char HAttributeGroup::load(AAttributeWrap & wrap) { int t = 0; readIntAttr(".attr_typ", &t); if(t == AAttribute::aNumeric) { int tn = 0; if(hasNamedAttr(".num_typ")) { readIntAttr(".num_typ", &tn); loadNumeric( wrap.createNumeric(tn) ); } } else if(t == AAttribute::aEnum) { loadEnum( wrap.createEnum() ); } else if(t == AAttribute::aString) { loadString( wrap.createString() ); } else if(t == AAttribute::aCompound) { loadCompound( wrap.createCompound() ); } AAttribute * data = wrap.attrib(); if(!data) return 0; std::string lnm; readStringAttr(".longname", lnm); data->setLongName(lnm); data->setShortName(lastName()); return 1; }
bool SceneLoader::loadScene() { sgxElement = doc.FirstChildElement( "sgx" ); globalsElement = sgxElement->FirstChildElement( "globals" ); viewElement = sgxElement->FirstChildElement( "view" ); illuminationElement = sgxElement->FirstChildElement("illumination"); texturesElement = sgxElement->FirstChildElement("textures"); objectsElement = sgxElement->FirstChildElement("objects"); materialsElement = sgxElement->FirstChildElement("materials"); Material * mat; Texture * tex; // Inicialização // Um exemplo de um conjunto de nós bem conhecidos e obrigatórios if(sgxElement == NULL) { cout << "Bloco sgx nao encontrado\n"; system("pause"); return false; } if(globalsElement != NULL) { if(!loadGlobals()) return false; } else { cout<<"Bloco globals nao encontrado\n"; system("pause"); return false; } if (viewElement != NULL) { if(!loadView()) return false; } else { cout << "Bloco view nao encontrado\n"; system("pause"); return false; } if(illuminationElement != NULL) { if(!loadIllumination()) return false; } else { cout<<"Bloco illumination nao econtrado\n"; system("pause"); return false; } if(texturesElement != NULL) { if(!loadTextures()) return false; } else { cout<<"Bloco textures nao econtrado\n"; system("pause"); return false; } if(materialsElement != NULL) { if(!loadMaterials()) return false; } else { cout<<"Bloco materials nao econtrado\n"; system("pause"); return false; } if(objectsElement!=NULL) { if(!loadObjects()) return false; if(!loadCompound()) return false; root_object=findObject(global.root); if(root_object==NULL) return false; if(root_object->mat_id=="null") mat=this->mat_base; else { mat=findMaterial(root_object->mat_id); if(mat==NULL) return false; } if(!aplicaMaterials(root_object, mat)) return false; if(root_object->tex_id=="null"||root_object->tex_id=="clear") tex=this->no_tex; else { tex=findTexture(root_object->tex_id); if(tex==NULL) return false; } if(!aplicaTextures(root_object, tex)) return false; } else { cout<<"Bloco objects nao econtrado\n"; system("pause"); return false; } return true; }