diff --git a/Levels/heightmapLvlTest.png b/Levels/heightmapLvl0.png similarity index 100% rename from Levels/heightmapLvlTest.png rename to Levels/heightmapLvl0.png diff --git a/Levels/heightmapLvlTest2.png b/Levels/heightmapLvl02.png similarity index 100% rename from Levels/heightmapLvlTest2.png rename to Levels/heightmapLvl02.png diff --git a/application.cc b/application.cc index f6ee1ff..e2c375e 100644 --- a/application.cc +++ b/application.cc @@ -7,6 +7,8 @@ Application::Application() { void Application::init() { + // choose Level TODO: Choose this in a menu + this->level = Level("0"); // Don't change this! ignoredMouseUpdates = 0; cameraLock = true; diff --git a/level.cc b/level.cc index b6ca270..1cab1e4 100644 --- a/level.cc +++ b/level.cc @@ -2,9 +2,9 @@ -Level::Level(std::string filePath){ - this->filePath = filePath; - this->terrain = Terrain(filePath + "/terrain"); +Level::Level(std::string levelNum){ + this->levelNum = levelNum; + this->terrain = Terrain(levelNum); skydomeSize = 50.0f; } @@ -25,6 +25,31 @@ void Level::load() { // currently hard coded should later read this stuff out of a file this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f); + /*Loading Objects via xml: + XMLDocument* doc = new XMLDocument(); + const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str(); + doc->LoadFile(xmlFile); + if (doc->ErrorID()!=0){ + printf("Could not open ObjectSetupXml!\n"); + exit(-1); + } + XMLDocument* compositions = new XMLDocument(); + const char* compositionsFile = "../Levels/ObjectSetups/Compositions.xml"; + compositions->LoadFile(compositionsFile); + if (compositions->ErrorID()!=0){ + printf("Could not open Compositions!\n"); + exit(-1); + } + XMLElement* thisComposition = compositions->FirstChildElement("composition"); + for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ + int thisType; + thisComposition->QueryIntAttribute("typeID", &thisType); + if(thisType == type){ + ... + } + } + */ + //add player Model model = Model("MarbleSmooth.obj", 0.75f); Material material = Material("marbleTexture_small.png", 0.1f, 0.5f, 0.5f, 3.0f); diff --git a/level.hh b/level.hh index 83c971f..a1863b3 100644 --- a/level.hh +++ b/level.hh @@ -9,10 +9,11 @@ #include "material.hh" #include "camera.hh" #include "physics.hh" +#include "converter/tinyxml2.hh" class Level { public: - Level(std::string filePath); + Level(std::string levelNum); Level(); ~Level(); void load(); @@ -27,7 +28,7 @@ class Level { glm::vec4 getFogColor(); void setSkydomeSize(float size); private: - std::string filePath; + std::string levelNum; std::vector objects; std::vector physicObjects; std::vector lights; diff --git a/terrain.cc b/terrain.cc index 7fca297..cdc790a 100644 --- a/terrain.cc +++ b/terrain.cc @@ -1,8 +1,8 @@ #include "terrain.hh" #include "lodepng.h" -Terrain::Terrain(std::string filePath){ - this->filePath = filePath; +Terrain::Terrain(std::string levelNum){ + this->levelNum = levelNum; } Terrain::Terrain(){ @@ -13,10 +13,8 @@ Terrain::~Terrain() { void Terrain::load() { - filePath = "../Levels/heightmapLvlTest.png"; //TODO remove this, its only for testing - std::vector image; //the raw pixels - unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, filePath); + unsigned error = lodepng::decode(image, heightmapWidth, heightmapHeight, "../Levels/heightmapLvl" + levelNum + ".png"); if (error) { std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl; } diff --git a/terrain.hh b/terrain.hh index 263ea30..3cb8a4c 100644 --- a/terrain.hh +++ b/terrain.hh @@ -7,7 +7,7 @@ #include "model.hh" class Terrain { public: - Terrain(std::string filePath); + Terrain(std::string levelNum); Terrain(); ~Terrain(); void load(); @@ -19,7 +19,7 @@ class Terrain { private: Material material; - std::string filePath; + std::string levelNum; unsigned int heightmapHeight, heightmapWidth; float** heightmap; //can be accessed like 'float[][]' bool heightmapChanged;