From caea9b71814d74a8cad868efb1879cab17afe291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20F=C3=BCndgens?= Date: Fri, 12 Dec 2014 16:52:05 +0100 Subject: [PATCH] Implemented loading of physical objects. Compositions.xml holds mostly Dummy-Values for those. --- Levels/ObjectSetups/Compositions.xml | 20 +++++++++++------- level.cc | 31 +++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Levels/ObjectSetups/Compositions.xml b/Levels/ObjectSetups/Compositions.xml index 9b22027..bc29951 100644 --- a/Levels/ObjectSetups/Compositions.xml +++ b/Levels/ObjectSetups/Compositions.xml @@ -96,6 +96,8 @@ + + marbleSmooth.obj MarbleTexture.png @@ -104,6 +106,8 @@ 0.5 3.0 Player + 1.25 + 8.0 @@ -129,8 +133,8 @@ 2.0 TriangleMeshBody 2.0 - - + 1.0 + 1.0 @@ -142,8 +146,8 @@ 10.0 TriangleMeshBody 0.0 - - + 1.0 + 1.0 @@ -155,8 +159,8 @@ 2.0 TriangleMeshBody 1.0 - - + 1.0 + 1.0 @@ -168,6 +172,6 @@ 2.0 TriangleMeshBody 0.0 - - + 1.0 + 1.0 diff --git a/level.cc b/level.cc index cb4e841..45a5721 100644 --- a/level.cc +++ b/level.cc @@ -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; + } } } }