Saxum/physics.hh

65 lines
2.8 KiB
C++
Raw Normal View History

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>
#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-14 13:23:10 +00:00
#include "extern/bullet/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
#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"
#include "extern/bullet/src/LinearMath/btVector3.h"
#include "extern/bullet/src/LinearMath/btMatrix3x3.h"
2014-11-14 13:17:04 +00:00
class Physics {
public:
Physics();
2014-11-14 13:17:04 +00:00
~Physics();
2014-11-14 13:23:10 +00:00
void init();
void takeUpdateStep(float timeDiff);
2014-11-14 13:17:04 +00:00
void rollForward(glm::vec3 camPos, float strength);
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);
glm::mat4 getRotation(int i);
void rollForward(glm::vec3 camPos);
void addStaticGroundPlane();
2014-11-14 13:23:10 +00:00
void addTerrain(int width, int length, float** heightData);
void addPlayer(float rad, float x, float y, float z, float mass, unsigned indice);
void addSphere(float rad, float x, float y, float z, float mass, unsigned indice);
2014-11-14 13:23:10 +00:00
2014-11-14 13:17:04 +00:00
private:
btRigidBody* playerBody;
btRigidBody* terrainBody;
std::vector<btRigidBody*> bodies; //list of all bodies. bodies are also in world, but save again to ease cleaning up process.
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-10-20 16:48:20 +00:00
#endif