Support Forum       Library Source       SourceForge Page       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes

G3D::GEntity Class Reference

Sample base class for an object in a 3D world. More...

Inherits G3D::ReferenceCountedObject.

List of all members.

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 CFrameframe () const
 Current position, i.e., as of last onSimulation call.
const PhysicsFrameSplineframeSpline () 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::stringname () 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.
_WeakPtrLinkedListReferenceCountedObject_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.

Detailed Description

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.


Member Typedef Documentation

Maps model names that are referenced in to ArticulatedModel::Ref, MD2Model::Ref or MD3::ModelRef.


Member Enumeration Documentation

enum G3D::GEntity::ModelType [protected]
Enumerator:
ARTICULATED_MODEL2 
MD2_MODEL 
MD3_MODEL 

Constructor & Destructor Documentation

G3D::GEntity::GEntity (  ) [protected]

Referenced by create().

G3D::GEntity::GEntity ( const std::string name,
AnyTableReader propertyTable,
const ModelTable modelTable 
) [protected]

Construct a GEntity.

Parameters:
nameThe name of this GEntity, e.g., "Player 1"
propertyTableThe 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.

Parameters:
modelTableMaps 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.


Member Function Documentation

static GEntity::Ref G3D::GEntity::create ( const std::string name,
AnyTableReader propertyTable,
const ModelTable modelTable 
) [inline, static]

Construct a GEntity.

Parameters:
nameThe name of this GEntity, e.g., "Player 1"
propertyTableThe 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.

Parameters:
modelTableMaps 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.

virtual void G3D::GEntity::onSimulation ( GameTime  absoluteTime,
GameTime  deltaTime 
) [virtual]

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]

Converts the current GEntity to an Any.

Subclasses should modify at least the name of the Table, which will be "GEntity" if not changed.


Member Data Documentation

Current pose.

Pose over time.

Pose for the previous onSimulation.

Current position.

Referenced by frame().

Root position over time.

Set m_frameSplineChanged if this changes.

Referenced by frameSpline(), and setFrameSpline().

True if the spline was mutated since load.

Used by toAny() to decide if m_sourceAny is out of date.

Referenced by setFrameSpline().

Bounds at the last pose() call, in world space.

Bounds at the last pose() call, in world space.

Referenced by name().

Frame before the previous onSimulation()

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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

documentation generated on Mon Nov 14 2011 10:39:17 using doxygen 1.7.2