CGMeshMD5::CModel * CGmResMan::NewModelMD5( const char *pcFileNameMesh, const CArray<CStr> &roArrFileNameAnim, bool bTexSmooth ) { CGMeshMD5::CModel *poModel = 0; CStr oFileEntry( pcFileNameMesh ); for( unsigned int i=0; i<roArrFileNameAnim.GetSize(); ++i ) { oFileEntry += "&"; oFileEntry += roArrFileNameAnim[i]; } poModel = (CGMeshMD5::CModel *)FindFileEntry( oFileEntry.GetData() ); if( !poModel ) { poModel = new CGMeshMD5::CModel; //if( !MakeModelMD5_( poModel, pcFileNameMesh, roArrFileNameAnim, bTexSmooth ) ) //{ // ERR( "ModelMD5 %s.\n", pcFileNameMesh ); // DELETE_INSTANCE( poModel ); // return 0; //} { if( !poModel->InitModel( DATA_DIR + /*"model/" +*/ pcFileNameMesh ) ) { ERR( "ModelMD5 %s.\n", pcFileNameMesh ); DELETE_INSTANCE( poModel ); return 0; } CArray<CGTex2 *> oArrTex; const unsigned int uiMeshCount = poModel->GetMeshCount(); oArrTex.Resize( uiMeshCount ); oArrTex.Fill( 0 ); unsigned int i = uiMeshCount; while( i ) { --i; const char *pcMaterialName = poModel->GetMaterialName( i ); if( pcMaterialName ) { oArrTex[i] = NewTexture( pcMaterialName, bTexSmooth, false ); } } const unsigned int uiAnimCount = roArrFileNameAnim.GetSize(); for( unsigned int uiAnim=0; uiAnim<uiAnimCount; ++uiAnim ) { LOG( "Loading %s.\n", roArrFileNameAnim[uiAnim].GetData() ); if( poModel->InsertNewAnim( DATA_DIR + /*"model/" +*/ roArrFileNameAnim[uiAnim] ) ) { for( unsigned int i=0; i<uiMeshCount; ++i ) { if( oArrTex.GetSize() >= i && oArrTex[i] ) { poModel->SetTex( i, uiAnim, oArrTex[i] ); } } } } poModel->SetAnim( poModel->GetAnimCount() - 1 ); } m_oArrModelMD5.Append( poModel ); NewFileEntry( oFileEntry.GetData(), poModel ); } else { LOG( "ModelMD5 skipped: %s.\n", pcFileNameMesh ); } //else //{ // // copy with shared data // poModel = new CGMeshMD5::CModel( *poModel ); // // m_oArrModelMD5.Append( poModel ); // LOG( "ModelMD5 copied: %s.\n", pcFileNameMesh ); //} return poModel; }