My Project
MeshObject.h
1 #pragma once
2 #include "TileObject.h"
3 
4 
5 namespace ParaEngine
6 {
7  class CViewCullingObject;
13  class CMeshObject : public CTileObject
14  {
15  public:
16  virtual CBaseObject::_SceneObjectType GetType(){return CBaseObject::MeshObject;};
17  CMeshObject(void);
18  virtual ~CMeshObject(void);
19 
20  virtual void SetPosition(const DVector3 & v);
21 
29  virtual void Rotate(float x, float y, float z);
30 
33  virtual void SetScaling(float s);
35  virtual float GetScaling();
36 
38  virtual void Reset();
39 
41  virtual void SetRotation(const Quaternion& quat);
43  virtual void GetRotation(Quaternion* quat);
44 
47  virtual void SetAnimation(int nAnimID);
48 
50  virtual int GetAnimation();
51 
55  virtual void SetAnimFrame(int nFrame);
56 
58  virtual int GetAnimFrame();
59 
63  virtual bool ViewTouch();
64 
70  virtual void SetUseGlobalTime(bool bUseGlobalTime);
71 
77  virtual bool IsUseGlobalTime();
78 
82  virtual bool IsPersistent();
83 
87  virtual void SetPersistent(bool bPersistent);
88 
89  public:
90 
92  // implementation of IAttributeFields
93 
95  virtual int GetAttributeClassID(){return ATTRIBUTE_CLASSID_CMeshObject;}
97  virtual const char* GetAttributeClassName(){static const char name[] = "CMeshObject"; return name;}
99  virtual const char* GetAttributeClassDescription(){static const char desc[] = ""; return desc;}
101  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
102  ATTRIBUTE_SUPPORT_CREATE_FACTORY(CMeshObject);
103  ATTRIBUTE_METHOD1(CMeshObject, IsFaceCullingDisabled_s, bool*) {*p1 = cls->IsFaceCullingDisabled(); return S_OK;}
104  ATTRIBUTE_METHOD1(CMeshObject, SetFaceCullingDisabled_s, bool) {cls->SetFaceCullingDisabled(p1); return S_OK;}
105  public:
106  // -- for init and delete
107  HRESULT InitObject(MeshEntity* ppMesh, TextureEntity* ppTexture, Vector3 vPos);
108  virtual HRESULT InitDeviceObjects();
109  HRESULT RestoreDeviceObjects();
110  HRESULT InvalidateDeviceObjects();
111  virtual void Cleanup();
112 
113  // animate the object
114  virtual void Animate( double dTimeDelta, int nRenderNumber=0 );
115 
116  // -- for rendering
117  virtual HRESULT Draw( SceneState * sceneState);
118 
123  HRESULT DrawInner( SceneState * sceneState, const Matrix4* pMxWorld=0, float fCameraToObjectDist=0.f, CParameterBlock* materialParams = NULL);
124 
131  virtual Matrix4* GetRenderMatrix( Matrix4& out, int nRenderNumber=0);
132 
140  virtual Matrix4* GetAttachmentMatrix(Matrix4& pOut, int nAttachmentID=0, int nRenderNumber=0);
141 
142  virtual AssetEntity* GetPrimaryAsset(){return (AssetEntity*)m_ppMesh.get();}; // used as KEY for batch rendering
143 
144  virtual float GetCtorPercentage();
145  virtual void SetCtorPercentage(float fPercentage);
146 
150  virtual bool HasAlphaBlendedObjects();
151 
157  virtual bool IsTransparent(){return m_bIsTransparent;};
158 
163  virtual void SetTransparent(bool bIsTransparent){m_bIsTransparent = bIsTransparent;};
164 
166  virtual void SetLocalTransform(const Matrix4& mXForm);
168  virtual void GetLocalTransform(Matrix4* localTransform);
169 
171  void SetLocalTransform(float fScale, float fRotX, float fRotY, float fRotZ);
173  void SetLocalTransform(float fScale, const Quaternion& quat);
175  void GetLocalTransform(float* fScale, Quaternion* quat);
176 
178 
183  void ForceNoLight(bool bNoLight);
187  bool IsNoLight();
188 
197  virtual int GetNumReplaceableTextures();
198 
207  virtual TextureEntity* GetDefaultReplaceableTexture(int ReplaceableTextureID);
208 
217  virtual TextureEntity* GetReplaceableTexture(int ReplaceableTextureID);
218 
228  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity);
229 
231  void SearchXRefObject();
232 
234  int GetXRefInstanceCount();
235 
237  XRefObject* GetXRefInstanceByIndex(int nIndex);
238 
240  void CleanupXRefInstances();
241 
243  //int GetXRefMeshCount();
244 
246  //XRefObject* GetXRefMeshByIndex(int nIndex);
247 
249  //void CleanupXRefMesh();
250 
251 
253  int GetXRefScriptCount();
254 
256  const char* GetXRefScript(int nIndex);
257 
261  Vector3 GetXRefScriptPosition(int nIndex);
262 
266  Vector3 GetXRefScriptScaling(int nIndex);
267 
271  float GetXRefScriptFacing(int nIndex);
272 
278  const char* GetXRefScriptLocalMatrix(int nIndex);
279 
280 
282  void SetFaceCullingDisabled(bool bDisableFaceCulling);
283 
285  bool IsFaceCullingDisabled();
286  private:
287 
289  bool SetParamsFromAsset();
290 
291  protected:
292  CViewCullingObject* m_pViewClippingObject;
293 
296 
298  asset_ptr<MeshEntity> m_ppMesh;
299  vector< asset_ptr<TextureEntity> > m_ReplaceableTextures;
300 
302  vector<XRefObject*> m_XRefObjects;
303 
305  asset_ptr<TextureEntity> m_ppTexture;
306 
309 
312 
315 
318 
322 
325 
328 
331 
334 
339 
340  friend class CMeshPhysicsObject;
341  friend class CSkyMesh;
342  };
343 }
virtual float GetCtorPercentage()
Get the object construction percentage (progress) in the range[0,1].
Definition: MeshObject.cpp:81
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
bool m_XRefSearched
whether we have searched the XRef object, we will use late evaluation and only load XRef when they ar...
Definition: MeshObject.h:333
bool m_bViewClippingUpdated
whether view clipping object should be updated.
Definition: MeshObject.h:330
Vector3 GetXRefScriptPosition(int nIndex)
get the 3D position in world space of the script object&#39;s origin
Definition: MeshObject.cpp:1033
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: MeshObject.h:97
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
const char * GetXRefScriptLocalMatrix(int nIndex)
get the local transform of the script object.
Definition: MeshObject.cpp:1158
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
const char * GetXRefScript(int nIndex)
return xref script file path by index
Definition: MeshObject.cpp:1008
It is used for object-level view culling.
Definition: ViewCullingObject.h:16
int GetXRefInstanceCount()
get the number of the animation X reference instances
Definition: MeshObject.cpp:976
void SetFaceCullingDisabled(bool bDisableFaceCulling)
whether we will turn off any material level face culling setting.
Definition: MeshObject.cpp:1297
Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection...
Definition: IViewClippingObject.h:29
virtual TextureEntity * GetDefaultReplaceableTexture(int ReplaceableTextureID)
get the default replaceable texture by its ID.
Definition: MeshObject.cpp:1208
base class for all xref objects
Definition: XRefObject.h:13
float m_fCtorPercentage
construction progress of the mesh
Definition: MeshObject.h:308
virtual float GetScaling()
get scaling
Definition: MeshObject.cpp:390
virtual void Animate(double dTimeDelta, int nRenderNumber=0)
animate the model by a given delta time.
Definition: MeshObject.cpp:1254
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual IViewClippingObject * GetViewClippingObject()
return the view clipping object used for object-level clipping when rendering this object...
Definition: MeshObject.cpp:276
bool m_bIsTransparent
whether the object contains transparent material.
Definition: MeshObject.h:321
virtual void SetAnimation(int nAnimID)
Set the current animation id.
Definition: MeshObject.cpp:909
virtual void Cleanup()
clean up the object.
Definition: MeshObject.cpp:271
void SearchXRefObject()
search the associated mesh entity for any XReference object
Definition: MeshObject.cpp:850
virtual bool IsUseGlobalTime()
whether to use global time to sync animation.
Definition: MeshObject.cpp:970
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: MeshObject.h:99
Implementation of a Quaternion, i.e.
Definition: ParaQuaternion.h:10
virtual void GetRotation(Quaternion *quat)
get rotation using a quaternion
Definition: MeshObject.cpp:355
the sky object in the scene.
Definition: SkyMesh.h:13
virtual void SetRotation(const Quaternion &quat)
set rotation using a quaternion.
Definition: MeshObject.cpp:342
void CleanupXRefInstances()
remove and clean up all anim xref references
Definition: MeshObject.cpp:70
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
HRESULT InitObject(MeshEntity *ppMesh, TextureEntity *ppTexture, Vector3 vPos)
Desc: It saves device references, but do not initialize those devices.
Definition: MeshObject.cpp:99
virtual void SetScaling(float s)
set the scale of the object.
Definition: MeshObject.cpp:378
asset_ptr< TextureEntity > m_ppTexture
texture
Definition: MeshObject.h:305
float GetXRefScriptFacing(int nIndex)
get the facing of the object in xz plane
Definition: MeshObject.cpp:1107
static mesh scene object.
Definition: MeshObject.h:13
bool m_bIsPersistent
whether it is persistent in the world.
Definition: MeshObject.h:338
int m_nAnimFrame
animation frame for xref animated object.
Definition: MeshObject.h:314
virtual void SetTransparent(bool bIsTransparent)
Set whether the object is transparent.
Definition: MeshObject.h:163
virtual Matrix4 * GetRenderMatrix(Matrix4 &out, int nRenderNumber=0)
return the world matrix of the object for rendering
Definition: MeshObject.cpp:406
asset_ptr< MeshEntity > m_ppMesh
mesh geometry
Definition: MeshObject.h:298
virtual int GetAnimFrame()
get the current animation frame number relative to the beginning of current animation.
Definition: MeshObject.cpp:946
Matrix4 m_mxLocalTransform
mesh local world xform: center in the origin
Definition: MeshObject.h:295
void ForceNoLight(bool bNoLight)
whether force rendering without local or global lighting effect.
Definition: MeshObject.cpp:840
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
virtual bool IsPersistent()
whether the object is persistent in the world.
Definition: MeshObject.cpp:1287
virtual int GetAnimation()
get the scaling.
Definition: MeshObject.cpp:922
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: MeshObject.h:95
HRESULT DrawInner(SceneState *sceneState, const Matrix4 *pMxWorld=0, float fCameraToObjectDist=0.f, CParameterBlock *materialParams=NULL)
it is the same as draw, except that it will use the current transform, instead of applying by the mes...
Definition: MeshObject.cpp:441
virtual void SetUseGlobalTime(bool bUseGlobalTime)
whether to use global time to sync animation.
Definition: MeshObject.cpp:958
vector< XRefObject * > m_XRefObjects
xref animation instances in the model.
Definition: MeshObject.h:302
A static mesh based physical object in the scene please note that it keeps the static mesh object as ...
Definition: MeshPhysicsObject.h:16
MeshEntity distinguish one template from other.
Definition: MeshEntity.h:38
virtual bool ViewTouch()
this function is called, when the object is in view range.
Definition: MeshObject.cpp:1271
bool m_bUseGlobalTime
whether to use global time for all animation.
Definition: MeshObject.h:317
int m_nAnimID
animation id for xref animated object.
Definition: MeshObject.h:311
Tile Object have position and bounding rect and can usually be attached to quad-tree terrain tile...
Definition: TileObject.h:10
int GetXRefScriptCount()
get the number of the script X reference instances
Definition: MeshObject.cpp:987
virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity *pTextureEntity)
set the replaceable texture at the given index with a new texture.
Definition: MeshObject.cpp:1242
virtual HRESULT Draw(SceneState *sceneState)
Desc: Render this instance using the current settings.
Definition: MeshObject.cpp:772
virtual TextureEntity * GetReplaceableTexture(int ReplaceableTextureID)
get the current replaceable texture by its ID.
Definition: MeshObject.cpp:1219
virtual Matrix4 * GetAttachmentMatrix(Matrix4 &pOut, int nAttachmentID=0, int nRenderNumber=0)
Get the specified attachment matrix of the current model.
Definition: MeshObject.cpp:891
virtual int GetNumReplaceableTextures()
get the total number of replaceable textures, which is the largest replaceable texture ID...
Definition: MeshObject.cpp:1197
virtual void Rotate(float x, float y, float z)
Rotate the object.This only takes effects on objects having 3D orientation, such as static mesh and p...
Definition: MeshObject.cpp:363
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: MeshObject.cpp:1307
virtual void SetLocalTransform(const Matrix4 &mXForm)
set local transform directly
Definition: MeshObject.cpp:302
bool m_bForceNoLight
force rendering without local or global lighting effect.
Definition: MeshObject.h:324
virtual void SetPosition(const DVector3 &v)
always bottom center of the bounding shape
Definition: MeshObject.cpp:1149
virtual AssetEntity * GetPrimaryAsset()
Set scaling.
Definition: MeshObject.h:142
virtual void SetPersistent(bool bPersistent)
whenever a persistent object is made non-persistent, the SaveToDB() function will actually removed it...
Definition: MeshObject.cpp:1292
virtual bool IsTransparent()
whether the object contains transparent material.
Definition: MeshObject.h:157
virtual void SetCtorPercentage(float fPercentage)
Set the object construction percentage (progress) in the range[0,1].
Definition: MeshObject.cpp:86
virtual bool HasAlphaBlendedObjects()
return true if the object contains alpha blended render pass.
Definition: MeshObject.cpp:1316
bool IsFaceCullingDisabled()
whether we will turn off any material level face culling setting.
Definition: MeshObject.cpp:1302
virtual void GetLocalTransform(Matrix4 *localTransform)
get local transform
Definition: MeshObject.cpp:326
Vector3 GetXRefScriptScaling(int nIndex)
get the scaling of the object in both x,y,z directions
Definition: MeshObject.cpp:1066
virtual void Reset()
reset the object to its default settings.
Definition: MeshObject.cpp:400
bool IsNoLight()
Definition: MeshObject.cpp:845
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
bool m_bDisableFaceCulling
if true, we will disable facing culling when rendering the object.
Definition: MeshObject.h:327
virtual void SetAnimFrame(int nFrame)
set the current animation frame number relative to the beginning of current animation.
Definition: MeshObject.cpp:934
XRefObject * GetXRefInstanceByIndex(int nIndex)
return animation xref instance by index
Definition: MeshObject.cpp:982
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108