Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
#include <Model.h>
Classes | |
struct | Prop |
Public Member Functions | |
CModel (const CSimulation2 &simulation, const CMaterial &material, const CModelDefPtr &modeldef) | |
~CModel () override | |
CModel * | ToCModel () override |
Dynamic cast. More... | |
void | UpdateTo (float time) |
const CModelDefPtr & | GetModelDef () |
void | SetPlayerID (player_id_t id) override |
void | SetShadingColor (const CColor &color) override |
const CMaterial & | GetMaterial () |
bool | SetAnimation (CSkeletonAnim *anim, bool once=false) |
CSkeletonAnim * | GetAnimation () const |
void | CopyAnimationFrom (CModel *source) |
void | SetFlags (int flags) |
int | GetFlags () const |
void | AddFlagsRec (int flags) |
void | RemoveShadowsRec () |
void | SetTerrainDirty (ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) override |
Called when terrain has changed in the given inclusive bounds. More... | |
void | SetEntityVariable (const std::string &name, float value) override |
Called when the entity tries to set some variable to affect the display of this model and/or its child objects. More... | |
void | CalcBounds () override |
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 CBoundingBoxAligned & | GetObjectBounds () |
Returns the object-space bounds for this model, excluding its children. More... | |
const CBoundingBoxAligned | GetWorldBoundsRec () override |
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... | |
const CBoundingBoxAligned | GetObjectSelectionBoundsRec () override |
Reimplemented here since proper models should participate in selection boxes. More... | |
void | SetTransform (const CMatrix3D &transform) override |
Set transform of this object. More... | |
bool | IsSkinned () |
Return whether this is a skinned/skeletal model. More... | |
const CMatrix3D * | GetAnimatedBoneMatrices () |
void | AddProp (const SPropPoint *point, std::unique_ptr< 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, std::unique_ptr< 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... | |
CModelAbstract * | FindFirstAmmoProp () |
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 |
std::unique_ptr< CModelAbstract > | Clone () const override |
void | ValidatePosition () override |
Ensure that both the transformation and the bone matrices are correct for this model and all its props. More... | |
void | InvalidatePosition () override |
Mark this model's position and bone matrices, and all props' positions as invalid. More... | |
Public Member Functions inherited from CModelAbstract | |
CModelAbstract () | |
virtual | ~CModelAbstract () |
virtual std::unique_ptr< CModelAbstract > | Clone () const =0 |
virtual CModelDummy * | ToCModelDummy () |
Dynamic cast. More... | |
virtual CModel * | ToCModel () |
Dynamic cast. More... | |
virtual CModelDecal * | ToCModelDecal () |
Dynamic cast. More... | |
virtual CModelParticleEmitter * | ToCModelParticleEmitter () |
Dynamic cast. More... | |
virtual const CBoundingBoxAligned | GetWorldBoundsRec () |
Returns world space bounds of this object and all child objects. 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 const CBoundingBoxAligned | GetObjectSelectionBoundsRec () |
Returns the (object-space) bounds that should be used to construct a selection box for this model and its children. More... | |
virtual void | SetTerrainDirty (ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1)=0 |
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 | ValidatePosition ()=0 |
Ensure that both the transformation and the bone matrices are correct for this model and all its props. More... | |
virtual void | InvalidatePosition ()=0 |
Mark this model's position and bone matrices, and all props' positions as invalid. More... | |
virtual void | SetPlayerID (player_id_t id) |
virtual player_id_t | GetPlayerID () const |
virtual void | SetShadingColor (const CColor &color) |
virtual const CColor & | GetShadingColor () const |
Public Member Functions inherited from CRenderableObject | |
CRenderableObject () | |
virtual | ~CRenderableObject () |
virtual void | SetTransform (const CMatrix3D &transform) |
const CMatrix3D & | GetTransform () const |
const CMatrix3D & | GetInvTransform () const |
void | SetDirty (u32 dirtyflags) |
virtual void | CalcBounds ()=0 |
(Re)calculates and stores any bounds or bound-dependent data for this object. More... | |
const CBoundingBoxAligned & | GetWorldBounds () |
Returns the world-space axis-aligned bounds of this object. More... | |
virtual void | InvalidateBounds () |
Marks the bounds as invalid. More... | |
void | SetRenderData (CRenderData *renderdata) |
CRenderData * | GetRenderData () |
Return object renderdata - can be null if renderer hasn't yet created the renderdata. More... | |
Private Member Functions | |
NONCOPYABLE (CModel) | |
Private Attributes | |
const CSimulation2 & | m_Simulation |
int | m_Flags {0} |
CMaterial | m_Material |
const CModelDefPtr | m_pModelDef |
CBoundingBoxAligned | m_ObjectBounds |
CSkeletonAnim * | m_Anim = nullptr |
float | m_AnimTime {0.0f} |
CMatrix3D * | m_BoneMatrices {nullptr} |
Current state of all bones on this model; null if associated modeldef isn't skeletal. More... | |
std::vector< Prop > | m_Props |
const SPropPoint * | m_AmmoPropPoint {nullptr} |
The prop point to which the ammo prop is attached, or NULL if none. More... | |
size_t | m_AmmoLoadedProp {0} |
If m_AmmoPropPoint is not NULL, then the index in m_Props of the ammo prop. More... | |
Additional Inherited Members | |
Public Attributes inherited from CModelAbstract | |
CModelAbstract * | m_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... | |
CustomSelectionShape * | m_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 |
CRenderData * | m_RenderData |
bool | m_BoundsValid |
Remembers whether any bounds need to be recalculated. More... | |
CModel::CModel | ( | const CSimulation2 & | simulation, |
const CMaterial & | material, | ||
const CModelDefPtr & | modeldef | ||
) |
|
override |
void CModel::AddAmmoProp | ( | const SPropPoint * | point, |
std::unique_ptr< 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, |
std::unique_ptr< 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.
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.
|
overridevirtual |
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.
|
overridevirtual |
Implements CModelAbstract.
void CModel::CopyAnimationFrom | ( | CModel * | source | ) |
CModelAbstract * CModel::FindFirstAmmoProp | ( | ) |
Find the first prop used for ammo, by this model or its own props.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the object-space bounds for this model, excluding its children.
|
overridevirtual |
Reimplemented here since proper models should participate in selection boxes.
Reimplemented from CModelAbstract.
|
inline |
|
inline |
|
overridevirtual |
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.
|
overridevirtual |
Mark this model's position and bone matrices, and all props' positions as invalid.
Implements CModelAbstract.
|
inline |
Return whether this is a skinned/skeletal model.
If it is, Get*BoneMatrices() will return valid non-NULL arrays.
|
private |
void CModel::RemoveShadowsRec | ( | ) |
bool CModel::SetAnimation | ( | CSkeletonAnim * | anim, |
bool | once = false |
||
) |
|
inlineoverridevirtual |
Called when the entity tries to set some variable to affect the display of this model and/or its child objects.
Reimplemented from CModelAbstract.
|
inline |
|
overridevirtual |
Reimplemented from CModelAbstract.
|
overridevirtual |
Reimplemented from CModelAbstract.
|
inlineoverridevirtual |
Called when terrain has changed in the given inclusive bounds.
Might call SetDirty if the change affects this model.
Implements CModelAbstract.
|
overridevirtual |
Set transform of this object.
Reimplemented from CRenderableObject.
void CModel::ShowAmmoProp | ( | ) |
Show the ammo prop (if any), and hide any other props on that prop point.
|
inlineoverridevirtual |
Dynamic cast.
Reimplemented from CModelAbstract.
void CModel::UpdateTo | ( | float | time | ) |
|
overridevirtual |
Ensure that both the transformation and the bone matrices are correct for this model and all its props.
Implements CModelAbstract.
|
private |
If m_AmmoPropPoint is not NULL, then the index in m_Props of the ammo prop.
|
private |
The prop point to which the ammo prop is attached, or NULL if none.
|
private |
|
private |
|
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).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |