Implemented loading of physical objects. Compositions.xml holds mostly Dummy-Values for those.

This commit is contained in:
Steffen Fündgens 2014-12-12 16:52:05 +01:00
parent f8d9ff0919
commit caea9b7181
2 changed files with 38 additions and 13 deletions

View File

@ -96,6 +96,8 @@
<objectData>
<modelPath>marbleSmooth.obj</modelPath>
<texturePath>MarbleTexture.png</texturePath>
@ -104,6 +106,8 @@
<specularFactor>0.5</specularFactor>
<shininess>3.0</shininess>
<physicType>Player</physicType>
<radius>1.25</radius>
<mass>8.0</mass>
</objectData>
<objectData>
@ -129,8 +133,8 @@
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>2.0</mass>
<dampningL></dampningL>
<dampningA></dampningA>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
<objectData>
@ -142,8 +146,8 @@
<shininess>10.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>0.0</mass>
<dampningL></dampningL>
<dampningA></dampningA>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
<objectData>
@ -155,8 +159,8 @@
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>1.0</mass>
<dampningL></dampningL>
<dampningA></dampningA>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
<objectData>
@ -168,6 +172,6 @@
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>0.0</mass>
<dampningL></dampningL>
<dampningA></dampningA>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>

View File

@ -174,16 +174,37 @@ void Level::load() {
glm::vec3 objectPosition = compPos + glm::vec3(rotatedObjectOffset.x,rotatedObjectOffset.y,rotatedObjectOffset.z);
Object* object = new Object(model, material, objectPosition, compRot);
objects.push_back(object);
//physicObjects.push_back(object);
physicObjects.push_back(object);
const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText();
if(charPhysicType == NULL){
printf("XMLError: No physicType found.\n");
}
std::string physicType = charPhysicType;
//TODO switch (physicType) and add object to physics
//if(compositionType == 20){
// cameraCenter = object;
//}
//add Object to physics
if (physicType.compare("Player") == 0){
float radius, mass;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
this->physics.addPlayer(radius, *object, mass, physicObjects.size());
}
if (physicType.compare("Box") == 0){
float width, height, length, mass;
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
this->physics.addBox(width, height, length, *object, mass, physicObjects.size());
}
if (physicType.compare("TriangleMeshBody") == 0){
float mass, dampningL, dampningA;
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
this->physics.addTriangleMeshBody(*object, mass, dampningL, dampningA, physicObjects.size());
}
if(compositionType == 20){
cameraCenter = object;
}
}
}
}