readding button -> box

This commit is contained in:
Jasper 2015-01-23 12:05:43 +01:00
parent d827948747
commit 0a5e6ba941
2 changed files with 7 additions and 5 deletions

View File

@ -247,21 +247,23 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f
throw std::invalid_argument( "Bodies out of Sync" );
}
void Physics::addButton(float radius, float height, Entity entity, float mass, float dampningL, float dampningA, unsigned indice)
void Physics::addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice)
{
if(bodies.size() == indice)
throw std::invalid_argument( "Bodies out of Sync" );
btCylinderShape* shape = new btCylinderShape(btVector3(height/2, radius,radius));
btBoxShape* box = new btBoxShape(btVector3(width/2,height/2,length/2));
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z)));
btVector3 inertia(0,0,0);
if(mass != 0.0)
{
shape->calculateLocalInertia((btScalar)mass,inertia);
box->calculateLocalInertia((btScalar)mass,inertia);
}
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,shape,inertia);
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,box,inertia);
btRigidBody* body = new btRigidBody(info);

View File

@ -66,7 +66,7 @@ class Physics {
void addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //this is used to ensuer that the system is synchronized
void addPositionConstraint(int bodyIndice, float strength, glm::vec3 position);
void removePositionConstraint(int bodyIndice);
void addButton(float radius, float height, Entity entity, float mass, float dampningL, float dampningA, unsigned indice);
void addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice);
glm::vec3 getCameraToPlayer();
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};