added wasd recognition, prepared roll forward to accept vec3 pos instead of mat3 rot

This commit is contained in:
Jasper 2014-11-17 13:12:51 +01:00
parent cac4672c7c
commit e579fe1d75
4 changed files with 15 additions and 6 deletions

View File

@ -76,6 +76,11 @@ void Level::update(float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPre
camera.updateRotation(mouseDelta/100.0f); camera.updateRotation(mouseDelta/100.0f);
} }
if(wPressed)
{
//physics.rollForward(camera.getRotation);
}
physics.takeUpdateStep(runTime); physics.takeUpdateStep(runTime);
objects[0].setPosition(physics.getPos(0)); objects[0].setPosition(physics.getPos(0));

View File

@ -16,7 +16,7 @@ class Level {
Level(); Level();
~Level(); ~Level();
void load(ACGL::OpenGL::SharedShaderProgram shader); // Shader is necessary for correct texture assigning void load(ACGL::OpenGL::SharedShaderProgram shader); // Shader is necessary for correct texture assigning
void update(float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed, bool dPressed, bool sPressed); void update(float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed,bool sPressed, bool dPressed);
void render(); void render();
glm::vec3 getAmbientLight(); glm::vec3 getAmbientLight();
std::vector<Light> getLights(); std::vector<Light> getLights();

View File

@ -14,7 +14,6 @@ btRigidBody* staticGroundBody;
Physics::Physics() { Physics::Physics() {
//init();
} }
Physics::~Physics() { Physics::~Physics() {
@ -159,11 +158,16 @@ glm::mat4 Physics::getRotation(int i)
return matrix; return matrix;
} }
void Physics::rollForward(glm::mat3 rotCamera) void Physics::rollForward(glm::vec3 camPos)
{ {
glm::vec3 saveVector= glm::vec3(1,0,0) * rotCamera; btVector3 pos(camPos.x,camPos.y,camPos.z);
pos -= playerBody->getCentreOfMassPosition();
pos.cross(btVector3(0,1,0);
playerBall->applyTorque(pos);
/* glm::vec3 saveVector= glm::vec3(1,0,0) * rotCamera;
saveVector = glm::cross(glm::vec3(0,1,0),saveVector); saveVector = glm::cross(glm::vec3(0,1,0),saveVector);
playerBall->applyTorque(btVector3(saveVector[0],saveVector[1],saveVector[2])); playerBall->applyTorque(btVector3(saveVector[0],saveVector[1],saveVector[2]));*/
} }
/* /*

View File

@ -39,7 +39,7 @@ class Physics {
void rollForward(glm::vec3 camPos, float strength); void rollForward(glm::vec3 camPos, float strength);
glm::vec3 getPos(int i); glm::vec3 getPos(int i);
glm::mat4 getRotation(int i); glm::mat4 getRotation(int i);
void rollForward(glm::mat3 rotCamera); void rollForward(glm::vec3 camPos);
void addStaticGroundPlane(); void addStaticGroundPlane();
void addTerrain(int width, int length, float** heightData); void addTerrain(int width, int length, float** heightData);
void addPlayer(float rad, float x, float y, float z, float mass, unsigned indice); void addPlayer(float rad, float x, float y, float z, float mass, unsigned indice);