diff --git a/Levels/ObjectSetups/Level1.xml b/Levels/ObjectSetups/Level1.xml
index 3c74fa3..054662c 100644
--- a/Levels/ObjectSetups/Level1.xml
+++ b/Levels/ObjectSetups/Level1.xml
@@ -10,6 +10,16 @@
1
5
20
+
+ -
+ 0.0
+ 0.0
+ 0.0
+ 1.0
+ false
+ 1
+ -
+
@@ -19,11 +29,21 @@
0.0
false
5.500000
- 1.0
+ 0.0
-5.500000
1
4
40
+
+ -
+ 0.0
+ 0.0
+ 0.0
+ 1.0
+ false
+ 1
+ -
+
@@ -38,6 +58,16 @@
1
3
85
+
+ -
+ 0.0
+ 0.0
+ 0.0
+ 1.0
+ false
+ 1
+ -
+
@@ -47,11 +77,21 @@
0.0
false
-1.500000
- 1.0
+ 0.0
-4.500000
1
2
40
+
+ -
+ 0.0
+ 0.0
+ 0.0
+ 1.0
+ false
+ 1
+ -
+
@@ -61,11 +101,21 @@
0.0
false
-4.500000
- 1.0
+ 0.0
1.500000
1
1
40
+
+ -
+ 0.0
+ 0.0
+ 0.0
+ 1.0
+ false
+ 1
+ -
+
@@ -94,29 +144,3 @@
skydome.png
-
-
- bla
- 25.0
- 14.0
- 5.5
- 5.0
- false
- 1
- 5
- 0
- 0
-
-
-
- -
- 0.0
- 0.0
- 0.0
- 1.0
- false
- 0
- 0
- 0
- -
-
diff --git a/converter/converter.cc b/converter/converter.cc
index 725f2d4..52e03ab 100644
--- a/converter/converter.cc
+++ b/converter/converter.cc
@@ -30,7 +30,7 @@ Converter::Converter(std::string level){
std::string backupXML = "../Levels/ObjectSetups/BackupLevel" + level + ".xml";
std::ifstream src(xmlFile, std::ios::binary);
std::ofstream dst(backupXML, std::ios::binary);
- dst << src.rdbuf();
+
//Load the Level xml file
nextID.push_back(1);
@@ -95,41 +95,8 @@ Converter::Converter(std::string level){
doc->InsertEndChild(fogColour);
doc->InsertEndChild(directionalLight);
doc->InsertEndChild(skydome);
-
- //Create a Dummy-trigger
- XMLElement* trigger = doc->NewElement("trigger");
- doc->InsertEndChild(trigger);
- XMLElement* name = doc->NewElement("name");
- XMLElement* xPosition = doc->NewElement("xPosition");
- XMLElement* yPosition = doc->NewElement("yPosition");
- XMLElement* zPosition = doc->NewElement("zPosition");
- XMLElement* distance = doc->NewElement("distance");
- XMLElement* isBiggerThan = doc->NewElement("isBiggerThan");
- XMLElement* idGreen = doc->NewElement("idGreen");
- XMLElement* idBlue = doc->NewElement("idBlue");
- XMLElement* objectNum = doc->NewElement("objectNum");
- XMLElement* functionPointer = doc->NewElement("functionPointer");
- name->SetText("-");
- xPosition->SetText("0.0");
- yPosition->SetText("0.0");
- zPosition->SetText("0.0");
- distance->SetText("1.0");
- isBiggerThan->SetText("false");
- idGreen->SetText("0");
- idBlue->SetText("0");
- objectNum->SetText("1");
- functionPointer->SetText("-");
- trigger->InsertEndChild(name);
- trigger->InsertEndChild(xPosition);
- trigger->InsertEndChild(yPosition);
- trigger->InsertEndChild(zPosition);
- trigger->InsertEndChild(distance);
- trigger->InsertEndChild(isBiggerThan);
- trigger->InsertEndChild(idGreen);
- trigger->InsertEndChild(idBlue);
- trigger->InsertEndChild(objectNum);
- trigger->InsertEndChild(functionPointer);
}else{
+ dst << src.rdbuf();
XMLElement* thisComposition = doc->FirstChildElement("composition");
int idGreen, idBlue;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
@@ -189,6 +156,39 @@ std::vector Converter::newComposition(int type, float posX, float posZ){
newComposition->InsertFirstChild(xRot);
newComposition->InsertFirstChild(scale);
+ //Create a Dummy-trigger
+ XMLElement* trigger = doc->NewElement("trigger");
+ newComposition->InsertEndChild(trigger);
+ XMLElement* name = doc->NewElement("name");
+ XMLElement* xPosition = doc->NewElement("xPosition");
+ XMLElement* yPosition = doc->NewElement("yPosition");
+ XMLElement* zPosition = doc->NewElement("zPosition");
+ XMLElement* distance = doc->NewElement("distance");
+ XMLElement* isBiggerThan = doc->NewElement("isBiggerThan");
+ XMLElement* objectNum = doc->NewElement("objectNum");
+ XMLElement* functionPointer = doc->NewElement("functionPointer");
+ //XMLElement* targetIdGreen = doc->NewElement("targetIdGreen");
+ //XMLElement* targetIdBlue = doc->NewElement("targetIdBlue");
+ name->SetText("-");
+ xPosition->SetText("0.0");
+ yPosition->SetText("0.0");
+ zPosition->SetText("0.0");
+ distance->SetText("1.0");
+ isBiggerThan->SetText("false");
+ objectNum->SetText("1");
+ functionPointer->SetText("-");
+ //targetIdGreen->SetText("0");
+ //targetIdBlue->SetText("0");
+ trigger->InsertEndChild(name);
+ trigger->InsertEndChild(xPosition);
+ trigger->InsertEndChild(yPosition);
+ trigger->InsertEndChild(zPosition);
+ trigger->InsertEndChild(distance);
+ trigger->InsertEndChild(isBiggerThan);
+ trigger->InsertEndChild(objectNum);
+ trigger->InsertEndChild(functionPointer);
+ //trigger->InsertEndChild(targetIdGreen);
+ //trigger->InsertEndChild(targetIdBlue);
std::vector ret = nextID;
nextID[1] += 1;
if (nextID[1] == 255){
diff --git a/level.cc b/level.cc
index 512a27d..560937b 100644
--- a/level.cc
+++ b/level.cc
@@ -270,40 +270,43 @@ void Level::load() {
}//iterating over all compositions in Level.xml
//load triggers
- XMLElement* xmlTrigger = doc->FirstChildElement("trigger");
- for(; xmlTrigger; xmlTrigger=xmlTrigger->NextSiblingElement("trigger")){
- const char* charName = xmlTrigger->FirstChildElement("name")->GetText();
- if(charName == NULL){
- printf("XMLError: No name found for a trigger.\n");
- }
- std::string name = charName;
- if (name.compare("-") != 0){
- float xPos, yPos, zPos, distance;
- glm::vec3 position;
- bool isBigger;
- int idGreen, idBlue, objectNum, functionPointer_int;
- errorCheck(xmlTrigger->FirstChildElement("xPosition")->QueryFloatText(&xPos));
- errorCheck(xmlTrigger->FirstChildElement("yPosition")->QueryFloatText(&yPos));
- errorCheck(xmlTrigger->FirstChildElement("zPosition")->QueryFloatText(&zPos));
- errorCheck(xmlTrigger->FirstChildElement("distance")->QueryFloatText(&distance));
- position = glm::vec3(xPos, yPos, zPos);
- errorCheck(xmlTrigger->FirstChildElement("isBiggerThan")->QueryBoolText(&isBigger));
- errorCheck(xmlTrigger->FirstChildElement("idGreen")->QueryIntText(&idGreen));
- errorCheck(xmlTrigger->FirstChildElement("idBlue")->QueryIntText(&idBlue));
- errorCheck(xmlTrigger->FirstChildElement("objectNum")->QueryIntText(&objectNum));
- Object* object=0;
- for (unsigned int i = 0; iFirstChildElement("composition");
+ for(; composition; composition=composition->NextSiblingElement("composition")){
+ XMLElement* xmlTrigger = composition->FirstChildElement("trigger");
+ for(; xmlTrigger; xmlTrigger=xmlTrigger->NextSiblingElement("trigger")){
+ const char* charName = xmlTrigger->FirstChildElement("name")->GetText();
+ if(charName == NULL){
+ printf("XMLError: No name found for a trigger.\n");
+ }
+ std::string name = charName;
+ if (name.compare("-") != 0){
+ float xPos, yPos, zPos, distance;
+ glm::vec3 position;
+ bool isBigger;
+ int idGreen, idBlue, objectNum, functionPointer_int;
+ errorCheck(xmlTrigger->FirstChildElement("xPosition")->QueryFloatText(&xPos));
+ errorCheck(xmlTrigger->FirstChildElement("yPosition")->QueryFloatText(&yPos));
+ errorCheck(xmlTrigger->FirstChildElement("zPosition")->QueryFloatText(&zPos));
+ errorCheck(xmlTrigger->FirstChildElement("distance")->QueryFloatText(&distance));
+ position = glm::vec3(xPos, yPos, zPos);
+ errorCheck(xmlTrigger->FirstChildElement("isBiggerThan")->QueryBoolText(&isBigger));
+ errorCheck(composition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
+ errorCheck(composition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
+ errorCheck(xmlTrigger->FirstChildElement("objectNum")->QueryIntText(&objectNum));
+ Object* object=0;
+ for (unsigned int i = 0; iFirstChildElement("functionPointer")->QueryIntText(&functionPointer_int));
+ if (object != 0) {
+ Trigger trigger = Trigger(position, distance, isBigger, object, functionPointer_int, this);
+ triggers.push_back(trigger);
+ }
+ else {
+ printf("Trigger object not found.\n");
}
- }
- errorCheck(xmlTrigger->FirstChildElement("functionPointer")->QueryIntText(&functionPointer_int));
- if (object != 0) {
- Trigger trigger = Trigger(position, distance, isBigger, object, functionPointer_int, this);
- triggers.push_back(trigger);
- }
- else {
- printf("Trigger object not found.\n");
}
}
}