void TSRModelExporterDOM::CalculateFixupMatrixDOM( domCOLLADA& _colladaRoot ) { /// read asset data, here i can know if the up direction is Y or Z.. domAsset* pAsset = _colladaRoot.getAsset(); domUp_axis upAxis = UP_AXIS_Y_UP; if ( pAsset ) { domAsset::domUp_axisRef upAxisRef = pAsset->getUp_axis(); upAxis = upAxisRef->getValue(); } m_FixupMatrix.MakeIdent(); TSRVector3 X_Axis = m_FixupMatrix.GetLocalX(); TSRVector3 Z_Axis = m_FixupMatrix.GetLocalZ(); // std::swap( X_Axis, Z_Axis ); m_FixupMatrix.GetLocalX() = X_Axis; m_FixupMatrix.GetLocalZ() = -Z_Axis; if( upAxis == UP_AXIS_Z_UP ) { TSRMatrix4 Zupmatrix = TSRMatrix4::Identity; Zupmatrix.GetLocalX().Assign( 0.0f, 1.0f, 0.0f ); Zupmatrix.GetLocalY().Assign( -1.0f, 0.0f, 0.0f ); m_FixupMatrix = m_FixupMatrix * Zupmatrix; } }
/// 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 ] ); } }
void TSRModelExporterDOM::ProcessImagesLibraryDOM( domCOLLADA& _colladaRoot ) { // see if there are any images which will be used as textures.. domLibrary_images_Array allImageLibraries = _colladaRoot.getLibrary_images_array(); for ( unsigned int i = 0; i < allImageLibraries.getCount(); i++ ) { domLibrary_images* pCurrImagesLibrary = allImageLibraries[ i ]; if ( pCurrImagesLibrary ) { domImage_Array& images_nodes = pCurrImagesLibrary->getImage_array(); for ( unsigned int j = 0; j < images_nodes.getCount(); j++ ) { domImage* currImage = images_nodes[ j ]; m_DomImages.push_back( currImage ); //domImage::domInit_fromRef initFromRef = currImage->getInit_from(); domImage::domInit_from* initFrom = currImage->getInit_from(); daeElement* pRefElement = initFrom->getDescendant( "ref" ); string strTemp; if ( pRefElement ) { pRefElement->getCharData( strTemp ); TSRModelTexture newTwisterTexture; memset( &newTwisterTexture, 0, sizeof( TSRModelTexture) ) ; sscanf( strTemp.c_str(), "%s", newTwisterTexture ); m_TwisterImages.push_back( newTwisterTexture ); } else { initFrom->getCharData( strTemp ); TSRModelTexture newTwisterTexture; memset( &newTwisterTexture, 0, sizeof( TSRModelTexture) ) ; assert( ( strTemp.length() < 64 ) && "Texture filename is too long, consider using relative paths" ); if ( strTemp.length() >= 64 ) { CookAssetError( "Texture filename is too long, consider using relative paths" ); } sscanf( strTemp.c_str(), "%s", newTwisterTexture.m_Name ); m_TwisterImages.push_back( newTwisterTexture ); } } } } ExportModelTextures(); }
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; } } } } }