2014-10-20 16:48:20 +00:00
# ifndef PHYSICS_HH_INCLUDED
# define PHYSICS_HH_INCLUDED
2014-10-20 16:39:16 +00:00
2014-11-14 13:17:04 +00:00
# include <ACGL/Base/Settings.hh>
# include <ACGL/Math/Math.hh>
# include <vector>
2014-11-21 11:50:11 +00:00
# include "entity.hh"
2014-11-14 13:17:04 +00:00
# include "extern/bullet/src/BulletDynamics/Dynamics/btRigidBody.h"
# include "extern/bullet/src/BulletDynamics/Dynamics/btDynamicsWorld.h"
# include "extern/bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
2014-11-14 13:23:10 +00:00
2014-11-14 13:17:04 +00:00
# include "extern/bullet/src/BulletCollision/CollisionShapes/btSphereShape.h"
2014-11-21 11:50:11 +00:00
# include "extern/bullet/src/BulletCollision/CollisionShapes/btBoxShape.h"
2014-11-14 13:23:10 +00:00
# include "extern/bullet/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
2014-11-17 11:57:16 +00:00
# include "extern/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h"
2014-11-14 13:17:04 +00:00
# include "extern/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h"
# include "extern/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" //YAY!
# include "extern/bullet/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
# include "extern/bullet/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
# include "extern/bullet/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
# include "extern/bullet/src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
# include "extern/bullet/src/BulletCollision/BroadphaseCollision/btDispatcher.h"
# include "extern/bullet/src/LinearMath/btScalar.h"
# include "extern/bullet/src/LinearMath/btMotionState.h"
# include "extern/bullet/src/LinearMath/btDefaultMotionState.h"
# include "extern/bullet/src/LinearMath/btQuaternion.h"
2014-11-14 14:15:29 +00:00
# include "extern/bullet/src/LinearMath/btVector3.h"
# include "extern/bullet/src/LinearMath/btMatrix3x3.h"
2014-11-14 13:17:04 +00:00
2014-11-07 15:44:12 +00:00
class Physics {
public :
2014-11-17 11:57:16 +00:00
Physics ( ) ;
2014-11-14 13:17:04 +00:00
~ Physics ( ) ;
2014-11-14 13:23:10 +00:00
void init ( ) ;
2014-11-28 11:06:17 +00:00
void takeUpdateStep ( float timeDiff ) ; //must be used in level.update to proagate the physics
void rollForward ( glm : : vec3 camPos , float strength ) ; //self explainitory
2014-11-17 15:07:40 +00:00
void rollLeft ( glm : : vec3 camPos , float strength ) ;
void rollRight ( glm : : vec3 camPos , float strength ) ;
void rollBack ( glm : : vec3 camPos , float strength ) ;
2014-11-14 13:23:10 +00:00
glm : : vec3 getPos ( int i ) ;
2014-11-14 14:15:29 +00:00
glm : : mat4 getRotation ( int i ) ;
2014-11-17 11:57:16 +00:00
void addStaticGroundPlane ( ) ;
2014-11-14 13:23:10 +00:00
void addTerrain ( int width , int length , float * * heightData ) ;
2014-11-28 11:06:17 +00:00
void addPlayer ( float rad , Entity entity , float mass , unsigned indice ) ; //use these AFTER physicObjects.push_back(object)! if mass == 0 then the object is unmoveable
void addSphere ( float rad , Entity entity , float mass , unsigned indice ) ; //The Indice should be set to physicObjects.size()
void addBox ( float width , float height , float length , Entity entity , float mass , unsigned indice ) ; //this is used to ensuer that the system is synchronized
2014-11-14 13:23:10 +00:00
2014-11-14 13:17:04 +00:00
private :
2014-11-28 11:06:17 +00:00
btRigidBody * playerBall ; //allows for quicker access to the ball
btRigidBody * terrainBody ; //duh
2014-11-14 13:17:04 +00:00
std : : vector < btRigidBody * > bodies ; //list of all bodies. bodies are also in world, but save again to ease cleaning up process.
2014-11-17 11:57:16 +00:00
btRigidBody * staticGroundBody ;
2014-11-14 13:17:04 +00:00
btDynamicsWorld * world ; //contains physical attributes of the world.
btDispatcher * dispatcher ; //
btCollisionConfiguration * colConfig ; //defines the type of collision detection.
btBroadphaseInterface * broadphase ; //defines how objects are culled from collision detection.
btConstraintSolver * solver ; //solver for forces and impulses.
2014-11-07 15:44:12 +00:00
} ;
2014-10-20 16:48:20 +00:00
# endif