Added the option to define initial position constraints in the Level.xml file.
This commit is contained in:
parent
10017bb855
commit
d26722595e
@ -98,14 +98,32 @@ Converter::Converter(std::string level){
|
|||||||
|
|
||||||
//Create global physics parameters
|
//Create global physics parameters
|
||||||
XMLElement* physics = doc->NewElement("physics");
|
XMLElement* physics = doc->NewElement("physics");
|
||||||
XMLElement* friction = doc->NewElement("friction");
|
XMLElement* playerFriction = doc->NewElement("friction");
|
||||||
XMLElement* strength = doc->NewElement("strength");
|
XMLElement* playerStrength = doc->NewElement("strength");
|
||||||
friction->SetText("0.9");
|
playerFriction->SetText("0.9");
|
||||||
strength->SetText("100.0");
|
playerStrength->SetText("100.0");
|
||||||
physics->InsertEndChild(friction);
|
physics->InsertEndChild(playerFriction);
|
||||||
physics->InsertEndChild(strength);
|
physics->InsertEndChild(playerStrength);
|
||||||
doc->InsertEndChild(physics);
|
doc->InsertEndChild(physics);
|
||||||
|
|
||||||
|
//create positionConstraint Dummy
|
||||||
|
XMLElement* positionConstraint = doc->NewElement("positionConstraint");
|
||||||
|
XMLElement* positionConstraintObjectNum = doc->NewElement("objectNum");
|
||||||
|
XMLElement* positionConstraintXPos = doc->NewElement("xPosition");
|
||||||
|
XMLElement* positionConstraintYPos = doc->NewElement("yPosition");
|
||||||
|
XMLElement* positionConstraintZPos = doc->NewElement("zPosition");
|
||||||
|
XMLElement* positionConstraintStrength = doc->NewElement("strength");
|
||||||
|
positionConstraintObjectNum->SetText("0");
|
||||||
|
positionConstraintXPos->SetText("0.0");
|
||||||
|
positionConstraintYPos->SetText("0.0");
|
||||||
|
positionConstraintZPos->SetText("0.0");
|
||||||
|
positionConstraintStrength->SetText("100.0");
|
||||||
|
positionConstraint->InsertEndChild(positionConstraintObjectNum);
|
||||||
|
positionConstraint->InsertEndChild(positionConstraintXPos);
|
||||||
|
positionConstraint->InsertEndChild(positionConstraintYPos);
|
||||||
|
positionConstraint->InsertEndChild(positionConstraintZPos);
|
||||||
|
positionConstraint->InsertEndChild(positionConstraintStrength);
|
||||||
|
doc->InsertEndChild(positionConstraint);
|
||||||
}else{
|
}else{
|
||||||
dst << src.rdbuf();
|
dst << src.rdbuf();
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
|
24
level.cc
24
level.cc
@ -387,8 +387,32 @@ void Level::load() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}//triggers
|
||||||
|
|
||||||
|
//load positionConstraints
|
||||||
|
composition = doc->FirstChildElement("composition");
|
||||||
|
for(; composition; composition=composition->NextSiblingElement("composition")){
|
||||||
|
XMLElement* positionConstraint = composition->FirstChildElement("positionConstraint");
|
||||||
|
for(; positionConstraint; positionConstraint=positionConstraint->NextSiblingElement("positionConstraint")){
|
||||||
|
float xPos, yPos, zPos, strength;
|
||||||
|
int objectNum, idGreen, idBlue, objectIndex;
|
||||||
|
errorCheck(positionConstraint->FirstChildElement("xPosition")->QueryFloatText(&xPos));
|
||||||
|
errorCheck(positionConstraint->FirstChildElement("yPosition")->QueryFloatText(&yPos));
|
||||||
|
errorCheck(positionConstraint->FirstChildElement("zPosition")->QueryFloatText(&zPos));
|
||||||
|
errorCheck(positionConstraint->FirstChildElement("strength")->QueryFloatText(&strength));
|
||||||
|
errorCheck(positionConstraint->FirstChildElement("objectNum")->QueryIntText(&objectNum));
|
||||||
|
errorCheck(composition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
|
||||||
|
errorCheck(composition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
||||||
|
for (unsigned int i = 0; i<objectIdentifiers.size(); i++){
|
||||||
|
if (objectIdentifiers[i][1]==idGreen && objectIdentifiers[i][2]==idBlue && objectIdentifiers[i][3]==objectNum){
|
||||||
|
objectIndex = objectIdentifiers[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glm::vec3 position = glm::vec3(xPos, yPos, zPos);
|
||||||
|
physics.addPositionConstraint(objectIndex, strength, position);
|
||||||
|
}
|
||||||
|
}//positionConstraints
|
||||||
|
}
|
||||||
|
|
||||||
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
||||||
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
|
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user