My Project
XRefObject.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
5  class CMeshObject;
6  struct AssetEntity;
7  class CParaXAnimInstance;
8  class CharModelInstance;
9  struct SceneState;
10 
11 
13  class XRefObject
14  {
15  public:
16  XRefObject(CMeshObject* pParent, AssetEntity* pModel, const Vector3& vOrigin, const Matrix4& mxLocalTransform);
17  XRefObject();
18  virtual ~XRefObject(void);
19 
22 
24  AssetEntity* GetModelAsset(){return m_pModelEntity.get();};
25 
27  virtual bool SetParamsFromAsset();
28 
30  virtual void Animate( double dTimeDelta, int nRenderNumber=0 ){};
31 
33  virtual HRESULT Draw( SceneState * sceneState);
34 
35  // it is the same as draw, except that it will use the current transform, instead of applying by the mesh object's position and transform.
36  // @param pMxWorld: if NULL, the current one will be used.
37  virtual HRESULT DrawInner( SceneState * sceneState, const Matrix4* pMxWorld=0, float fCameraToObjectDist=0.f);
38 
48  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity){return true;};
49 
55  Matrix4* GetRenderMatrix(Matrix4& mxWorld, const Matrix4* pMxParent=NULL, int nRenderNumber=0);
56 
64  virtual Matrix4* GetAttachmentMatrix(Matrix4& pOut, int nAttachmentID=0, int nRenderNumber=0){return NULL;};
65 
68  virtual void SetAnimation(int nAnimID){};
69 
71  virtual int GetAnimation(){return 0;};
72 
76  virtual void SetAnimFrame(int nFrame){};
77 
79  virtual int GetAnimFrame(){return 0;};
80 
86  virtual void SetUseGlobalTime(bool bUseGlobalTime){};
87 
93  virtual bool IsUseGlobalTime(){return false;};
94 
97 
99  Matrix4* GetMatrix(Matrix4& mxWorld, const Matrix4* pMatParent);
100 
101 
111 
119  virtual void SetPrimaryTechniqueHandle(int nHandle){m_nTechniqueHandle = nHandle;};
120  protected:
121  // asset entity
122  asset_ptr<AssetEntity> m_pModelEntity;
123 
127 
128 
131 
134 
137  };
138 
140  class XRefMeshObject : public XRefObject
141  {
142  public:
143  XRefMeshObject(CMeshObject* pParent, AssetEntity* pModel, const Vector3& vOrigin, const Matrix4& mxLocalTransform);
144  XRefMeshObject();
145  virtual ~XRefMeshObject(void);
146 
148  virtual bool SetParamsFromAsset();
149 
150  public:
152  virtual HRESULT Draw( SceneState * sceneState);
153  // it is the same as draw, except that it will use the current transform, instead of applying by the mesh object's position and transform.
154  // @param pMxWorld: if NULL, the current one will be used.
155  virtual HRESULT DrawInner( SceneState * sceneState, const Matrix4* pMxWorld=0, float fCameraToObjectDist=0.f);
156 
158  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity);
159  };
160 
168  {
169  public:
170  XRefAnimInstance(CMeshObject* pParent, AssetEntity* pModel, const Vector3& vOrigin, const Matrix4& mxLocalTransform);
171  ~XRefAnimInstance();
172 
174  virtual bool SetParamsFromAsset();
175 
177  CAnimInstanceBase* GetAnimInstance();
178 
182  CParaXAnimInstance* GetParaXAnimInstance();
183 
185  void DeleteAnimInstance();
186 
189  CharModelInstance* GetCharModelInstance();
190 
192  virtual void Animate( double dTimeDelta, int nRenderNumber=0 );
193 
195  virtual HRESULT Draw( SceneState * sceneState);
196 
197  // it is the same as draw, except that it will use the current transform, instead of applying by the mesh object's position and transform.
198  // @param pMxWorld: if NULL, the current one will be used.
199  virtual HRESULT DrawInner( SceneState * sceneState, const Matrix4* pMxWorld=0, float fCameraToObjectDist=0.f);
200 
202  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity);
203 
211  virtual Matrix4* GetAttachmentMatrix(Matrix4& pOut, int nAttachmentID=0, int nRenderNumber=0);
212 
215  virtual void SetAnimation(int nAnimID);
216 
218  virtual int GetAnimation();
219 
223  virtual void SetAnimFrame(int nFrame);
224 
226  virtual int GetAnimFrame();
227 
233  virtual void SetUseGlobalTime(bool bUseGlobalTime);
234 
240  virtual bool IsUseGlobalTime();
241  private:
244  };
245 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
abstract class for all animation instance implementation.
Definition: AnimInstanceBase.h:66
CMeshObject * GetParent()
Get the parent object associated with this object.
Definition: XRefObject.h:21
int m_nTechniqueHandle
the primary technique handle
Definition: XRefObject.h:133
virtual void SetAnimFrame(int nFrame)
set the current animation frame number relative to the beginning of current animation.
Definition: XRefObject.h:76
base class for all xref objects
Definition: XRefObject.h:13
different physics engine has different winding order.
Definition: EventBinding.h:32
Matrix4 & GetLocalMatrix()
get local matrix
Definition: XRefObject.h:96
character animation instance: it includes both the animation and model display information.
Definition: CustomCharModelInstance.h:17
virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity *pTextureEntity)
set the replaceable texture at the given index with a new texture.
Definition: XRefObject.h:48
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
virtual Matrix4 * GetAttachmentMatrix(Matrix4 &pOut, int nAttachmentID=0, int nRenderNumber=0)
Get the specified attachment matrix of the current model.
Definition: XRefObject.h:64
static mesh scene object.
Definition: MeshObject.h:13
animated animation instance referenced in model object.
Definition: XRefObject.h:167
CMeshObject * m_pParent
parent object
Definition: XRefObject.h:136
Matrix4 * GetMatrix(Matrix4 &mxWorld, const Matrix4 *pMatParent)
get matrix relative to a parent matrix
Definition: XRefObject.cpp:86
AssetEntity * GetModelAsset()
return the model asset associated with this object
Definition: XRefObject.h:24
Matrix4 m_mxLocalTransform
animated local transform: this is usually a const read from the model file
Definition: XRefObject.h:130
virtual int GetAnimation()
get the scaling.
Definition: XRefObject.h:71
virtual bool SetParamsFromAsset()
return true if asset effect type is known.
Definition: XRefObject.cpp:43
virtual void Animate(double dTimeDelta, int nRenderNumber=0)
animate the model
Definition: XRefObject.h:30
Matrix4 * GetRenderMatrix(Matrix4 &mxWorld, const Matrix4 *pMxParent=NULL, int nRenderNumber=0)
get matrix for rendering
Definition: XRefObject.cpp:59
virtual HRESULT Draw(SceneState *sceneState)
draw the model
Definition: XRefObject.cpp:49
virtual bool IsUseGlobalTime()
whether to use global time to sync animation.
Definition: XRefObject.h:93
The ref_ptr class template stores a pointer to a dynamically allocated (AssetEntity|CRefCounted|BaseA...
Definition: PERefPtr.h:13
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
virtual int GetPrimaryTechniqueHandle()
when batch-rendering a group of objects, objects are usually sorted by their render techniques and th...
Definition: XRefObject.h:110
virtual int GetAnimFrame()
get the current animation frame number relative to the beginning of current animation.
Definition: XRefObject.h:79
virtual void SetUseGlobalTime(bool bUseGlobalTime)
whether to use global time to sync animation.
Definition: XRefObject.h:86
virtual void SetPrimaryTechniqueHandle(int nHandle)
Set a new render technique handle.
Definition: XRefObject.h:119
Vector3 m_vOrigin
the xrefed model&#39;s origin relative to its parent model.
Definition: XRefObject.h:126
mesh instance referenced in model object.
Definition: XRefObject.h:140
virtual void SetAnimation(int nAnimID)
Set the current animation id.
Definition: XRefObject.h:68
this is primary animation instance used for normal animated character or advanced customizable charac...
Definition: ParaXAnimInstance.h:13
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25