Moved triggers into compositions.
This commit is contained in:
parent
d91d5e2028
commit
cb3ccb3668
@ -10,6 +10,16 @@
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>5</idBlue>
|
||||
<typeID>20</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>1</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<composition>
|
||||
@ -19,11 +29,21 @@
|
||||
<zRot>0.0</zRot>
|
||||
<manualPos>false</manualPos>
|
||||
<xPos>5.500000</xPos>
|
||||
<yOffset>1.0</yOffset>
|
||||
<yOffset>0.0</yOffset>
|
||||
<zPos>-5.500000</zPos>
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>4</idBlue>
|
||||
<typeID>40</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>1</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<composition>
|
||||
@ -38,6 +58,16 @@
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>3</idBlue>
|
||||
<typeID>85</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>1</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<composition>
|
||||
@ -47,11 +77,21 @@
|
||||
<zRot>0.0</zRot>
|
||||
<manualPos>false</manualPos>
|
||||
<xPos>-1.500000</xPos>
|
||||
<yOffset>1.0</yOffset>
|
||||
<yOffset>0.0</yOffset>
|
||||
<zPos>-4.500000</zPos>
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>2</idBlue>
|
||||
<typeID>40</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>1</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<composition>
|
||||
@ -61,11 +101,21 @@
|
||||
<zRot>0.0</zRot>
|
||||
<manualPos>false</manualPos>
|
||||
<xPos>-4.500000</xPos>
|
||||
<yOffset>1.0</yOffset>
|
||||
<yOffset>0.0</yOffset>
|
||||
<zPos>1.500000</zPos>
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>1</idBlue>
|
||||
<typeID>40</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>1</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<ambientLight>
|
||||
@ -94,29 +144,3 @@
|
||||
<skydome>
|
||||
<texture>skydome.png</texture>
|
||||
</skydome>
|
||||
|
||||
<trigger>
|
||||
<name>bla</name>
|
||||
<xPosition>25.0</xPosition>
|
||||
<yPosition>14.0</yPosition>
|
||||
<zPosition>5.5</zPosition>
|
||||
<distance>5.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<idGreen>1</idGreen>
|
||||
<idBlue>5</idBlue>
|
||||
<objectNum>0</objectNum>
|
||||
<functionPointer>0</functionPointer>
|
||||
</trigger>
|
||||
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<idGreen>0</idGreen>
|
||||
<idBlue>0</idBlue>
|
||||
<objectNum>0</objectNum>
|
||||
<functionPointer>-</functionPointer>
|
||||
</trigger>
|
||||
|
@ -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<int> 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<int> ret = nextID;
|
||||
nextID[1] += 1;
|
||||
if (nextID[1] == 255){
|
||||
|
69
level.cc
69
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; i<objectIdentifiers.size(); i++){
|
||||
if (objectIdentifiers[i][1]==idGreen && objectIdentifiers[i][2]==idBlue && objectIdentifiers[i][3]==objectNum){
|
||||
object = objects[objectIdentifiers[i][0]];
|
||||
XMLElement* composition = doc->FirstChildElement("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; i<objectIdentifiers.size(); i++){
|
||||
if (objectIdentifiers[i][1]==idGreen && objectIdentifiers[i][2]==idBlue && objectIdentifiers[i][3]==objectNum){
|
||||
object = objects[objectIdentifiers[i][0]];
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user