• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/physic/header/Physic.h

Go to the documentation of this file.
00001 #pragma once
00002 #include <crtdbg.h>
00003 #include <NxUserAllocatorDefault.h>
00004 #include <NxControllerManager.h>
00005 #include <NxBoxController.h>
00006 #include <NxCapsuleController.h>
00007 #include <NxPhysics.h>
00008 #include <NxCooking.h>
00009 #include "Body.h"
00010 #include "Stream.h"
00011 
00014 class Physic :
00015         public IPhysic
00016 {
00017 public:
00019         Physic(void);
00021         virtual ~Physic(void);
00022 
00023         bool init(void);
00024         void uninit(void);
00025 
00026         pIBody createDummy(float3 position, float3 rotation);
00027         pIBody createSphere(float3 position, float3 rotation,
00028                         float radius, float density,
00029                         ushort colGroup = 0, int material = 0, bool dynamic = false);
00030         pIBody createBox(float3 position, float3 rotation,
00031                         float width, float height, float depth, float density,
00032                         ushort colGroup = 0, int material = 0, bool dynamic = false);
00033         pIBody createMesh(float3 position, float3 rotation,
00034                         float* vertices,  int vertexSize, int numVertices,
00035                         ushort* indices, int numIndices, float density,
00036                         ushort colGroup = 0, int material = 0, bool dynamic = false);
00037         void createExplosion(float3 position);
00038 
00039         void freeBody(pIBody&);
00040 
00041         void update(float dt);
00042 
00043 private:
00044         // nVidia PhysX SDK
00045         NxPhysicsSDK* sdk; 
00046         NxScene* scene;
00047         NxForceField* forceField;
00048         NxActor* forceFieldActor;
00049         NxForceFieldShape* includeShape;
00050         NxForceFieldShape* excludeShape;
00051         NxForceFieldShapeGroup* includeGroup;
00052         NxForceFieldShapeGroup* excludeGroup;
00053         float explosionTime;
00054         bool explosion;
00055         bool initialized;
00056 };
00057 
00058 extern NxUserAllocatorDefault nxAllocator;
00059 
00061 inline void toFloat4x4(const NxMat34& w, float4x4& m)
00062 {
00063         m(0,0) = w.M(0,0); m(0,1) = w.M(0,1); m(0,2) = w.M(0,2); m(0,3) = w.t.x;
00064         m(1,0) = w.M(1,0); m(1,1) = w.M(1,1); m(1,2) = w.M(1,2); m(1,3) = w.t.y;
00065         m(2,0) = w.M(2,0); m(2,1) = w.M(2,1); m(2,2) = w.M(2,2); m(2,3) = w.t.z;
00066         m(3,0) = 0.f; m(3,1) = 0.f; m(3,2) = 0.f; m(3,3) = 1.f;
00067 }
00068 
00070 inline NxMat34 asNxMat34(const float4x4& m)
00071 {
00072         return NxMat34(
00073                 NxMat33(
00074                         NxVec3(m(0,0),m(0,1),m(0,2)),
00075                         NxVec3(m(1,0),m(1,1),m(1,2)),
00076                         NxVec3(m(2,0),m(2,1),m(2,2))),
00077                 NxVec3(m(0,3), m(1,3), m(2,3)));
00078 }
00079 
00081 inline NxVec3 asNxVec3(const float3& v)
00082 {
00083         return NxVec3(v.x, v.y, v.z);
00084 }

Generated on Fri Jun 18 2010 17:48:39 for Cannonball by  doxygen 1.7.0