diff --git a/Levels/ObjectSetups/Level1.xml b/Levels/ObjectSetups/Level1.xml
index 6df3c75..3a9b57f 100644
--- a/Levels/ObjectSetups/Level1.xml
+++ b/Levels/ObjectSetups/Level1.xml
@@ -166,3 +166,8 @@
skydome.png
+
+
+ 0.9
+ 100.0
+
diff --git a/converter/converter.cc b/converter/converter.cc
index 8128a4f..034d367 100644
--- a/converter/converter.cc
+++ b/converter/converter.cc
@@ -39,7 +39,7 @@ Converter::Converter(std::string level){
doc->LoadFile(charXmlFile);
if (doc->ErrorID()!=0){
printf("Could not open xml, creating new xml.\n");
- //Create all global Elements with Dummy-Values
+ //Create all global Lightingparameters with Dummy-Values
std::vector lightAttributes;
lightAttributes.push_back(doc->NewElement("xOffset"));
lightAttributes.push_back(doc->NewElement("yOffset"));
@@ -85,16 +85,27 @@ Converter::Converter(std::string level){
for(int i=0;i<7;i++){
directionalLight->InsertEndChild(lightAttributes[i]);
}
+ doc->InsertEndChild(ambientLight);
+ doc->InsertEndChild(fogColour);
+ doc->InsertEndChild(directionalLight);
+ //Create global skydome Element
XMLElement* skydome = doc->NewElement("skydome");
XMLElement* skydomeTexture = doc->NewElement("texture");
skydomeTexture->SetText("skydome.png");
skydome->InsertEndChild(skydomeTexture);
-
- doc->InsertEndChild(ambientLight);
- doc->InsertEndChild(fogColour);
- doc->InsertEndChild(directionalLight);
doc->InsertEndChild(skydome);
+
+ //Create global physics parameters
+ XMLElement* physics = doc->NewElement("physics");
+ XMLElement* friction = doc->NewElement("friction");
+ XMLElement* strength = doc->NewElement("strength");
+ friction->SetText("0.9");
+ strength->SetText("100.0");
+ physics->InsertEndChild(friction);
+ physics->InsertEndChild(strength);
+ doc->InsertEndChild(physics);
+
}else{
dst << src.rdbuf();
XMLElement* thisComposition = doc->FirstChildElement("composition");
diff --git a/level.cc b/level.cc
index 146222b..84476d6 100644
--- a/level.cc
+++ b/level.cc
@@ -69,6 +69,13 @@ void Level::load() {
printf("Could not open ObjectSetupXml!\n");
exit(-1);
}
+
+ //load global physic parameter
+ float friction;
+ XMLElement* physicsElement = doc->FirstChildElement("physics");
+ errorCheck(physicsElement->FirstChildElement("strength")->QueryFloatText(&strength));
+ errorCheck(physicsElement->FirstChildElement("friction")->QueryFloatText(&friction));
+
//load the skydome
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
const char* charSkydomeTexture = skydomeElement->FirstChildElement("texture")->GetText();
@@ -208,7 +215,7 @@ void Level::load() {
if (physicType.compare("Player") == 0){
float radius;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
- this->physics.addPlayer(radius, *object, mass, physicObjects.size());
+ this->physics.addPlayer(friction, radius, *object, mass, physicObjects.size());
}else if (physicType.compare("Box") == 0){
float width, height, length;
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
@@ -359,19 +366,17 @@ void Level::update(float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPre
camera.updateRotation(mouseDelta/100.0f);
}
- float str = 100;
-
if(wPressed){
- physics.rollForward(camera.getVector(),str);
+ physics.rollForward(camera.getVector(),strength);
}
if(aPressed) {
- physics.rollLeft(camera.getVector(),str);
+ physics.rollLeft(camera.getVector(),strength);
}
if(sPressed) {
- physics.rollBack(camera.getVector(),str);
+ physics.rollBack(camera.getVector(),strength);
}
if(dPressed){
- physics.rollRight(camera.getVector(),str);
+ physics.rollRight(camera.getVector(),strength);
}
physics.takeUpdateStep(runTime);
diff --git a/level.hh b/level.hh
index e3d81bd..00c0cca 100644
--- a/level.hh
+++ b/level.hh
@@ -46,6 +46,7 @@ class Level {
Camera camera;
Terrain terrain;
float skydomeSize;
+ float strength;
};
#endif
diff --git a/physics.cc b/physics.cc
index 448a438..1a5e432 100644
--- a/physics.cc
+++ b/physics.cc
@@ -104,7 +104,7 @@ void Physics::addStaticGroundPlane()
//players and objects
-void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
+void Physics::addPlayer(float friction, float rad, Entity entity, float mass, unsigned indice)
{
if(bodies.size() == indice)
throw std::invalid_argument( "Bodies out of Sync" );
@@ -120,7 +120,7 @@ void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
- info.m_friction = 0.9;
+ info.m_friction = friction;
playerBall = new btRigidBody(info);
diff --git a/physics.hh b/physics.hh
index 9d96467..9e566b7 100644
--- a/physics.hh
+++ b/physics.hh
@@ -59,7 +59,7 @@ class Physics {
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 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, 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