本文整理汇总了C++中Compound::loadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ Compound::loadAttributes方法的具体用法?C++ Compound::loadAttributes怎么用?C++ Compound::loadAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compound
的用法示例。
在下文中一共展示了Compound::loadAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadObjects
bool SceneLoader::loadObjects(){ //Falta condicao para nao se repetirem ID's <--
TiXmlElement* objectElement = root->FirstChildElement("objects");
if(objectElement == NULL)
{
cout << "> Error: objects tag not found!" << endl;
return false;
}
TiXmlElement* objectChild = objectElement->FirstChildElement();
int i=1;
for( ; objectChild != NULL; objectChild = objectChild->NextSiblingElement()){
if(i <= maxObjects){
if(!objectChild->Attribute("type")){
cout << " > Error: Could not load type of an Object!" << endl; //Sair imediatamente
return NULL;
}
string type = objectChild->Attribute("type");
if(type == "compound"){ //Tipo composto
Compound* compound = new Compound();
if((compound->loadAttributes(objectChild)) == NULL)
return false;
if(sceneManager->getObjectbyID(objectChild->Attribute("id")) != NULL){ //Objecto já existente no sistema
cout << " > Warning: object with ID " << objectChild->Attribute("id") << " is already in the system!!" << endl;
continue;
}
string material;
if((material = compound->loadMaterial(objectChild)).empty()) return NULL;
if(material != "null"){
Material* mat = this->sceneManager->getMaterialbyID(material);
if(mat == NULL){
cout << " > Error: Material with ID: " << material << " not found for Object: " << compound->id << endl;
return false;
}
compound->material = mat;
} else{
Material* mat = new Material();
mat->id = "null";
compound->material = mat;
}
string texture;
if((texture = compound->loadTexture(objectChild)).empty()) return NULL;
if(texture == "clear"){
Texture* text = new Texture();
text->id = "clear";
compound->texture = text;
} else if(texture != "null"){
Texture* text = this->sceneManager->getTexturebyID(texture);
if(text == NULL){
cout << " > Error: Texture with ID: " << texture << " not found for Object: " << compound->id << endl;
return false;
}
compound->texture = text;
} else{
Texture* text = new Texture();
text->id = "null";
compound->texture = text;
}
if(objectChild->Attribute("id") == sceneManager->globals->root){
sceneManager->root = compound;
}
sceneManager->addObject(compound);
} else if(type == "simple"){ //Tipo simples
Simple* simple = new Simple();
if((simple->loadAttributes(objectChild)) == NULL)
return false;
if(sceneManager->getObjectbyID(objectChild->Attribute("id")) != NULL) //Objecto já existente no sistema
{
cout << " > Warning: object with ID " << objectChild->Attribute("id") << " is already in the system!!" << endl;
continue;
}
string material;
if((material = simple->loadMaterial(objectChild)).empty()) return NULL;
if(material != "null"){
Material* mat = this->sceneManager->getMaterialbyID(material);
if(mat == NULL){
cout << " > Error: Material with ID: " << material << " not found for Object: " << simple->id << endl;
return false;
}
simple->material = mat;
} else{
Material* mat = new Material();
mat->id = "null";
simple->material = mat;
}
string texture;
if((texture = simple->loadTexture(objectChild)).empty()) return NULL;
if(texture == "clear"){
Texture* text = new Texture();
text->id = "clear";
simple->texture = text;
} else if(texture != "null"){
Texture* text = this->sceneManager->getTexturebyID(texture);
if(text == NULL){
//.........这里部分代码省略.........