/// process all materials in the library of materials at once void TSRModelExporterDOM::ProcessMaterialsLibraryDOM( domCOLLADA& _colladaRoot ) { domLibrary_materials* materials_library = daeSafeCast<domLibrary_materials>( _colladaRoot.getDescendant( "library_materials" ) ); domMaterial_Array& materials_array = materials_library->getMaterial_array(); for ( unsigned int i = 0; i < materials_array.getCount(); i++ ) { ProcessMaterialDOM( materials_array[ i ] ); } }
std::string imagePathFromSampler(domCOLLADA& root, const std::string& sampler_name) { domLibrary_effects* e = daeSafeCast<domLibrary_effects>(root.getDescendant(COLLADA_ELEMENT_LIBRARY_EFFECTS)); std::string image_name; if(e) { domEffect_Array& ea = e->getEffect_array(); for (size_t i = 0; i < ea.getCount(); i++) { xsID s = ea[i]->getId(); domFx_profile_abstract_Array & aaa = ea[i]->getFx_profile_abstract_array(); FIXME(Опасное упрощение) domProfile_COMMON *pc = daeSafeCast< domProfile_COMMON >( aaa[0] ); //const domImage_Array& ia = pc->getImage_array(); //for (size_t j = 0; j < ia.getCount(); j++) //{ // xsNCName s = ia[j]->getName(); // std::string path = ia[j]->getInit_from()->getValue().pathFile(); // int jj = 1; //} const domCommon_newparam_type_Array & npa = pc->getNewparam_array(); std::string surface_name; for (size_t j = 0; j < npa.getCount(); j++) { xsNCName sid = npa[j]->getSid(); domFx_sampler2D_commonRef sampl = npa[j]->getSampler2D(); if(sampl && sampler_name==sid) { const domFx_sampler2D_common_complexType::domSourceRef src = sampl->getSource(); surface_name = src->getValue(); break; } } for (size_t j = 0; j < npa.getCount(); j++) { xsNCName sid = npa[j]->getSid(); domFx_surface_commonRef sur = npa[j]->getSurface(); if(sur && surface_name==sid) { domFx_surface_init_commonRef sir = sur->getFx_surface_init_common(); const domFx_surface_init_from_common_Array & aaaa = sir->getInit_from_array(); FIXME(Опасное упрощение) for (size_t jj = 0; jj < aaaa.getCount(); jj++) { const xsIDREF & vv = aaaa[jj]->getValue(); image_name = vv.getID(); break; } } } } }