Modified adders in physics to no longer accept float x,y,z but entity/object instead.

This commit is contained in:
Jasper 2014-11-21 12:56:30 +01:00
parent 3c0deb232f
commit fa60d52676
3 changed files with 8 additions and 8 deletions

View File

@ -29,7 +29,7 @@ void Level::load(ACGL::OpenGL::SharedShaderProgram shader) {
Object object = Object(model, material, glm::vec3(0.0f, 10.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 0.0f), shader);
//add player to phy
this->physics.addPlayer(1.25f,0.0f,10.0f,0.0f,1.0f,0);
this->physics.addPlayer(1.25f,object,1.0f,0);
objects.push_back(object);
Model skyboxModel = Model("skybox.obj", skyboxSize);

View File

@ -75,7 +75,7 @@ void Physics::addStaticGroundPlane()
world->addRigidBody(staticGroundBody);
}
void Physics::addPlayer(float rad, float x, float y, float z, float mass, unsigned indice)
void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
{
if(bodies.size() != indice)
throw std::invalid_argument( "Bodies out of Sync" );
@ -87,7 +87,7 @@ void Physics::addPlayer(float rad, float x, float y, float z, float mass, unsign
sphere->calculateLocalInertia((btScalar)mass,inertia);
}
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(x,y,z)));
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z)));
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
@ -138,7 +138,7 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo
throw std::invalid_argument( "Bodies out of Sync" );
}
void Physics::addSphere(float rad, float x, float y, float z, float mass, unsigned indice)
void Physics::addSphere(float rad, Entity entity, float mass, unsigned indice)
{
if(bodies.size() != indice)
throw std::invalid_argument( "Bodies out of Sync" );
@ -150,8 +150,8 @@ void Physics::addSphere(float rad, float x, float y, float z, float mass, unsign
sphere->calculateLocalInertia((btScalar)mass,inertia);
}
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(x,y,z)));
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z)));
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
//info.

View File

@ -48,8 +48,8 @@ class Physics {
void rollForward(glm::vec3 camPos);
void addStaticGroundPlane();
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);
void addPlayer(float rad, Entity entity, float mass, unsigned indice);
void addSphere(float rad, Entity entity, float mass, unsigned indice);
void addBox(float width, float height, float length, Entity entity, float mass, unsigned indice);
private: