| Support Forum Library Source SourceForge Page G3D Web Page |
Sample base class for an object in a 3D world. More...
Inherits G3D::ReferenceCountedObject.
Public Types | |
| typedef Table< std::string, ReferenceCountedPointer < ReferenceCountedObject > > | ModelTable |
| Maps model names that are referenced in to ArticulatedModel::Ref, MD2Model::Ref or MD3::ModelRef. | |
| typedef ReferenceCountedPointer < GEntity > | Ref |
Public Member Functions | |
| const CFrame & | frame () const |
| Current position, i.e., as of last onSimulation call. | |
| const PhysicsFrameSpline & | frameSpline () const |
| Provides access to the underlying spline. | |
| virtual void | getLastBounds (class AABox &box) const |
| Return a world-space axis-aligned bounding box as of the last call to onPose(). | |
| virtual void | getLastBounds (class Sphere &sphere) const |
| Return a world-space bounding sphere as of the last call to onPose(). | |
| virtual void | getLastBounds (class Box &box) const |
| Return a world-space bounding box as of the last call to onPose(). | |
| virtual bool | intersect (const Ray &R, float &maxDistance) const |
| virtual bool | intersectBounds (const Ray &R, float &maxDistance) const |
| Returns true if there is conservatively some intersection with the object's bounds closer than maxDistance to the ray origin. | |
| const std::string & | name () const |
| virtual void | onPose (Array< Surface::Ref > &surfaceArray) |
| Pose as of the last simulation time. | |
| virtual void | onSimulation (GameTime absoluteTime, GameTime deltaTime) |
| Physical simulation callback. | |
| void | ReferenceCountedObject_zeroWeakPointers () |
| Automatically called immediately before the object is deleted. | |
| void | setFrameSpline (const PhysicsFrameSpline &s) |
| virtual Any | toAny () const |
| Converts the current GEntity to an Any. | |
Static Public Member Functions | |
| static GEntity::Ref | create (const std::string &name, AnyTableReader &propertyTable, const ModelTable &modelTable) |
Public Attributes | |
| AtomicInt32 | ReferenceCountedObject_refCount |
| The long name is to keep this from accidentally conflicting with a subclass's variable name. | |
| _WeakPtrLinkedList * | ReferenceCountedObject_weakPointer |
| Linked list of all weak pointers that reference this (some may be on the stack!). | |
Protected Types | |
| enum | ModelType { ARTICULATED_MODEL2, MD2_MODEL, MD3_MODEL } |
Protected Member Functions | |
| GEntity () | |
| GEntity (const std::string &name, AnyTableReader &propertyTable, const ModelTable &modelTable) | |
| Construct a GEntity. | |
| virtual void | simulatePose (GameTime absoluteTime, GameTime deltaTime) |
| Animates the appropriate pose type for the model selected. | |
Protected Attributes | |
| ArticulatedModel::Ref | m_art2Model |
| ArticulatedModel::Pose | m_art2Pose |
| Current pose. | |
| ArticulatedModel::PoseSpline | m_art2PoseSpline |
| Pose over time. | |
| ArticulatedModel::Pose | m_art2PreviousPose |
| Pose for the previous onSimulation. | |
| CFrame | m_frame |
| Current position. | |
| PhysicsFrameSpline | m_frameSpline |
| Root position over time. | |
| bool | m_frameSplineChanged |
| True if the spline was mutated since load. | |
| AABox | m_lastBoxBounds |
| Bounds at the last pose() call, in world space. | |
| Sphere | m_lastSphereBounds |
| Bounds at the last pose() call, in world space. | |
| MD2Model::Ref | m_md2Model |
| MD2Model::Pose | m_md2Pose |
| MD3Model::Ref | m_md3Model |
| MD3Model::Pose | m_md3Pose |
| ModelType | m_modelType |
| std::string | m_name |
| CFrame | m_previousFrame |
| Frame before the previous onSimulation() | |
| Any | m_sourceAny |
| The Any from which this was originally constructed. | |
Sample base class for an object in a 3D world.
G3D does not contain a mandatory Entity class in the API because it is a very application-specific role. However, this is a base class of how you might begin to structure one to get you started.
| typedef Table<std::string, ReferenceCountedPointer<ReferenceCountedObject> > G3D::GEntity::ModelTable |
Maps model names that are referenced in to ArticulatedModel::Ref, MD2Model::Ref or MD3::ModelRef.
enum G3D::GEntity::ModelType [protected] |
| G3D::GEntity::GEntity | ( | ) | [protected] |
Referenced by create().
| G3D::GEntity::GEntity | ( | const std::string & | name, |
| AnyTableReader & | propertyTable, | ||
| const ModelTable & | modelTable | ||
| ) | [protected] |
Construct a GEntity.
| name | The name of this GEntity, e.g., "Player 1" |
| propertyTable | The form is given below. It is intended that subclasses replace the table name and add new fields. |
<some base class name> { model = <modelname>; position = <CFrame, Vector3, or PhysicsFrameSpline>; pose = <ArticulatedModel::PoseSpline>; castsShadows = <bool>; }
The pose, position, and castsShadows fields are optional. The GEntity base class reads these fields. Other subclasses read their own fields.
If specified, the castsShadows field overwrites the pose's castsShadows field. This is a load-time convenience.
| modelTable | Maps model names that are referenced in propertyTable to ArticulatedModel::Ref, MD2Model::Ref or MD3::ModelRef. |
The original caller (typically, a Scene class) should invoke AnyTableReader::verifyDone to ensure that all of the fields specified were read by some subclass along the inheritance chain.
See samples/starter/source/Scene.cpp for an example of use.
| static GEntity::Ref G3D::GEntity::create | ( | const std::string & | name, |
| AnyTableReader & | propertyTable, | ||
| const ModelTable & | modelTable | ||
| ) | [inline, static] |
Construct a GEntity.
| name | The name of this GEntity, e.g., "Player 1" |
| propertyTable | The form is given below. It is intended that subclasses replace the table name and add new fields. |
<some base class name> { model = <modelname>; position = <CFrame, Vector3, or PhysicsFrameSpline>; pose = <ArticulatedModel::PoseSpline>; castsShadows = <bool>; }
The pose, position, and castsShadows fields are optional. The GEntity base class reads these fields. Other subclasses read their own fields.
If specified, the castsShadows field overwrites the pose's castsShadows field. This is a load-time convenience.
| modelTable | Maps model names that are referenced in propertyTable to ArticulatedModel::Ref, MD2Model::Ref or MD3::ModelRef. |
The original caller (typically, a Scene class) should invoke AnyTableReader::verifyDone to ensure that all of the fields specified were read by some subclass along the inheritance chain.
See samples/starter/source/Scene.cpp for an example of use.
| const CFrame& G3D::GEntity::frame | ( | ) | const [inline] |
Current position, i.e., as of last onSimulation call.
| const PhysicsFrameSpline& G3D::GEntity::frameSpline | ( | ) | const [inline] |
Provides access to the underlying spline.
| virtual void G3D::GEntity::getLastBounds | ( | class AABox & | box ) | const [virtual] |
Return a world-space axis-aligned bounding box as of the last call to onPose().
| virtual void G3D::GEntity::getLastBounds | ( | class Sphere & | sphere ) | const [virtual] |
Return a world-space bounding sphere as of the last call to onPose().
| virtual void G3D::GEntity::getLastBounds | ( | class Box & | box ) | const [virtual] |
Return a world-space bounding box as of the last call to onPose().
| virtual bool G3D::GEntity::intersect | ( | const Ray & | R, |
| float & | maxDistance | ||
| ) | const [virtual] |
| virtual bool G3D::GEntity::intersectBounds | ( | const Ray & | R, |
| float & | maxDistance | ||
| ) | const [virtual] |
Returns true if there is conservatively some intersection with the object's bounds closer than maxDistance to the ray origin.
If so, updates maxDistance with the intersection distance.
The bounds used may be more accurate than any of the given getLastBounds() results because the method may recurse into individual parts of the scene graph within the GEntity.
| const std::string& G3D::GEntity::name | ( | ) | const [inline] |
| virtual void G3D::GEntity::onPose | ( | Array< Surface::Ref > & | surfaceArray ) | [virtual] |
Pose as of the last simulation time.
Physical simulation callback.
The default implementation animates the model pose (by calling simulatePose()) and moves the frame() along m_frameSpline.
| void G3D::ReferenceCountedObject::ReferenceCountedObject_zeroWeakPointers | ( | ) | [inherited] |
Automatically called immediately before the object is deleted.
This is not called from the destructor because it needs to be invoked before the subclass destructor.
| void G3D::GEntity::setFrameSpline | ( | const PhysicsFrameSpline & | s ) | [inline] |
| virtual void G3D::GEntity::simulatePose | ( | GameTime | absoluteTime, |
| GameTime | deltaTime | ||
| ) | [protected, virtual] |
Animates the appropriate pose type for the model selected.
Called from onSimulation. Subclasses will frequently replace onSimulation but retain this helper method.
| virtual Any G3D::GEntity::toAny | ( | ) | const [virtual] |
ArticulatedModel::Ref G3D::GEntity::m_art2Model [protected] |
ArticulatedModel::Pose G3D::GEntity::m_art2Pose [protected] |
Current pose.
Pose over time.
Pose for the previous onSimulation.
CFrame G3D::GEntity::m_frame [protected] |
Current position.
Referenced by frame().
PhysicsFrameSpline G3D::GEntity::m_frameSpline [protected] |
Root position over time.
Set m_frameSplineChanged if this changes.
Referenced by frameSpline(), and setFrameSpline().
bool G3D::GEntity::m_frameSplineChanged [protected] |
True if the spline was mutated since load.
Used by toAny() to decide if m_sourceAny is out of date.
Referenced by setFrameSpline().
AABox G3D::GEntity::m_lastBoxBounds [protected] |
Bounds at the last pose() call, in world space.
Sphere G3D::GEntity::m_lastSphereBounds [protected] |
Bounds at the last pose() call, in world space.
MD2Model::Ref G3D::GEntity::m_md2Model [protected] |
MD2Model::Pose G3D::GEntity::m_md2Pose [protected] |
MD3Model::Ref G3D::GEntity::m_md3Model [protected] |
MD3Model::Pose G3D::GEntity::m_md3Pose [protected] |
ModelType G3D::GEntity::m_modelType [protected] |
std::string G3D::GEntity::m_name [protected] |
Referenced by name().
CFrame G3D::GEntity::m_previousFrame [protected] |
Frame before the previous onSimulation()
Any G3D::GEntity::m_sourceAny [protected] |
The Any from which this was originally constructed.
The long name is to keep this from accidentally conflicting with a subclass's variable name.
Do not use or explicitly manipulate this value--its type may change in the future and is not part of the supported API.
Linked list of all weak pointers that reference this (some may be on the stack!).
Do not use or explicitly manipulate this value.
1.7.2