Moved all dampning parameters (except for the camera) to Compositions.xml.

This commit is contained in:
Steffen Fündgens 2015-01-06 13:31:53 +01:00
parent cc4842a628
commit aee4d4a8ff
4 changed files with 24 additions and 17 deletions

View File

@ -136,6 +136,8 @@
<shininess>3.0</shininess>
<physicType>Player</physicType>
<radius>1.5</radius>
<dampningL>0.1</dampningL>
<dampningA>0.7</dampningA>
</objectData>
<objectData>
@ -149,6 +151,8 @@
<width>5.0</width>
<height>6.0</height>
<length>1.8</length>
<dampningL>0.8</dampningL>
<dampningA>0.9</dampningA>
</objectData>
<objectData>
@ -186,6 +190,8 @@
<width>0.5</width>
<height>0.5</height>
<length>0.5</length>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
<objectData>

View File

@ -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");

View File

@ -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);

View File

@ -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