Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/Model.h
Show All 21 Lines | |||||
#ifndef INCLUDED_MODEL | #ifndef INCLUDED_MODEL | ||||
#define INCLUDED_MODEL | #define INCLUDED_MODEL | ||||
#include <vector> | #include <vector> | ||||
#include "graphics/Texture.h" | #include "graphics/Texture.h" | ||||
#include "graphics/Material.h" | #include "graphics/Material.h" | ||||
#include "graphics/MeshManager.h" | #include "graphics/MeshManager.h" | ||||
#include "graphics/ModelAbstract.h" | #include "graphics/SceneObject.h" | ||||
struct SPropPoint; | struct SPropPoint; | ||||
class CObjectEntry; | class CObjectEntry; | ||||
class CSkeletonAnim; | class CSkeletonAnim; | ||||
class CSkeletonAnimDef; | class CSkeletonAnimDef; | ||||
class CSkeletonAnimManager; | class CSkeletonAnimManager; | ||||
class CSimulation2; | class CSimulation2; | ||||
class CUnit; | |||||
#define MODELFLAG_CASTSHADOWS (1<<0) | #define MODELFLAG_CASTSHADOWS (1<<0) | ||||
#define MODELFLAG_NOLOOPANIMATION (1<<1) | #define MODELFLAG_NOLOOPANIMATION (1<<1) | ||||
#define MODELFLAG_SILHOUETTE_DISPLAY (1<<2) | #define MODELFLAG_SILHOUETTE_DISPLAY (1<<2) | ||||
#define MODELFLAG_SILHOUETTE_OCCLUDER (1<<3) | #define MODELFLAG_SILHOUETTE_OCCLUDER (1<<3) | ||||
#define MODELFLAG_IGNORE_LOS (1<<4) | #define MODELFLAG_IGNORE_LOS (1<<4) | ||||
#define MODELFLAG_FLOATONWATER (1<<5) | #define MODELFLAG_FLOATONWATER (1<<5) | ||||
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||
// CModel: basically, a mesh object - holds the texturing and skinning | // CModel: basically, a mesh object - holds the texturing and skinning | ||||
// information for a model in game | // information for a model in game | ||||
class CModel : public CModelAbstract | class CModel : public CSceneObject | ||||
{ | { | ||||
NONCOPYABLE(CModel); | NONCOPYABLE(CModel); | ||||
public: | public: | ||||
struct Prop | struct Prop | ||||
{ | { | ||||
Prop() : m_MinHeight(0.f), m_MaxHeight(0.f), m_Point(0), m_Model(0), m_ObjectEntry(0), m_Hidden(false), m_Selectable(true) {} | Prop() : m_MinHeight(0.f), m_MaxHeight(0.f), m_Point(0), m_Model(0), m_ObjectEntry(0), m_Hidden(false), m_Selectable(true) {} | ||||
float m_MinHeight; | float m_MinHeight; | ||||
float m_MaxHeight; | float m_MaxHeight; | ||||
/** | /** | ||||
* Location of the prop point within its parent model, relative to either a bone in the parent model or to the | * Location of the prop point within its parent model, relative to either a bone in the parent model or to the | ||||
* parent model's origin. See the documentation for @ref SPropPoint for more details. | * parent model's origin. See the documentation for @ref SPropPoint for more details. | ||||
* @see SPropPoint | * @see SPropPoint | ||||
*/ | */ | ||||
const SPropPoint* m_Point; | const SPropPoint* m_Point; | ||||
/** | /** | ||||
* Pointer to the model associated with this prop. Note that the transform matrix held by this model is the full object-to-world | * Pointer to the model associated with this prop. Note that the transform matrix held by this model is the full object-to-world | ||||
* space transform, taking into account all parent model positioning (see @ref CModel::ValidatePosition for positioning logic). | * space transform, taking into account all parent model positioning (see @ref CModel::ValidatePosition for positioning logic). | ||||
* @see CModel::ValidatePosition | * @see CModel::ValidatePosition | ||||
*/ | */ | ||||
CModelAbstract* m_Model; | CSceneObject* m_Model; | ||||
CObjectEntry* m_ObjectEntry; | CObjectEntry* m_ObjectEntry; | ||||
bool m_Hidden; ///< Should this prop be temporarily removed from rendering? | bool m_Hidden; ///< Should this prop be temporarily removed from rendering? | ||||
bool m_Selectable; /// < should this prop count in the selection size? | bool m_Selectable; /// < should this prop count in the selection size? | ||||
}; | }; | ||||
public: | public: | ||||
// constructor | // constructor | ||||
Show All 11 Lines | public: | ||||
// setup model from given geometry | // setup model from given geometry | ||||
bool InitModel(const CModelDefPtr& modeldef); | bool InitModel(const CModelDefPtr& modeldef); | ||||
// update this model's state; 'time' is the absolute time since the start of the animation, in MS | // update this model's state; 'time' is the absolute time since the start of the animation, in MS | ||||
void UpdateTo(float time); | void UpdateTo(float time); | ||||
// get the model's geometry data | // get the model's geometry data | ||||
const CModelDefPtr& GetModelDef() { return m_pModelDef; } | const CModelDefPtr& GetModelDef() { return m_pModelDef; } | ||||
// Update our owner, also update props. | |||||
virtual void SetOwner(CUnit* owner); | |||||
// set the model's material | // set the model's material | ||||
void SetMaterial(const CMaterial &material); | void SetMaterial(const CMaterial &material); | ||||
// set the model's player ID, recursively through props | |||||
void SetPlayerID(player_id_t id); | |||||
// set the models mod color | |||||
virtual void SetShadingColor(const CColor& color); | |||||
// get the model's material | // get the model's material | ||||
CMaterial& GetMaterial() { return m_Material; } | CMaterial& GetMaterial() { return m_Material; } | ||||
// set the given animation as the current animation on this model | // set the given animation as the current animation on this model | ||||
bool SetAnimation(CSkeletonAnim* anim, bool once = false); | bool SetAnimation(CSkeletonAnim* anim, bool once = false); | ||||
// get the currently playing animation, if any | // get the currently playing animation, if any | ||||
CSkeletonAnim* GetAnimation() const { return m_Anim; } | CSkeletonAnim* GetAnimation() const { return m_Anim; } | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | public: | ||||
* @param sound offset of 'sound' event, in range [0, 1] | * @param sound offset of 'sound' event, in range [0, 1] | ||||
* @return new animation, or NULL on error | * @return new animation, or NULL on error | ||||
*/ | */ | ||||
CSkeletonAnim* BuildAnimation(const VfsPath& pathname, const CStr& name, const CStr& ID, int frequency, float speed, float actionpos, float actionpos2, float soundpos); | CSkeletonAnim* BuildAnimation(const VfsPath& pathname, const CStr& name, const CStr& ID, int frequency, float speed, float actionpos, float actionpos2, float soundpos); | ||||
/** | /** | ||||
* Add a prop to the model on the given point. | * Add a prop to the model on the given point. | ||||
*/ | */ | ||||
void AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f, bool selectable = true); | void AddProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f, bool selectable = true); | ||||
/** | /** | ||||
* Add a prop to the model on the given point, and treat it as the ammo prop. | * Add a prop to the model on the given point, and treat it as the ammo prop. | ||||
* The prop will be hidden by default. | * The prop will be hidden by default. | ||||
*/ | */ | ||||
void AddAmmoProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry); | void AddAmmoProp(const SPropPoint* point, CSceneObject* model, CObjectEntry* objectentry); | ||||
/** | /** | ||||
* Show the ammo prop (if any), and hide any other props on that prop point. | * Show the ammo prop (if any), and hide any other props on that prop point. | ||||
*/ | */ | ||||
void ShowAmmoProp(); | void ShowAmmoProp(); | ||||
/** | /** | ||||
* Hide the ammo prop (if any), and show any other props on that prop point. | * Hide the ammo prop (if any), and show any other props on that prop point. | ||||
*/ | */ | ||||
void HideAmmoProp(); | void HideAmmoProp(); | ||||
/** | /** | ||||
* Find the first prop used for ammo, by this model or its own props. | * Find the first prop used for ammo, by this model or its own props. | ||||
*/ | */ | ||||
CModelAbstract* FindFirstAmmoProp(); | CSceneObject* FindFirstAmmoProp(); | ||||
// return prop list | // return prop list | ||||
std::vector<Prop>& GetProps() { return m_Props; } | std::vector<Prop>& GetProps() { return m_Props; } | ||||
const std::vector<Prop>& GetProps() const { return m_Props; } | const std::vector<Prop>& GetProps() const { return m_Props; } | ||||
// return a clone of this model | // return a clone of this model | ||||
virtual CModelAbstract* Clone() const; | virtual CSceneObject* Clone() const; | ||||
/** | /** | ||||
* Ensure that both the transformation and the bone | * Ensure that both the transformation and the bone | ||||
* matrices are correct for this model and all its props. | * matrices are correct for this model and all its props. | ||||
*/ | */ | ||||
virtual void ValidatePosition(); | virtual void ValidatePosition(); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator