integrating tinyxml into level, adding lights to compositions

This commit is contained in:
Steffen Fündgens 2014-12-05 12:47:02 +01:00
parent 7e7754ca64
commit 5e44f9680e
6 changed files with 4406 additions and 15 deletions

View File

@ -40,10 +40,20 @@
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<scale>1.0</scale> <scale>1.0</scale>
</object> </object>
<object>
<xOffset>0.0</xOffset>
<yOffset>1.0</yOffset>
<zOffset>0.0</zOffset>
<rColour>1.0</rColour>
<gColour>1.0</gColour>
<bColour>1.0</bColour>
<intensity>5.0</intensity>
<scale>0.0</scale>
</object>
</composition> </composition>
<composition> <composition>
<typeID>100</typeID> <typeID>99</typeID>
<object> <object>
<filePath>../Levels/Geometry/Column.obj</filePath> <filePath>../Levels/Geometry/Column.obj</filePath>
<xOffset>0.0</xOffset> <xOffset>0.0</xOffset>
@ -66,3 +76,21 @@
<scale>1.0</scale> <scale>1.0</scale>
</object> </object>
</composition> </composition>
<composition>
<typeID>120</typeID>
<object>
<filePath>../Levels/Geometry/switch_inner.obj</filePath>
<xOffset>0.0</xOffset>
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
</object>
<object>
<filePath>../Levels/Geometry/switch_outer.obj</filePath>
<xOffset>0.0</xOffset>
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
</object>
</composition>

View File

@ -30,7 +30,7 @@ Converter::Converter(std::string level){
}else{ }else{
XMLElement* thisComposition = doc->FirstChildElement("composition"); XMLElement* thisComposition = doc->FirstChildElement("composition");
int idGreen, idBlue; int idGreen, idBlue;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
thisComposition->QueryIntAttribute("idGreen", &idGreen); thisComposition->QueryIntAttribute("idGreen", &idGreen);
thisComposition->QueryIntAttribute("idBlue", &idBlue); thisComposition->QueryIntAttribute("idBlue", &idBlue);
if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){ if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){
@ -96,7 +96,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ){ void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ){
XMLElement* thisComposition = doc->FirstChildElement("composition"); XMLElement* thisComposition = doc->FirstChildElement("composition");
int idGreen, idBlue; int idGreen, idBlue;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
thisComposition->QueryIntAttribute("idGreen", &idGreen); thisComposition->QueryIntAttribute("idGreen", &idGreen);
thisComposition->QueryIntAttribute("idBlue", &idBlue); thisComposition->QueryIntAttribute("idBlue", &idBlue);
if(idGreen == idG && idBlue == idB){ if(idGreen == idG && idBlue == idB){
@ -109,7 +109,7 @@ void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX
void Converter::deleteComposition(unsigned int idG, unsigned int idB){ void Converter::deleteComposition(unsigned int idG, unsigned int idB){
XMLElement* thisComposition = doc->FirstChildElement("composition"); XMLElement* thisComposition = doc->FirstChildElement("composition");
int idGreen, idBlue; int idGreen, idBlue;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
thisComposition->QueryIntAttribute("idGreen", &idGreen); thisComposition->QueryIntAttribute("idGreen", &idGreen);
thisComposition->QueryIntAttribute("idBlue", &idBlue); thisComposition->QueryIntAttribute("idBlue", &idBlue);
if(idGreen == idG && idBlue == idB){ if(idGreen == idG && idBlue == idB){
@ -129,7 +129,7 @@ std::vector<unsigned int> Converter::getNextID(){
/* finding a typeID in compositions: /* finding a typeID in compositions:
XMLElement* thisComposition = compositions->FirstChildElement("composition"); XMLElement* thisComposition = compositions->FirstChildElement("composition");
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
int thisType; int thisType;
thisComposition->QueryIntAttribute("typeID", &thisType); thisComposition->QueryIntAttribute("typeID", &thisType);
if(thisType == type){ if(thisType == type){

View File

@ -17,6 +17,7 @@ Level::~Level() {
} }
} }
using namespace tinyxml2;
void Level::load() { void Level::load() {
this->physics = Physics(); this->physics = Physics();
@ -25,7 +26,7 @@ void Level::load() {
// currently hard coded should later read this stuff out of a file // currently hard coded should later read this stuff out of a file
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f); this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
/*Loading Objects via xml: //Loading Objects via xml:
XMLDocument* doc = new XMLDocument(); XMLDocument* doc = new XMLDocument();
const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str(); const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str();
doc->LoadFile(xmlFile); doc->LoadFile(xmlFile);
@ -40,20 +41,33 @@ void Level::load() {
printf("Could not open Compositions!\n"); printf("Could not open Compositions!\n");
exit(-1); exit(-1);
} }
XMLElement* thisComposition = compositions->FirstChildElement("composition"); XMLElement* thisComposition = doc->FirstChildElement("composition");
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement()){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
int thisType; int thisType;
thisComposition->QueryIntAttribute("typeID", &thisType); thisComposition->QueryIntAttribute("typeID", &thisType);
if(thisType == type){ XMLElement* compositionType = compositions->FirstChildElement("composition");
... for(; compositionType; compositionType=compositionType->NextSiblingElement("composition")){
int compositionID;
compositionType->QueryIntAttribute("typeID", &compositionID);
if(thisType == compositionID){
XMLElement* object = compositionType->FirstChildElement("object");
for(; object; object=object->NextSiblingElement("object")){
}
XMLElement* light = compositionType->FirstChildElement("light");
for(; light; light=light->NextSiblingElement("light")){
}
//Model model = Model("MarbleSmooth.obj", 0.75f);
} }
} }
*/ }
//add player //add player
Model model = Model("MarbleSmooth.obj", 0.75f); Model marbleModel = Model("MarbleSmooth.obj", 0.75f);
Material material = Material("marbleTexture_small.png", 0.1f, 0.5f, 0.5f, 3.0f); Material marbleMaterial = Material("marbleTexture_small.png", 0.1f, 0.5f, 0.5f, 3.0f);
Object* object = new Object(model, material, glm::vec3(2.0f, 10.0f, 2.0f), Object* object = new Object(marbleModel, marbleMaterial, glm::vec3(2.0f, 10.0f, 2.0f),
glm::vec3(0.0f, 0.0f, 0.0f)); glm::vec3(0.0f, 0.0f, 0.0f));
objects.push_back(object); objects.push_back(object);
physicObjects.push_back(object); physicObjects.push_back(object);

View File

@ -9,7 +9,7 @@
#include "material.hh" #include "material.hh"
#include "camera.hh" #include "camera.hh"
#include "physics.hh" #include "physics.hh"
#include "converter/tinyxml2.hh" #include "tinyxml2.hh"
class Level { class Level {
public: public:

2258
tinyxml2.cc Executable file

File diff suppressed because it is too large Load Diff

2091
tinyxml2.hh Executable file

File diff suppressed because it is too large Load Diff