From 147ae177895a34ca08766d0c732554038ba0c246 Mon Sep 17 00:00:00 2001 From: Steffen Date: Sat, 17 Jan 2015 12:24:54 +0100 Subject: [PATCH] Added ignoreHeightmap option to compositions in Compositions.xml. --- Levels/ObjectSetups/Compositions.xml | 14 +++++++++++--- level.cc | 11 +++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Levels/ObjectSetups/Compositions.xml b/Levels/ObjectSetups/Compositions.xml index d0275bd..80cf038 100644 --- a/Levels/ObjectSetups/Compositions.xml +++ b/Levels/ObjectSetups/Compositions.xml @@ -1,6 +1,7 @@ 20 + false marbleSmooth.obj 0.0 @@ -14,6 +15,7 @@ 40 + false block.obj 0.0 @@ -27,6 +29,7 @@ 60 + false column.obj 0.0 @@ -40,6 +43,7 @@ 80 + false torch.obj 0.0 @@ -62,6 +66,7 @@ 85 + false 0.0 1 @@ -76,6 +81,7 @@ 100 + false column.obj 0.0 @@ -105,6 +111,7 @@ 120 + false switch_inner.obj 0.0 @@ -123,13 +130,14 @@ - + - 140 + 140 + true block.obj 0.0 - 10.0 + 20.0 2.0 1.5 0.0 diff --git a/level.cc b/level.cc index 5d24e37..4a091df 100644 --- a/level.cc +++ b/level.cc @@ -207,10 +207,13 @@ void Level::load() { errorCheck(thisComposition->FirstChildElement("xRot")->QueryFloatText(&compRot[0])); errorCheck(thisComposition->FirstChildElement("yRot")->QueryFloatText(&compRot[1])); errorCheck(thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2])); - glm::vec3 compPos = glm::vec3(compXPos, - compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())] - [int(compZPos-0.5+0.5*terrain.getHeightmapWidth())], - compZPos); + bool ignoreHeightmap; + errorCheck(composition->FirstChildElement("ignoreHeightmap")->QueryBoolText(&ignoreHeightmap)); + if (!ignoreHeightmap){ + compYOffset = compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())] + [int(compZPos-0.5+0.5*terrain.getHeightmapWidth())]; + } + glm::vec3 compPos = glm::vec3(compXPos, compYOffset, compZPos); objectOffset = objectOffset * compScale; glm::vec4 rotatedObjectOffset = glm::rotate(compRot.x, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::rotate(compRot.y, glm::vec3(0.0f, 1.0f, 0.0f))