My Project
MeshPhysicsObject.h
1 #pragma once
2 #include "TileObject.h"
3 
4 namespace ParaEngine
5 {
6  class CMeshObject;
7  struct IParaPhysicsActor;
8  class CPhysicsWorld;
9  struct MeshEntity;
10 
17  {
18  public:
19  virtual CBaseObject::_SceneObjectType GetType(){ return CBaseObject::MeshPhysicsObject; };
20  virtual std::string ToString(DWORD nMethod);
21  CMeshPhysicsObject(void);
22  virtual ~CMeshPhysicsObject(void);
23 
24  private:
26  void CreateMeshObject();
27 
28  void SetParamsFromAsset();
29 
31  vector<IParaPhysicsActor*> m_staticActors;
32 
36  bool m_bIsPersistent;
37 
38  public:
39 
41  // implementation of IAttributeFields
42 
44  virtual int GetAttributeClassID(){ return ATTRIBUTE_CLASSID_CMeshPhysicsObject; }
46  virtual const char* GetAttributeClassName(){ static const char name[] = "CMeshPhysicsObject"; return name; }
48  virtual const char* GetAttributeClassDescription(){ static const char desc[] = ""; return desc; }
50  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
51 
52  ATTRIBUTE_SUPPORT_CREATE_FACTORY(CMeshPhysicsObject);
53  ATTRIBUTE_METHOD1(CMeshPhysicsObject, IsFaceCullingDisabled_s, bool*) { *p1 = cls->IsFaceCullingDisabled(); return S_OK; }
54  ATTRIBUTE_METHOD1(CMeshPhysicsObject, SetFaceCullingDisabled_s, bool) { cls->SetFaceCullingDisabled(p1); return S_OK; }
55 
56  public:
58  void SetFaceCullingDisabled(bool bDisableFaceCulling);
59 
61  bool IsFaceCullingDisabled();
62 
69  virtual void SetPhysicsGroup(int nGroup);
76  virtual int GetPhysicsGroup();
77 
79  int GetStaticActorCount();
80 
82  virtual bool CanHasPhysics();
83 
95  HRESULT InitObject(MeshEntity* ppMesh, float fOBB_X, float fOBB_Y, float fOBB_Z, bool bApplyPhysics, const Matrix4& localTransform);
96 
98  virtual void Cleanup();
99 
107  virtual void Rotate(float x, float y, float z);
108 
110  virtual void SetRotation(const Quaternion& quat);
112  virtual void GetRotation(Quaternion* quat);
113 
116  virtual void SetScaling(float s);
118  virtual float GetScaling();
119 
121  virtual void Reset();
122 
125  virtual void SetAnimation(int nAnimID);
126 
128  virtual int GetAnimation();
129 
133  virtual void SetAnimFrame(int nFrame);
134 
136  virtual int GetAnimFrame();
137 
143  virtual void SetUseGlobalTime(bool bUseGlobalTime);
144 
150  virtual bool IsUseGlobalTime();
151 
157  virtual void SetLocalTransform(const Matrix4& mXForm);
158  virtual void GetLocalTransform(Matrix4* localTransform);
159 
160  virtual void SetBoundingBox(float fOBB_X, float fOBB_Y, float fOBB_Z, float fFacing);
161  virtual void SetBoundRect(FLOAT fWidth, FLOAT fHeight, FLOAT fFacing);
162  virtual void SetRadius(FLOAT fRadius);
163 
164  virtual Matrix4* GetRenderMatrix(Matrix4& out, int nRenderNumber = 0);
165 
172  virtual Matrix4* GetAttachmentMatrix(Matrix4& pOut, int nAttachmentID = 0, int nRenderNumber = 0);
173 
177  virtual bool HasAttachmentPoint(int nAttachmentID = 0);
178 
182  virtual bool IsPersistent();
186  virtual void SetPersistent(bool bPersistent);
187 
205  virtual void LoadPhysics();
209  virtual void UnloadPhysics();
210 
214  virtual void SetAlwaysLoadPhysics(bool bEnable);
215 
219  virtual bool ViewTouch();
220 
222  virtual void EnablePhysics(bool bEnable);
223  virtual bool IsPhysicsEnabled();
224 
226  virtual void CompressObject(CompressOption option = (CompressOption)0xffff);
227  virtual void SetPosition(const DVector3 & v);
228  virtual void SetYaw(float fFacing);
229 
230  // animate the object
231  virtual void Animate(double dTimeDelta, int nRenderNumber = 0);
232  virtual HRESULT Draw(SceneState * sceneState);
233  // used as KEY for batch rendering
234  virtual AssetEntity* GetPrimaryAsset();
236  virtual int GetPrimaryTechniqueHandle();
237  virtual void SetPrimaryTechniqueHandle(int nHandle);
241  virtual CParameterBlock* GetEffectParamBlock(bool bCreateIfNotExist = false);
242 
243  virtual float GetCtorPercentage();
244  virtual void SetCtorPercentage(float fPercentage);
245  virtual void AutoSelectTechnique();
246 
248  virtual void SetOnAssetLoaded(const char* sCallbackScript);
249 
254  virtual void OnSelect(int nGroupID);
256  virtual void OnDeSelect();
257 
263  virtual bool IsTransparent();
264 
269  virtual void SetTransparent(bool bIsTransparent);
270 
271 
275  virtual bool HasAlphaBlendedObjects();
276 
285  virtual int GetNumReplaceableTextures();
286 
295  virtual TextureEntity* GetDefaultReplaceableTexture(int ReplaceableTextureID);
296 
305  virtual TextureEntity* GetReplaceableTexture(int ReplaceableTextureID);
306 
316  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity);
317 
318  protected:
319  // any bit wise combination of PHYSICS_METHOD
320  DWORD m_dwPhysicsMethod;
321 
322  unsigned int m_nPhysicsGroup;
324  union{
325  CMeshObject * m_pMeshObject;
326  };
327 
328  };
329 }
virtual Matrix4 * GetAttachmentMatrix(Matrix4 &pOut, int nAttachmentID=0, int nRenderNumber=0)
Get the specified attachment matrix of the current model.
Definition: MeshPhysicsObject.cpp:724
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
virtual void OnDeSelect()
called whenever an object is un-selected.
Definition: MeshPhysicsObject.cpp:710
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
virtual void GetLocalTransform(Matrix4 *localTransform)
get local transform
Definition: MeshPhysicsObject.cpp:333
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
virtual TextureEntity * GetDefaultReplaceableTexture(int ReplaceableTextureID)
get the default replaceable texture by its ID.
Definition: MeshPhysicsObject.cpp:658
virtual void SetBoundRect(FLOAT fWidth, FLOAT fHeight, FLOAT fFacing)
Set the object shape to rect (a plane) and rect parameters if fFacing is 0, it is a axis aligned boun...
Definition: MeshPhysicsObject.cpp:809
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
virtual void Reset()
reset the object to its default settings.
Definition: MeshPhysicsObject.cpp:394
virtual void SetTransparent(bool bIsTransparent)
Set whether the object is transparent.
Definition: MeshPhysicsObject.cpp:642
virtual void Animate(double dTimeDelta, int nRenderNumber=0)
animate the model by a given delta time.
Definition: MeshPhysicsObject.cpp:518
virtual void SetRotation(const Quaternion &quat)
set rotation using a quaternion.
Definition: MeshPhysicsObject.cpp:341
virtual void SetCtorPercentage(float fPercentage)
Set the object construction percentage (progress) in the range[0,1].
Definition: MeshPhysicsObject.cpp:618
virtual int GetAnimation()
get the scaling.
Definition: MeshPhysicsObject.cpp:744
Pure interface for CBaseObject (3D scene object) It defines basic shapes and collision detection...
Definition: IViewClippingObject.h:29
virtual void AutoSelectTechnique()
automatically select the proper technique for the rendering of the object.
Definition: MeshPhysicsObject.cpp:682
virtual void SetAnimation(int nAnimID)
Set the current animation id.
Definition: MeshPhysicsObject.cpp:738
virtual void SetLocalTransform(const Matrix4 &mXForm)
update the local transform of the mesh object.
Definition: MeshPhysicsObject.cpp:325
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: MeshPhysicsObject.h:48
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual void SetOnAssetLoaded(const char *sCallbackScript)
set the callback scipt whenever the primary asset is successfully loaded.
Definition: MeshPhysicsObject.cpp:248
virtual int GetNumReplaceableTextures()
get the total number of replaceable textures, which is the largest replaceable texture ID...
Definition: MeshPhysicsObject.cpp:650
virtual bool IsTransparent()
whether the object contains transparent material.
Definition: MeshPhysicsObject.cpp:634
virtual TextureEntity * GetReplaceableTexture(int ReplaceableTextureID)
get the current replaceable texture by its ID.
Definition: MeshPhysicsObject.cpp:666
Implementation of a Quaternion, i.e.
Definition: ParaQuaternion.h:10
virtual void SetScaling(float s)
set the scale of the object.
Definition: MeshPhysicsObject.cpp:372
int GetStaticActorCount()
get the number of physics actors.
Definition: MeshPhysicsObject.cpp:782
virtual int GetAnimFrame()
get the current animation frame number relative to the beginning of current animation.
Definition: MeshPhysicsObject.cpp:757
virtual void Cleanup()
clean up
Definition: MeshPhysicsObject.cpp:215
virtual CParameterBlock * GetEffectParamBlock(bool bCreateIfNotExist=false)
get effect parameter block with this object.
Definition: MeshPhysicsObject.cpp:717
virtual bool CanHasPhysics()
if the object may contain physics
Definition: MeshPhysicsObject.cpp:787
static mesh scene object.
Definition: MeshObject.h:13
void SetFaceCullingDisabled(bool bDisableFaceCulling)
whether we will turn off any material level face culling setting.
Definition: MeshPhysicsObject.cpp:863
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: MeshPhysicsObject.h:46
virtual void CompressObject(CompressOption option=(CompressOption) 0xffff)
unload physics.
Definition: MeshPhysicsObject.cpp:483
virtual float GetCtorPercentage()
Get the object construction percentage (progress) in the range[0,1].
Definition: MeshPhysicsObject.cpp:611
CMeshPhysicsObject(void)
Definition: MeshPhysicsObject.cpp:203
virtual bool HasAttachmentPoint(int nAttachmentID=0)
whether it has an attachment point
Definition: MeshPhysicsObject.cpp:731
virtual std::string ToString(DWORD nMethod)
convert the object to an NPL string by which this object may be created or deleted.
Definition: MeshPhysicsObject.cpp:32
virtual void SetAlwaysLoadPhysics(bool bEnable)
by default physics is lazy-load when player walk into its bounding box, setting this to false will al...
Definition: MeshPhysicsObject.cpp:823
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: MeshPhysicsObject.cpp:877
virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity *pTextureEntity)
set the replaceable texture at the given index with a new texture.
Definition: MeshPhysicsObject.cpp:674
virtual IViewClippingObject * GetViewClippingObject()
return the view clipping object used for object-level clipping when rendering this object...
Definition: MeshPhysicsObject.cpp:508
virtual void GetRotation(Quaternion *quat)
get rotation using a quaternion
Definition: MeshPhysicsObject.cpp:349
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
virtual void OnSelect(int nGroupID)
called when an object is selected.
Definition: MeshPhysicsObject.cpp:703
CMeshObject * GetMeshObject()
get the mesh object associated with the object
Definition: MeshPhysicsObject.cpp:321
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 HRESULT Draw(SceneState *sceneState)
only for drawable objects
Definition: MeshPhysicsObject.cpp:526
virtual bool HasAlphaBlendedObjects()
return true if the object contains alpha blended render pass.
Definition: MeshPhysicsObject.cpp:626
Tile Object have position and bounding rect and can usually be attached to quad-tree terrain tile...
Definition: TileObject.h:10
virtual void SetBoundingBox(float fOBB_X, float fOBB_Y, float fOBB_Z, float fFacing)
Set the object shape to box and bounding box parameters if fFacing is 0, it is a axis aligned boundin...
Definition: MeshPhysicsObject.cpp:802
virtual int GetPhysicsGroup()
Get the physics group ID to which this object belongs to default to 0, must be smaller than 32...
Definition: MeshPhysicsObject.cpp:777
virtual void SetPhysicsGroup(int nGroup)
set the physics group ID to which this object belongs to default to 0, must be smaller than 32...
Definition: MeshPhysicsObject.cpp:792
virtual void SetPrimaryTechniqueHandle(int nHandle)
Set a new render technique handle.
Definition: MeshPhysicsObject.cpp:604
virtual bool ViewTouch()
this function is called, when the object is in view range.
Definition: MeshPhysicsObject.cpp:835
virtual Matrix4 * GetRenderMatrix(Matrix4 &out, int nRenderNumber=0)
return the world matrix of the object for rendering
Definition: MeshPhysicsObject.cpp:559
virtual void SetRadius(FLOAT fRadius)
Set the object shape to Sphere and sphere parameters.
Definition: MeshPhysicsObject.cpp:816
virtual void SetPosition(const DVector3 &v)
always bottom center of the bounding shape
Definition: MeshPhysicsObject.cpp:499
HRESULT InitObject(MeshEntity *ppMesh, float fOBB_X, float fOBB_Y, float fOBB_Z, bool bApplyPhysics, const Matrix4 &localTransform)
mesh asset file name ending with _a or _b (such as "tree_b.x" )will be forced no physics initially...
Definition: MeshPhysicsObject.cpp:226
virtual void UnloadPhysics()
load the physics object
Definition: MeshPhysicsObject.cpp:470
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: MeshPhysicsObject.cpp:357
bool IsFaceCullingDisabled()
whether we will turn off any material level face culling setting.
Definition: MeshPhysicsObject.cpp:869
virtual void SetPersistent(bool bPersistent)
whenever a persistent object is made non-persistent, the SaveToDB() function will actually removed it...
Definition: MeshPhysicsObject.cpp:858
virtual AssetEntity * GetPrimaryAsset()
Set scaling.
Definition: MeshPhysicsObject.cpp:570
virtual float GetScaling()
get the size scale
Definition: MeshPhysicsObject.cpp:384
virtual void SetAnimFrame(int nFrame)
set the current animation frame number relative to the beginning of current animation.
Definition: MeshPhysicsObject.cpp:751
virtual void LoadPhysics()
load the physics objects.
Definition: MeshPhysicsObject.cpp:400
virtual bool IsUseGlobalTime()
whether to use global time to sync animation.
Definition: MeshPhysicsObject.cpp:770
virtual int GetPrimaryTechniqueHandle()
when batch-rendering a group of objects, objects are usually sorted by their render techniques and th...
Definition: MeshPhysicsObject.cpp:596
virtual void SetUseGlobalTime(bool bUseGlobalTime)
whether to use global time to sync animation.
Definition: MeshPhysicsObject.cpp:764
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: MeshPhysicsObject.h:44
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
virtual bool IsPersistent()
whether the object is persistent in the world.
Definition: MeshPhysicsObject.cpp:853
virtual void EnablePhysics(bool bEnable)
this function will turn on or off the physics of the object.
Definition: MeshPhysicsObject.cpp:577
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108