Pyrogenesis  trunk
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CModel Class Reference

#include <Model.h>

Inheritance diagram for CModel:
Inheritance graph
[legend]
Collaboration diagram for CModel:
Collaboration graph
[legend]

Classes

struct  Prop
 

Public Member Functions

 CModel (CSkeletonAnimManager &skeletonAnimManager, CSimulation2 &simulation)
 
 ~CModel ()
 
virtual CModelToCModel ()
 Dynamic cast. More...
 
bool InitModel (const CModelDefPtr &modeldef)
 
void UpdateTo (float time)
 
const CModelDefPtrGetModelDef ()
 
void SetMaterial (const CMaterial &material)
 
void SetPlayerID (player_id_t id)
 
virtual void SetShadingColor (const CColor &color)
 
CMaterialGetMaterial ()
 
bool SetAnimation (CSkeletonAnim *anim, bool once=false)
 
CSkeletonAnimGetAnimation () const
 
void CopyAnimationFrom (CModel *source)
 
void SetFlags (int flags)
 
int GetFlags () const
 
void AddFlagsRec (int flags)
 
void RemoveShadowsRec ()
 
virtual void SetDirtyRec (int dirtyflags)
 Calls SetDirty on this model and all child objects. More...
 
virtual void SetTerrainDirty (ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1)
 Called when terrain has changed in the given inclusive bounds. More...
 
virtual void SetEntityVariable (const std::string &name, float value)
 Called when the entity tries to set some variable to affect the display of this model and/or its child objects. More...
 
virtual void CalcBounds ()
 Overridden to calculate both the world-space and object-space bounds of this model, and stores the result in m_Bounds and m_ObjectBounds, respectively. More...
 
const CBoundingBoxAlignedGetObjectBounds ()
 Returns the object-space bounds for this model, excluding its children. More...
 
virtual const CBoundingBoxAligned GetWorldBoundsRec ()
 Returns world space bounds of this object and all child objects. More...
 
void CalcStaticObjectBounds ()
 Auxiliary method; calculates object space bounds of this model, based solely on vertex positions, and stores the result in m_ObjectBounds. More...
 
void CalcAnimatedObjectBounds (CSkeletonAnimDef *anim, CBoundingBoxAligned &result)
 Auxiliary method; calculate object-space bounds encompassing all vertex positions for given animation, and stores the result in m_ObjectBounds. More...
 
virtual const CBoundingBoxAligned GetObjectSelectionBoundsRec ()
 Reimplemented here since proper models should participate in selection boxes. More...
 
virtual void SetTransform (const CMatrix3D &transform)
 Set transform of this object. More...
 
bool IsSkinned ()
 Return whether this is a skinned/skeletal model. More...
 
const CMatrix3DGetAnimatedBoneMatrices ()
 
CSkeletonAnimBuildAnimation (const VfsPath &pathname, const CStr &name, const CStr &ID, int frequency, float speed, float actionpos, float actionpos2, float soundpos)
 Load raw animation frame animation from given file, and build an animation specific to this model. More...
 
void AddProp (const SPropPoint *point, CModelAbstract *model, CObjectEntry *objectentry, float minHeight=0.f, float maxHeight=0.f, bool selectable=true)
 Add a prop to the model on the given point. More...
 
void AddAmmoProp (const SPropPoint *point, CModelAbstract *model, CObjectEntry *objectentry)
 Add a prop to the model on the given point, and treat it as the ammo prop. More...
 
void ShowAmmoProp ()
 Show the ammo prop (if any), and hide any other props on that prop point. More...
 
void HideAmmoProp ()
 Hide the ammo prop (if any), and show any other props on that prop point. More...
 
CModelAbstractFindFirstAmmoProp ()
 Find the first prop used for ammo, by this model or its own props. More...
 
std::vector< Prop > & GetProps ()
 
const std::vector< Prop > & GetProps () const
 
virtual CModelAbstractClone () const
 
virtual void ValidatePosition ()
 Ensure that both the transformation and the bone matrices are correct for this model and all its props. More...
 
virtual void InvalidatePosition ()
 Mark this model's position and bone matrices, and all props' positions as invalid. More...
 
- Public Member Functions inherited from CModelAbstract
 CModelAbstract ()
 
 ~CModelAbstract ()
 
virtual CModelDecalToCModelDecal ()
 Dynamic cast. More...
 
virtual CModelParticleEmitterToCModelParticleEmitter ()
 Dynamic cast. More...
 
virtual const CBoundingBoxOrientedGetSelectionBox ()
 Returns the world-space selection box of this model. More...
 
virtual void InvalidateBounds ()
 Marks the bounds as invalid. More...
 
void SetCustomSelectionShape (CustomSelectionShape *descriptor)
 Sets a custom selection shape as described by a descriptor. More...
 
virtual player_id_t GetPlayerID () const
 
virtual CColor GetShadingColor () const
 
