readding button -> box
This commit is contained in:
parent
bea8436a8d
commit
14462ac8df
10
physics.cc
10
physics.cc
@ -247,21 +247,23 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f
|
|||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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)
|
if(bodies.size() == indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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)));
|
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);
|
btVector3 inertia(0,0,0);
|
||||||
if(mass != 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);
|
btRigidBody* body = new btRigidBody(info);
|
||||||
|
|
||||||
|
@ -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 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 addPositionConstraint(int bodyIndice, float strength, glm::vec3 position);
|
||||||
void removePositionConstraint(int bodyIndice);
|
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();
|
glm::vec3 getCameraToPlayer();
|
||||||
|
|
||||||
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};
|
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};
|
||||||
|
Loading…
Reference in New Issue
Block a user