Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CModel Class Reference

#include <Model.h>

Inheritance diagram for CModel:
CModelAbstract CRenderableObject

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 &colour)
 
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, 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)
 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
CBoundingBoxOriented
GetSelectionBox ()
 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...
 

Detailed Description

Definition at line 50 of file Model.h.

Constructor & Destructor Documentation

CModel::CModel ( CSkeletonAnimManager skeletonAnimManager,
CSimulation2 simulation 
)

Definition at line 47 of file Model.cpp.

CModel::~CModel ( )

Definition at line 56 of file Model.cpp.

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.

Definition at line 528 of file Model.cpp.

void CModel::AddFlagsRec ( int  flags)

Definition at line 624 of file Model.cpp.

void CModel::AddProp ( const SPropPoint point,
CModelAbstract model,
CObjectEntry objectentry,
float  minHeight = 0.f,
float  maxHeight = 0.f 
)

Add a prop to the model on the given point.

Definition at line 511 of file Model.cpp.

CSkeletonAnim * CModel::BuildAnimation ( const VfsPath pathname,
const CStr &  name,
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")
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

Definition at line 258 of file Model.cpp.

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.

Definition at line 144 of file Model.cpp.

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.

Definition at line 105 of file Model.cpp.

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.

Definition at line 130 of file Model.cpp.

CModelAbstract * CModel::Clone ( ) const
virtual

Implements CModelAbstract.

Definition at line 591 of file Model.cpp.

void CModel::CopyAnimationFrom ( CModel source)

Definition at line 496 of file Model.cpp.

CModelAbstract * CModel::FindFirstAmmoProp ( )

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

Definition at line 570 of file Model.cpp.

const CMatrix3D* CModel::GetAnimatedBoneMatrices ( )
inline

Definition at line 195 of file Model.h.

CSkeletonAnim* CModel::GetAnimation ( ) const
inline

Definition at line 114 of file Model.h.

int CModel::GetFlags ( ) const
inline

Definition at line 123 of file Model.h.

CMaterial& CModel::GetMaterial ( )
inline

Definition at line 108 of file Model.h.

const CModelDefPtr& CModel::GetModelDef ( )
inline

Definition at line 99 of file Model.h.

const CBoundingBoxAligned& CModel::GetObjectBounds ( )
inline

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

Definition at line 157 of file Model.h.

const CBoundingBoxAligned CModel::GetObjectSelectionBoundsRec ( )
virtual

Reimplemented here since proper models should participate in selection boxes.

Reimplemented from CModelAbstract.

Definition at line 203 of file Model.cpp.

std::vector<Prop>& CModel::GetProps ( )
inline

Definition at line 240 of file Model.h.

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

Definition at line 241 of file Model.h.

const CBoundingBoxAligned CModel::GetWorldBoundsRec ( )
virtual

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

Reimplemented from CModelAbstract.

Definition at line 195 of file Model.cpp.

void CModel::HideAmmoProp ( )

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

Definition at line 555 of file Model.cpp.

bool CModel::InitModel ( const CModelDefPtr modeldef)

Definition at line 76 of file Model.cpp.

void CModel::InvalidatePosition ( )
virtual

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

Implements CModelAbstract.

Definition at line 309 of file Model.cpp.

bool CModel::IsSkinned ( )
inline

Return whether this is a skinned/skeletal model.

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

Definition at line 192 of file Model.h.

CModel::NONCOPYABLE ( CModel  )
private
void CModel::ReleaseData ( )
private

Definition at line 63 of file Model.cpp.

void CModel::RemoveShadowsRec ( )

Definition at line 639 of file Model.cpp.

bool CModel::SetAnimation ( CSkeletonAnim anim,
bool  once = false 
)

Definition at line 449 of file Model.cpp.

virtual void CModel::SetDirtyRec ( int  dirtyflags)
inlinevirtual

Calls SetDirty on this model and all child objects.

Implements CModelAbstract.

Definition at line 131 of file Model.h.

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.

Definition at line 144 of file Model.h.

void CModel::SetFlags ( int  flags)
inline

Definition at line 121 of file Model.h.

void CModel::SetMaterial ( const CMaterial material)

Definition at line 655 of file Model.cpp.

void CModel::SetPlayerID ( player_id_t  id)
virtual

Reimplemented from CModelAbstract.

Definition at line 660 of file Model.cpp.

void CModel::SetShadingColor ( const CColor colour)
virtual

Reimplemented from CModelAbstract.

Definition at line 668 of file Model.cpp.

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.

Definition at line 138 of file Model.h.

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.

Definition at line 615 of file Model.cpp.

void CModel::ShowAmmoProp ( )

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

Definition at line 540 of file Model.cpp.

virtual CModel* CModel::ToCModel ( )
inlinevirtual

Dynamic cast.

Reimplemented from CModelAbstract.

Definition at line 88 of file Model.h.

void CModel::UpdateTo ( float  time)

Definition at line 292 of file Model.cpp.

void CModel::ValidatePosition ( )
virtual

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

Implements CModelAbstract.

Definition at line 319 of file Model.cpp.

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.

Definition at line 300 of file Model.h.

const SPropPoint* CModel::m_AmmoPropPoint
private

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

Definition at line 295 of file Model.h.

CSkeletonAnim* CModel::m_Anim
private

Definition at line 276 of file Model.h.

float CModel::m_AnimTime
private

Definition at line 278 of file Model.h.

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

Definition at line 288 of file Model.h.

int CModel::m_Flags
private

Definition at line 266 of file Model.h.

CMaterial CModel::m_Material
private

Definition at line 268 of file Model.h.

CBoundingBoxAligned CModel::m_ObjectBounds
private

Definition at line 274 of file Model.h.

CModelDefPtr CModel::m_pModelDef
private

Definition at line 270 of file Model.h.

std::vector<Prop> CModel::m_Props
private

Definition at line 290 of file Model.h.

CSimulation2& CModel::m_Simulation
private

Definition at line 263 of file Model.h.

CSkeletonAnimManager& CModel::m_SkeletonAnimManager
private

Definition at line 303 of file Model.h.


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