- Public Member Functions inherited from CRenderableObject
 CRenderableObject ()
 
virtual ~CRenderableObject ()
 
const CMatrix3DGetTransform () const
 
const CMatrix3DGetInvTransform () const
 
void SetDirty (u32 dirtyflags)
 
const CBoundingBoxAlignedGetWorldBounds ()
 Returns the world-space axis-aligned bounds of this object. More...
 
void SetRenderData (CRenderData *renderdata)
 
CRenderDataGetRenderData ()
 Return object renderdata - can be null if renderer hasn't yet created the renderdata. More...
 

Private Member Functions

 NONCOPYABLE (CModel)
 
void ReleaseData ()
 

Private Attributes

CSimulation2m_Simulation
 
int m_Flags
 
CMaterial m_Material
 
CModelDefPtr m_pModelDef
 
CBoundingBoxAligned m_ObjectBounds
 
CSkeletonAnimm_Anim
 
float m_AnimTime
 
CMatrix3Dm_BoneMatrices
 Current state of all bones on this model; null if associated modeldef isn't skeletal. More...
 
std::vector< Propm_Props
 
const SPropPointm_AmmoPropPoint
 The prop point to which the ammo prop is attached, or NULL if none. More...
 
size_t m_AmmoLoadedProp
 If m_AmmoPropPoint is not NULL, then the index in m_Props of the ammo prop. More...
 
CSkeletonAnimManagerm_SkeletonAnimManager
 

Additional Inherited Members

- Public Attributes inherited from CModelAbstract
CModelAbstractm_Parent
 If non-null, points to the model that we are attached to. More...
 
bool m_PositionValid
 True if both transform and and bone matrices are valid. More...
 
player_id_t m_PlayerID
 
CColor m_ShadingColor
 Modulating color. More...
 
- Protected Member Functions inherited from CModelAbstract
void CalcSelectionBox ()
 
- Protected Member Functions inherited from CRenderableObject
void RecalculateBoundsIfNecessary ()
 Factored out so subclasses don't need to repeat this if they want to add additional getters for bounds-related methods (since they'll have to make sure to recalc the bounds if necessary before they return it). More...
 
- Protected Attributes inherited from CModelAbstract
CBoundingBoxOriented m_SelectionBox
 Selection box for this model. More...
 
bool m_SelectionBoxValid
 Is the current selection box valid? More...
 
CustomSelectionShapem_CustomSelectionShape
 Pointer to a descriptor for a custom-defined selection box shape. More...
 
- Protected Attributes inherited from CRenderableObject
CBoundingBoxAligned m_WorldBounds
 World-space bounds of this object. More...
 
CMatrix3D m_Transform
 
CMatrix3D m_InvTransform
 
CRenderDatam_RenderData
 
bool m_BoundsValid
 Remembers whether any bounds need to be recalculated. More...
 

Constructor & Destructor Documentation

CModel::CModel ( CSkeletonAnimManager skeletonAnimManager,
CSimulation2 simulation 
)
CModel::~CModel ( )

Member Function Documentation

void CModel::AddAmmoProp ( const SPropPoint point,
CModelAbstract model,
CObjectEntry objectentry 
)

Add a prop to the model on the given point, and treat it as the ammo prop.

The prop will be hidden by default.

void CModel::AddFlagsRec ( int  flags)
void CModel::AddProp ( const SPropPoint point,
CModelAbstract model,
CObjectEntry objectentry,
float  minHeight = 0.f,
float  maxHeight = 0.f,
bool  selectable = true 
)

Add a prop to the model on the given point.

CSkeletonAnim * CModel::BuildAnimation ( const VfsPath pathname,
const CStr &  name,
const CStr &  ID,
int  frequency,
float  speed,
float  actionpos,
float  actionpos2,
float  soundpos 
)

Load raw animation frame animation from given file, and build an animation specific to this model.

Parameters
pathnameanimation file to load
nameanimation name (e.g. "idle")
IDspecific ID of the animation, to sync with props
frequencyinfluences the random choices
speedanimation speed as a factor of the default animation speed
actionposoffset of 'action' event, in range [0, 1]
actionpos2offset of 'action2' event, in range [0, 1]
soundoffset of 'sound' event, in range [0, 1]
Returns
new animation, or NULL on error
void CModel::CalcAnimatedObjectBounds ( CSkeletonAnimDef anim,
CBoundingBoxAligned result 
)

Auxiliary method; calculate object-space bounds encompassing all vertex positions for given animation, and stores the result in m_ObjectBounds.

Called by CalcBounds (instead of CalcStaticBounds) if it has been determined that the object-space bounds need to take animations into account.

void CModel::CalcBounds ( )
virtual

Overridden to calculate both the world-space and object-space bounds of this model, and stores the result in m_Bounds and m_ObjectBounds, respectively.

Implements CRenderableObject.

void CModel::CalcStaticObjectBounds ( )

Auxiliary method; calculates object space bounds of this model, based solely on vertex positions, and stores the result in m_ObjectBounds.

