Moved all dampning parameters (except for the camera) to Compositions.xml.
This commit is contained in:
parent
3560957d67
commit
b8d45cc522
@ -136,6 +136,8 @@
|
|||||||
<shininess>3.0</shininess>
|
<shininess>3.0</shininess>
|
||||||
<physicType>Player</physicType>
|
<physicType>Player</physicType>
|
||||||
<radius>1.5</radius>
|
<radius>1.5</radius>
|
||||||
|
<dampningL>0.1</dampningL>
|
||||||
|
<dampningA>0.7</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -149,6 +151,8 @@
|
|||||||
<width>5.0</width>
|
<width>5.0</width>
|
||||||
<height>6.0</height>
|
<height>6.0</height>
|
||||||
<length>1.8</length>
|
<length>1.8</length>
|
||||||
|
<dampningL>0.8</dampningL>
|
||||||
|
<dampningA>0.9</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -186,6 +190,8 @@
|
|||||||
<width>0.5</width>
|
<width>0.5</width>
|
||||||
<height>0.5</height>
|
<height>0.5</height>
|
||||||
<length>0.5</length>
|
<length>0.5</length>
|
||||||
|
<dampningL>1.0</dampningL>
|
||||||
|
<dampningA>1.0</dampningA>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
|
11
level.cc
11
level.cc
@ -212,20 +212,21 @@ void Level::load() {
|
|||||||
//add object to physics
|
//add object to physics
|
||||||
float mass;
|
float mass;
|
||||||
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&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){
|
if (physicType.compare("Player") == 0){
|
||||||
float radius;
|
float radius;
|
||||||
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&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){
|
}else if (physicType.compare("Box") == 0){
|
||||||
float width, height, length;
|
float width, height, length;
|
||||||
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
||||||
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
||||||
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
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){
|
}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());
|
this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size());
|
||||||
} else{
|
} else{
|
||||||
printf("XMLError: Not a valid physicType.\n");
|
printf("XMLError: Not a valid physicType.\n");
|
||||||
|
12
physics.cc
12
physics.cc
@ -104,7 +104,7 @@ void Physics::addStaticGroundPlane()
|
|||||||
|
|
||||||
|
|
||||||
//players and objects
|
//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)
|
if(bodies.size() == indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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 = new btRigidBody(info);
|
||||||
|
|
||||||
playerBall->setDamping(0.1f,0.7f);
|
playerBall->setDamping(dampningL, dampningA);
|
||||||
|
|
||||||
world->addRigidBody(playerBall);
|
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" );
|
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)
|
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);
|
btRigidBody* body = new btRigidBody(info);
|
||||||
|
|
||||||
body->setDamping(0.8f,0.9f);
|
body->setDamping(dampningL, dampningA);
|
||||||
|
|
||||||
world->addRigidBody(body);
|
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" );
|
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)
|
if(bodies.size() == indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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);
|
btRigidBody* body = new btRigidBody(info);
|
||||||
|
|
||||||
body->setDamping(0.2f,0.4f);
|
body->setDamping(dampningL, dampningA);
|
||||||
|
|
||||||
world->addRigidBody(body);
|
world->addRigidBody(body);
|
||||||
|
|
||||||
|
12
physics.hh
12
physics.hh
@ -53,15 +53,15 @@ class Physics {
|
|||||||
glm::vec3 getPos(int i);
|
glm::vec3 getPos(int i);
|
||||||
glm::mat4 getRotation(int i);
|
glm::mat4 getRotation(int i);
|
||||||
void addStaticGroundPlane();
|
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();
|
glm::vec3 getCameraPosition();
|
||||||
void addRigidBodyFromFile(Entity entity, float mass, float dampningL, float dampningA, std::string modelLocation,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 addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA, unsigned indice);
|
||||||
void addTerrain(int width, int length, float** heightData);
|
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 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 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, unsigned indice); //The Indice should be set to physicObjects.size()
|
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, 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
|
||||||
|
|
||||||
private:
|
private:
|
||||||
btRigidBody* playerBall; //allows for easier access to the ball
|
btRigidBody* playerBall; //allows for easier access to the ball
|
||||||
|
Loading…
Reference in New Issue
Block a user