diff --git a/Levels/ObjectSetups/Compositions.xml b/Levels/ObjectSetups/Compositions.xml
index b4a60e0..bf97041 100644
--- a/Levels/ObjectSetups/Compositions.xml
+++ b/Levels/ObjectSetups/Compositions.xml
@@ -136,6 +136,8 @@
3.0
Player
1.5
+ 0.1
+ 0.7
@@ -149,6 +151,8 @@
5.0
6.0
1.8
+ 0.8
+ 0.9
@@ -186,6 +190,8 @@
0.5
0.5
0.5
+ 1.0
+ 1.0
diff --git a/level.cc b/level.cc
index 84476d6..d78de87 100644
--- a/level.cc
+++ b/level.cc
@@ -212,20 +212,21 @@ void Level::load() {
//add object to physics
float mass;
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
+ float dampningL, dampningA;
+ errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
+ errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
if (physicType.compare("Player") == 0){
float radius;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
- this->physics.addPlayer(friction, radius, *object, mass, physicObjects.size());
+ this->physics.addPlayer(friction, radius, *object, mass, dampningL, dampningA, physicObjects.size());
}else if (physicType.compare("Box") == 0){
float width, height, length;
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
- this->physics.addBox(width, height, length, *object, mass, physicObjects.size());
+ this->physics.addBox(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size());
}else if (physicType.compare("TriangleMesh") == 0){
- float dampningL, dampningA;
- errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
- errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
+
this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size());
} else{
printf("XMLError: Not a valid physicType.\n");
diff --git a/physics.cc b/physics.cc
index 1a5e432..95e46f3 100644
--- a/physics.cc
+++ b/physics.cc
@@ -104,7 +104,7 @@ void Physics::addStaticGroundPlane()
//players and objects
-void Physics::addPlayer(float friction, float rad, Entity entity, float mass, unsigned indice)
+void Physics::addPlayer(float friction, float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice)
{
if(bodies.size() == indice)
throw std::invalid_argument( "Bodies out of Sync" );
@@ -124,7 +124,7 @@ void Physics::addPlayer(float friction, float rad, Entity entity, float mass, un
playerBall = new btRigidBody(info);
- playerBall->setDamping(0.1f,0.7f);
+ playerBall->setDamping(dampningL, dampningA);
world->addRigidBody(playerBall);
@@ -207,7 +207,7 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f
throw std::invalid_argument( "Bodies out of Sync" );
}
-void Physics::addBox(float width, float height, float length, Entity entity, float mass, unsigned indice)
+void Physics::addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice)
{
if(bodies.size() == indice)
@@ -227,7 +227,7 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo
btRigidBody* body = new btRigidBody(info);
- body->setDamping(0.8f,0.9f);
+ body->setDamping(dampningL, dampningA);
world->addRigidBody(body);
@@ -237,7 +237,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, Entity entity, float mass, unsigned indice)
+void Physics::addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice)
{
if(bodies.size() == indice)
throw std::invalid_argument( "Bodies out of Sync" );
@@ -256,7 +256,7 @@ void Physics::addSphere(float rad, Entity entity, float mass, unsigned indice)
btRigidBody* body = new btRigidBody(info);
- body->setDamping(0.2f,0.4f);
+ body->setDamping(dampningL, dampningA);
world->addRigidBody(body);
diff --git a/physics.hh b/physics.hh
index 9e566b7..c7104ff 100644
--- a/physics.hh
+++ b/physics.hh
@@ -53,15 +53,15 @@ class Physics {
glm::vec3 getPos(int i);
glm::mat4 getRotation(int i);
void addStaticGroundPlane();
- void addCamera(float rad,float distance); //Do NOT impliment before Player has been created;
+ void addCamera(float rad, float distance); //Do NOT impliment before Player has been created;
glm::vec3 getCameraPosition();
- void addRigidBodyFromFile(Entity entity, float mass, float dampningL, float dampningA, std::string modelLocation,unsigned indice);
- void addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA,unsigned indice);
+ void addRigidBodyFromFile(Entity entity, float mass, float dampningL, float dampningA, std::string modelLocation, unsigned indice);
+ void addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA, unsigned indice);
void addTerrain(int width, int length, float** heightData);
void addTerrainTriangles(int width, int length, float** heightData); //add the terrain as a trimesh instead of a heightmap
- void addPlayer(float friction, float rad, Entity entity, float mass, unsigned indice); //use these AFTER physicObjects.push_back(object)! if mass == 0 then the object is unmoveable
- void addSphere(float rad, Entity entity, float mass, unsigned indice); //The Indice should be set to physicObjects.size()
- void addBox(float width, float height, float length, Entity entity, float mass, unsigned indice); //this is used to ensuer that the system is synchronized
+ void addPlayer(float friction, float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //use these AFTER physicObjects.push_back(object)! if mass == 0 then the object is unmoveable
+ void addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //The Indice should be set to physicObjects.size()
+ 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
private:
btRigidBody* playerBall; //allows for easier access to the ball