My Project
ParaXModelCanvas.h
1 #pragma once
2 #include "IAttributeFields.h"
3 
4 namespace ParaEngine
5 {
6  class CanvasAttachment;
7  struct LightParams;
8 
18  {
19  public:
21  virtual ~ParaXModelCanvas();
22 
23  ATTRIBUTE_DEFINE_CLASS(ParaXModelCanvas);
25  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
26 
28  virtual IAttributeFields* GetChildAttributeObject(const std::string& sName);
30  virtual int GetChildAttributeObjectCount(int nColumnIndex = 0);
32  virtual int GetChildAttributeColumnCount();
33  virtual IAttributeFields* GetChildAttributeObject(int nRowIndex, int nColumnIndex = 0);
34 
35  public:
42  bool Animate(SceneState * sceneState, CharacterPose* pPose, int nAnimID = 0, IAttributeFields* pAnimInstance = NULL);
44  void Draw(SceneState * sceneState, CParameterBlock* materialParams = NULL);
46  void BuildShadowVolume(SceneState * sceneState, ShadowVolume * pShadowVolume, LightParams* pLight, Matrix4* mxWorld);
47 
50  void SetAutoCharacterModel(bool bAutoCharacterModel);
56  bool InitBaseModel(ParaXEntity * pModel);
57 
60  void MountOnModel(ParaXEntity *model, float fScale = 1.0f);
62  void UnmountModel();
64  bool IsMounted();
80  CanvasAttachment* addAttachment(ParaXEntity *model, int id, int slot, float fScale = 1.0f);
81  CanvasAttachment* addAttachment(MeshEntity *model, int id, int slot, float fScale = 1.0f);
82 
84  void clearAttachments();
89  void deleteSlot(int slot);
90 
92  CanvasAttachment* GetChild(int id, int slot = -1);
93 
99  void deleteAttachment(int nAttachmentID);
100 
101  public:
102  enum _MODEL_LIGHT{
103  LT_AMBIENT,
104  LT_DIRECTIONAL,
105  LT_MODEL_ONLY
106  };
107  _MODEL_LIGHT m_lightType;
108 
111 
115 
116  private:
118  asset_ptr<ParaXEntity> m_baseModel;
120  asset_ptr<ParaXEntity> m_MountModel;
121  };
122 
124 
129  {
130  public:
132  CanvasAttachment(CanvasAttachment *parent, ParaXEntity *model, int id, int slot, float scale = 1.0f);
133  CanvasAttachment(CanvasAttachment *parent, MeshEntity *model, int id, int slot, float scale = 1.0f);
134  virtual ~CanvasAttachment();
135 
136  ATTRIBUTE_DEFINE_CLASS(CanvasAttachment);
137 
139  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
140 
142  virtual IAttributeFields* GetChildAttributeObject(const std::string& sName);
144  virtual int GetChildAttributeObjectCount(int nColumnIndex = 0);
146  virtual int GetChildAttributeColumnCount();
147  virtual IAttributeFields* GetChildAttributeObject(int nRowIndex, int nColumnIndex = 0);
148 
149  public:
150  void SetReplaceableTexture(TextureEntity* pTex);
151  void SetModel(ParaXEntity* pModel);
152  void SetModel(MeshEntity* pModel);
153 
155  void SetOffset(float x, float y, float z);
156 
160  bool SetupParantTransform(float fCameraToCurObjectDistance = 0.f);
161 
170  CanvasAttachment* addChild(ParaXEntity *model, int id, int slot, float scale = 1.0f);
171  CanvasAttachment* addChild(MeshEntity *model, int id, int slot, float scale = 1.0f);
172 
174  CanvasAttachment* GetChild(int id, int slot = -1);
175 
177  IAttributeFields * GetAttributeObject();
178 
181  void AttachChild(CanvasAttachment* att);
182 
183  void delSlot(int slot);
184  void delChildren();
185  void delChild(CanvasAttachment* child);
187  void delChildByID(int nID);
188 
192  void release();
199  bool animate(SceneState * sceneState, CharacterPose* pPose, bool bUseGlobal = false, int nAnimID = 0, IAttributeFields* pAnimInstance = NULL);
200 
202  void draw(SceneState * sceneState, ParaXModelCanvas *c, CParameterBlock* materialParams = NULL);
204  void BuildShadowVolume(SceneState * sceneState, ShadowVolume * pShadowVolume, LightParams* pLight, Matrix4* mxWorld);
205 
206  public:
208  std::vector< CanvasAttachmentPtr > children;
209 
212 
213  // model associated with this attachment
214  asset_ptr<ParaXEntity> model;
215  // static mesh entity, for backward compatibility
216  // asset_ptr<MeshEntity> m_pMeshEntity;
217 
218  // static mesh object
219  ref_ptr<CMeshObject> m_pMeshObject;
220 
221  // a replaceable texture for use with the model on this attachment.
222  asset_ptr<TextureEntity> texReplaceable;
223 
224 
227  int id;
229  int slot;
231  float scale;
232  Vector3 m_vOffset;
236  };
237 
238 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
std::vector< CanvasAttachmentPtr > children
child models
Definition: ParaXModelCanvas.h:208
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
bool Animate(SceneState *sceneState, CharacterPose *pPose, int nAnimID=0, IAttributeFields *pAnimInstance=NULL)
call this to recalculate the bone transform matrices according to the current frame time the caller m...
Definition: ParaXModelCanvas.cpp:74
ShadowVolume is a structure for storing shadow volume geometries.
Definition: ShadowVolume.h:39
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
CanvasAttachment * addAttachment(ParaXEntity *model, int id, int slot, float fScale=1.0f)
add an attachment to the character
Definition: ParaXModelCanvas.cpp:91
void deleteAttachment(int nAttachmentID)
delete all attachments which is attached to the position specified by the attachment ID ...
Definition: ParaXModelCanvas.cpp:115
virtual IAttributeFields * GetChildAttributeObject(const std::string &sName)
get attribute by child object.
Definition: ParaXModelCanvas.cpp:465
void UnmountModel()
unmount the current model.
Definition: ParaXModelCanvas.cpp:41
float scale
this is a model scale which applies to x,y,z axis uniformly.
Definition: ParaXModelCanvas.h:231
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: ParaXModelCanvas.cpp:459
different physics engine has different winding order.
Definition: EventBinding.h:32
int id
this id will be used to index into the parent model&#39;s attachment lookup table to find the actual atta...
Definition: ParaXModelCanvas.h:227
CanvasAttachment * parent
weak reference to parent
Definition: ParaXModelCanvas.h:211
bool m_bIsAutoCharacter
whether the model is a automatic character model, bone matrix calculation for automatic model is give...
Definition: ParaXModelCanvas.h:114
bool InitBaseModel(ParaXEntity *pModel)
reset the model canvas, and initialize with a base model without any attachments. ...
Definition: ParaXModelCanvas.cpp:120
virtual int GetChildAttributeColumnCount()
we support multi-dimensional child object.
Definition: ParaXModelCanvas.cpp:486
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
ref_ptr< CanvasAttachment > m_root
root canvas
Definition: ParaXModelCanvas.h:110
void Draw(SceneState *sceneState, CParameterBlock *materialParams=NULL)
draw the canvas with all models on it.
Definition: ParaXModelCanvas.cpp:85
void SetAutoCharacterModel(bool bAutoCharacterModel)
set this model as automatic character model.
Definition: ParaXModelCanvas.cpp:65
LightParams is a structure for which a shadow volume is built.
Definition: ShadowVolume.h:8
void MountOnModel(ParaXEntity *model, float fScale=1.0f)
mount the current model on another model, such as a horse.
Definition: ParaXModelCanvas.cpp:34
The ref_ptr class template stores a pointer to a dynamically allocated (AssetEntity|CRefCounted|BaseA...
Definition: PERefPtr.h:13
Attachment on parax model canvas.
Definition: ParaXModelCanvas.h:128
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Definition: ParaXEntity.h:9
bool IsMounted()
the base object is mounted on another model
Definition: ParaXModelCanvas.cpp:47
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
virtual int GetChildAttributeObjectCount(int nColumnIndex=0)
get the number of child objects (row count) in the given column.
Definition: ParaXModelCanvas.cpp:479
CanvasAttachment * GetChild(int id, int slot=-1)
get the first attachment matching the id
Definition: ParaXModelCanvas.cpp:110
int slot
the slot ID used to identify the logical position of this attachment
Definition: ParaXModelCanvas.h:229
MeshEntity distinguish one template from other.
Definition: MeshEntity.h:38
the pose of the character.
Definition: ParaXModel.h:381
ParaXEntity * GetBaseModel()
get the base model, where body attachments are attached.Base model is usually the main character mode...
Definition: ParaXModelCanvas.cpp:52
void BuildShadowVolume(SceneState *sceneState, ShadowVolume *pShadowVolume, LightParams *pLight, Matrix4 *mxWorld)
build the shadow volume
Definition: ParaXModelCanvas.cpp:79
ParaXEntity * GetAnimModel()
get the animation model.
Definition: ParaXModelCanvas.cpp:57
void deleteSlot(int slot)
delete everything on a specified slot of the character
Definition: ParaXModelCanvas.cpp:105
void clearAttachments()
delete all attachment to this character.
Definition: ParaXModelCanvas.cpp:100
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108
A ParaX Model canvas is just a hierarchy of parax Models.
Definition: ParaXModelCanvas.h:17