00001 #ifndef PHYSICSWORLD_H
00002 #define PHYSICSWORLD_H
00003
00004 #include "Types.h"
00005 #include "RelationalNode.h"
00006 #include "Property.h"
00007
00008 #define MAX_OBJECTS 1024
00009
00010 #define WARP_X 512
00011 #define WARP_Y 512
00012 #define WARP_Z 512
00013
00014 namespace RenderTools {
00015
00016 class PhysicsWorld {
00017 public:
00018
00019 static PropertyPtr create( const XMLNodePtr & xml = XMLNodePtr() );
00020 static void update( void );
00021 static void initialize( void );
00022 static float toSim( float x );
00023 static float fromSim( float x );
00024 static Vec3 fromSim( const Vec3 & x );
00025 static Mat4 fromSim( const Mat4 & x );
00026 static Vec3 getWarpVector();
00027 static void setTimeStep( float step );
00028 static float getTimeStep( void );
00029
00030 #ifdef RT_BULLET
00031 static btVector3 toSim( const Vec3 & x );
00032 static btVector3 toSim( const btVector3 & x );
00033 static Vec3 fromSim( const btVector3 & x );
00034 static btTransform toSim( const Mat4 & x );
00035 static Mat4 fromSim( const btTransform & x );
00036 static btDiscreteDynamicsWorld * getWorld( void );
00037 static void addRigidBody( btRigidBody * const & body );
00038 static void deleteRigidBody( btRigidBody * const & body );
00039 static void deleteConstraint( btTypedConstraint * const & constraint );
00040 #endif
00041
00042
00043 private:
00044 PhysicsWorld( XMLNodePtr xml = XMLNodePtr() );
00045 virtual ~PhysicsWorld( void );
00046
00047 static PropertyContainerPtr s_instance;
00048 static float s_step;
00049 static bool s_initialized;
00050
00051 #ifdef RT_BULLET
00052 static btDefaultCollisionConfiguration * s_config;
00053 static btCollisionDispatcher * s_dispatcher;
00054 static btSequentialImpulseConstraintSolver * s_solver;
00055 static btDiscreteDynamicsWorld * s_world;
00056 static btAlignedObjectArray<btRigidBody*> s_bodies;
00057 static btAxisSweep3 * s_cache;
00058 static btClock s_clock;
00059 #endif
00060 };
00061
00062 typedef shared_ptr< PhysicsWorld > PhysicsWorldPtr;
00063
00064 };
00065
00066 #endif