My Project
PhysicsWorld.h
1 #pragma once
2 #include "IParaPhysics.h"
3 #include <list>
4 
6 // #define INVERT_PHYSICS_FACE_WINDING
7 
8 namespace ParaEngine
9 {
10  struct MeshEntity;
11  struct ParaXEntity;
12 
19  {
20  public:
21  class TriangleMeshShape;
22  typedef std::list<TriangleMeshShape*> TriangleMeshShape_Map_Type;
23 
25  {
26  public:
27  SubMeshPhysicsShape():m_nPhysicsGroup(0), m_pShape(NULL){};
28  SubMeshPhysicsShape(IParaPhysicsShape* pShape, int nPhysicsGroup=0):m_nPhysicsGroup(nPhysicsGroup), m_pShape(pShape){};
29  IParaPhysicsShape* m_pShape;
30  int m_nPhysicsGroup;
31  };
38  {
39  public:
40  union {
41  MeshEntity* m_pMeshEntity;
43  };
44 
45  Vector3 m_vScale;
46  std::vector<SubMeshPhysicsShape> m_pShapes;
47 
48  TriangleMeshShape ():m_pMeshEntity(NULL), m_vScale (1.f,1.f,1.f){}
49  };
50 
51  public:
52  CPhysicsWorld(void);
53  virtual ~CPhysicsWorld(void);
54 
55  ATTRIBUTE_DEFINE_CLASS(CPhysicsWorld);
56 
60  void InitPhysics();
61 
67  void ExitPhysics();
68 
70  void ResetPhysics();
71 
74  void StepSimulation(double dTime);
75 
89  IParaPhysicsActor* CreateStaticMesh(MeshEntity* ppMesh, const Matrix4& globalMat, uint32 nShapeGroup = 0, vector<IParaPhysicsActor*>* pOutputPhysicsActor = NULL, void* pUserData=NULL);
90  IParaPhysicsActor* CreateStaticMesh(ParaXEntity* ppMesh, const Matrix4& globalMat, uint32 nShapeGroup = 0, vector<IParaPhysicsActor*>* pOutputPhysicsActor = NULL, void* pUserData = NULL);
91 
93  void ReleaseActor(IParaPhysicsActor* pActor);
94 
97  void SetDynamicsSimulationEnabled(bool bEnable);
98  bool IsDynamicsSimulationEnabled();
99 
100  public:
103 
104  public:
107 
109  TriangleMeshShape_Map_Type m_listMeshShapes;
110 
113  };
114 }
std::vector< SubMeshPhysicsShape > m_pShapes
the scaling factor
Definition: PhysicsWorld.h:46
void ReleaseActor(IParaPhysicsActor *pActor)
release an actor by calling this function.
Definition: PhysicsWorld.cpp:426
different physics engine has different winding order.
Definition: EventBinding.h:32
ParaXEntity * m_pParaXEntity
the mesh entity
Definition: PhysicsWorld.h:42
void InitPhysics()
Init the physics scene.
Definition: PhysicsWorld.cpp:70
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
IParaPhysics * GetPhysicsInterface()
get the physics interface.
Definition: PhysicsWorld.cpp:443
it is represent a shape that can be used to create various actors in the scene.
Definition: IParaPhysics.h:42
TriangleMeshShape_Map_Type m_listMeshShapes
all shapes used to composed the physical world. There may be multiple object using the same shape ...
Definition: PhysicsWorld.h:109
IParaPhysics * m_pPhysicsWorld
the main physic interface.
Definition: PhysicsWorld.h:106
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Definition: ParaXEntity.h:9
void SetDynamicsSimulationEnabled(bool bEnable)
whether to do dynamic simulation.
Definition: PhysicsWorld.cpp:484
ParaPhysics core interface.
Definition: IParaPhysics.h:100
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
bool m_bRunDynamicSimulation
whether to do dynamic simulation. It is turned off by default, which only provide basic collision det...
Definition: PhysicsWorld.h:112
IParaPhysicsActor * CreateStaticMesh(MeshEntity *ppMesh, const Matrix4 &globalMat, uint32 nShapeGroup=0, vector< IParaPhysicsActor *> *pOutputPhysicsActor=NULL, void *pUserData=NULL)
create a static actor in the physical world from a mesh entity.
Definition: PhysicsWorld.cpp:122
it is represent a shape that can be used to create various actors in the scene.
Definition: IParaPhysics.h:79
MeshEntity distinguish one template from other.
Definition: MeshEntity.h:38
void StepSimulation(double dTime)
Start the physics for some time advances dTime: advances in seconds.
Definition: PhysicsWorld.cpp:106
The global physics scene (NxScene) and physics SDK is encapsulated in a member object of scene manage...
Definition: PhysicsWorld.h:18
void ResetPhysics()
First call ExitPhysics(), then InitPhysics()
Definition: PhysicsWorld.cpp:100
void ExitPhysics()
ExitPhysics() calls NxPhysicsSDK::releaseScene() which deletes all the objects in the scene and then ...
Definition: PhysicsWorld.cpp:83
the triangle mesh shape.
Definition: PhysicsWorld.h:37