Called by CalcBounds (instead of CalcAnimatedObjectBounds) if it has been determined that the object-space bounds are static.

CModelAbstract * CModel::Clone ( ) const
virtual

Implements CModelAbstract.

void CModel::CopyAnimationFrom ( CModel source)
CModelAbstract * CModel::FindFirstAmmoProp ( )

Find the first prop used for ammo, by this model or its own props.

const CMatrix3D* CModel::GetAnimatedBoneMatrices ( )
inline
CSkeletonAnim* CModel::GetAnimation ( ) const
inline
int CModel::GetFlags ( ) const
inline
CMaterial& CModel::GetMaterial ( )
inline
const CModelDefPtr& CModel::GetModelDef ( )
inline
const CBoundingBoxAligned& CModel::GetObjectBounds ( )
inline

Returns the object-space bounds for this model, excluding its children.

const CBoundingBoxAligned CModel::GetObjectSelectionBoundsRec ( )
virtual

Reimplemented here since proper models should participate in selection boxes.

Reimplemented from CModelAbstract.

std::vector<Prop>& CModel::GetProps ( )
inline
const std::vector<Prop>& CModel::GetProps ( ) const
inline
const CBoundingBoxAligned CModel::GetWorldBoundsRec ( )
virtual

Returns world space bounds of this object and all child objects.

Reimplemented from CModelAbstract.

void CModel::HideAmmoProp ( )

Hide the ammo prop (if any), and show any other props on that prop point.

bool CModel::InitModel ( const CModelDefPtr modeldef)
void CModel::InvalidatePosition ( )
virtual

Mark this model's position and bone matrices, and all props' positions as invalid.

Implements CModelAbstract.

bool CModel::IsSkinned ( )
inline

Return whether this is a skinned/skeletal model.

If it is, Get*BoneMatrices() will return valid non-NULL arrays.

CModel::NONCOPYABLE ( CModel  )
private
void CModel::ReleaseData ( )
private
void CModel::RemoveShadowsRec ( )
bool CModel::SetAnimation ( CSkeletonAnim anim,
bool  once = false 
)
virtual void CModel::SetDirtyRec ( int  dirtyflags)
inlinevirtual

Calls SetDirty on this model and all child objects.

Implements CModelAbstract.

virtual void CModel::SetEntityVariable ( const std::string &  name,
float  value 
)
inlinevirtual

Called when the entity tries to set some variable to affect the display of this model and/or its child objects.

Reimplemented from CModelAbstract.

void CModel::SetFlags ( int  flags)
inline
void CModel::SetMaterial ( const CMaterial material)
void CModel::SetPlayerID ( player_id_t  id)
virtual

Reimplemented from CModelAbstract.

void CModel::SetShadingColor ( const CColor color)
virtual

Reimplemented from CModelAbstract.

virtual void CModel::SetTerrainDirty ( ssize_t  i0,
ssize_t  j0,
ssize_t  i1,
ssize_t  j1 
)
inlinevirtual

Called when terrain has changed in the given inclusive bounds.

Might call SetDirty if the change affects this model.

Implements CModelAbstract.

void CModel::SetTransform ( const CMatrix3D transform)
virtual

Set transform of this object.

Note
In order to ensure that all child props are updated properly, you must call ValidatePosition().

Reimplemented from CRenderableObject.

void CModel::ShowAmmoProp ( )

Show the ammo prop (if any), and hide any other props on that prop point.

virtual CModel* CModel::ToCModel ( )
inlinevirtual

Dynamic cast.

Reimplemented from CModelAbstract.

void CModel::UpdateTo ( float  time)
void CModel::ValidatePosition ( )
virtual

Ensure that both the transformation and the bone matrices are correct for this model and all its props.

Implements CModelAbstract.

Member Data Documentation

size_t CModel::m_AmmoLoadedProp
private

If m_AmmoPropPoint is not NULL, then the index in m_Props of the ammo prop.

const SPropPoint* CModel::m_AmmoPropPoint
private

The prop point to which the ammo prop is attached, or NULL if none.

CSkeletonAnim* CModel::m_Anim
private
float CModel::m_AnimTime
private
CMatrix3D* CModel::m_BoneMatrices
private

Current state of all bones on this model; null if associated modeldef isn't skeletal.

Props may attach to these bones by means of the SPropPoint::m_BoneIndex field; in this case their transformation matrix held is relative to the bone transformation (see SPropPoint and CModel::ValidatePosition).

See also
SPropPoint
int CModel::m_Flags
private
CMaterial CModel::m_Material
private
CBoundingBoxAligned CModel::m_ObjectBounds
private
CModelDefPtr CModel::m_pModelDef
private
std::vector<Prop> CModel::m_Props
private
CSimulation2& CModel::m_Simulation
private
CSkeletonAnimManager& CModel::m_SkeletonAnimManager
private

The documentation for this class was generated from the following files: