Implemented more of the loading from xml
This commit is contained in:
parent
f4529d1430
commit
4ab04faf68
55
level.cc
55
level.cc
@ -67,27 +67,56 @@ void Level::load() {
|
|||||||
int thisType = 0;
|
int thisType = 0;
|
||||||
error = thisComposition->FirstChildElement("typeID")->QueryIntText(&thisType);
|
error = thisComposition->FirstChildElement("typeID")->QueryIntText(&thisType);
|
||||||
errorCheck(error);
|
errorCheck(error);
|
||||||
XMLElement* compositionType = compositions->FirstChildElement("composition");
|
XMLElement* composition = compositions->FirstChildElement("composition");
|
||||||
for(; compositionType; compositionType=compositionType->NextSiblingElement("composition")){
|
for(; composition; composition=composition->NextSiblingElement("composition")){
|
||||||
int compositionID = 0;
|
int compositionType = 0;
|
||||||
error = compositionType->FirstChildElement("typeID")->QueryIntText(&compositionID);
|
error = composition->FirstChildElement("typeID")->QueryIntText(&compositionType);
|
||||||
errorCheck(error);
|
errorCheck(error);
|
||||||
if(thisType == compositionID){
|
if(thisType == compositionType){
|
||||||
XMLElement* object = compositionType->FirstChildElement("object");
|
XMLElement* object = composition->FirstChildElement("object");
|
||||||
for(; object; object=object->NextSiblingElement("object")){
|
for(; object; object=object->NextSiblingElement("object")){
|
||||||
const char* charModelPath = object->FirstChildElement("modelPath")->GetText();
|
const char* charModelPath = object->FirstChildElement("modelPath")->GetText();
|
||||||
if(charModelPath == NULL){
|
if(charModelPath == NULL){
|
||||||
printf("XMLError: No modelPath found.\n");
|
printf("XMLError: No modelPath found in object.\n");
|
||||||
}
|
}
|
||||||
std::string modelPath = charModelPath;
|
std::string modelPath = charModelPath;
|
||||||
float scale;
|
float scaleObj, scaleComp;
|
||||||
object->FirstChildElement("scale")->QueryFloatText(&scale);
|
object->FirstChildElement("scale")->QueryFloatText(&scaleObj);
|
||||||
//Model model = Model(modelPath, scale);
|
thisComposition->FirstChildElement("scale")->QueryFloatText(&scaleComp);
|
||||||
|
//Model model = Model(modelPath, scaleObj * scaleComp);
|
||||||
|
XMLElement* objectData = compositions->FirstChildElement("objectData");
|
||||||
|
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
|
||||||
|
const char* charDataModelPath = objectData->FirstChildElement("modelPath")->GetText();
|
||||||
|
if(charDataModelPath == NULL){
|
||||||
|
printf("XMLError: No modelPath found in objectData.\n");
|
||||||
|
}
|
||||||
|
std::string dataModelPath = charDataModelPath;
|
||||||
|
if(dataModelPath == modelPath){
|
||||||
|
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
||||||
|
objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor);
|
||||||
|
objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor);
|
||||||
|
objectData->FirstChildElement("specularFactor")->QueryFloatText(&specularFactor);
|
||||||
|
objectData->FirstChildElement("shininess")->QueryFloatText(&shininess);
|
||||||
|
const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
|
||||||
|
if(charTexturePath == NULL){
|
||||||
|
printf("XMLError: No texturePath found in objectData.\n");
|
||||||
|
}
|
||||||
|
std::string texturePath = charTexturePath;
|
||||||
|
//Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TODO calculate position and rotation
|
||||||
|
//Object* object = new Object(model, material, position, rotation);
|
||||||
|
//objects.push_back(object);
|
||||||
|
//TODO if object has physics: physicObjects.push_back(object);
|
||||||
|
//TODO add object to physics
|
||||||
|
//if(compositionType == 20){
|
||||||
|
// cameraCenter = object;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
XMLElement* light = compositionType->FirstChildElement("light");
|
XMLElement* light = composition->FirstChildElement("light");
|
||||||
for(; light; light=light->NextSiblingElement("light")){
|
for(; light; light=light->NextSiblingElement("light")){
|
||||||
|
//TODO add lights
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user