diff --git a/source/terrain/ObjectEntry.cpp b/source/terrain/ObjectEntry.cpp index 5271d31899..4910a017bf 100755 --- a/source/terrain/ObjectEntry.cpp +++ b/source/terrain/ObjectEntry.cpp @@ -61,22 +61,30 @@ bool CObjectEntry::BuildModel() CStr texturefilename(m_TextureName); m_Model->SetTexture(CTexture((const char*) texturefilename)); - for( uint t = 0; t < m_Animations.size(); t++ ) { if( m_Animations[t].m_FileName.Length() > 0 ) { CStr animfilename( "mods\\official\\" ); animfilename += m_Animations[t].m_FileName; try { m_Animations[t].m_AnimData = CSkeletonAnim::Load( animfilename ); } catch( ... ) { m_Animations[t].m_AnimData = NULL; } if( m_Animations[t].m_AnimName.LowerCase() == CStr( "idle" ) ) m_IdleAnim = m_Animations[t].m_AnimData; if( m_Animations[t].m_AnimName.LowerCase() == CStr( "walk" ) ) m_WalkAnim = m_Animations[t].m_AnimData; } } m_Model->SetAnimation( m_IdleAnim ); /* - if (m_Animations.size()) { - if (m_Animations[0].m_FileName.Length()>0) { - CStr animfilename("mods\\official\\"); - animfilename+=m_Animations[0].m_FileName; - - try { - CSkeletonAnim* anim=CSkeletonAnim::Load((const char*) animfilename); - m_Model->SetAnimation(anim); - } catch (...) { - m_Model->SetAnimation(0); + + for( uint t = 0; t < m_Animations.size(); t++ ) + { + if( m_Animations[t].m_FileName.Length() > 0 ) + { + CStr animfilename( "mods\\official\\" ); + animfilename += m_Animations[t].m_FileName; + try + { + m_Animations[t].m_AnimData = CSkeletonAnim::Load( animfilename ); } + catch( ... ) + { + m_Animations[t].m_AnimData = NULL; + } + if( m_Animations[t].m_AnimName.LowerCase() == CStr( "idle" ) ) + m_IdleAnim = m_Animations[t].m_AnimData; + if( m_Animations[t].m_AnimName.LowerCase() == CStr( "walk" ) ) + m_WalkAnim = m_Animations[t].m_AnimData; } } - */ - // rebuild model bounds // janwas: WTF? sign mismatch warning on this line? + m_Model->SetAnimation( m_IdleAnim ); + + // rebuild model bounds m_Model->CalcBounds(); // replace any units using old model to now use new model @@ -84,12 +92,7 @@ bool CObjectEntry::BuildModel() for (uint i=0;im_Model->GetModelDef()==oldmodel) { units[i]->m_Model->InitModel(m_Model->GetModelDef()); - /* - CSkeletonAnim* anim=m_Model->GetAnimation(); - if (anim) { - units[i]->m_Model->SetAnimation(anim); - } */ } } @@ -98,7 +101,17 @@ bool CObjectEntry::BuildModel() return true; } -CSkeletonAnim* CObjectEntry::GetNamedAnimation( CStr animationName ) { for( int t = 0; t < m_Animations.size(); t++ ) { if( m_Animations[t].m_AnimName == animationName ) return( m_Animations[t].m_AnimData ); } return( NULL ); } + +CSkeletonAnim* CObjectEntry::GetNamedAnimation( CStr animationName ) +{ + for( uint t = 0; t < m_Animations.size(); t++ ) + { + if( m_Animations[t].m_AnimName == animationName ) + return( m_Animations[t].m_AnimData ); + } + return( NULL ); +} + bool CObjectEntry::Load(const char* filename) { bool parseOK = false; diff --git a/source/terrain/ObjectEntry.h b/source/terrain/ObjectEntry.h index 443fe41e45..c012262a08 100755 --- a/source/terrain/ObjectEntry.h +++ b/source/terrain/ObjectEntry.h @@ -13,7 +13,8 @@ class CObjectEntry public: struct Anim { CStr m_AnimName; - CStr m_FileName; CSkeletonAnim* m_AnimData; //Pending + CStr m_FileName; + CSkeletonAnim* m_AnimData; //Pending }; public: @@ -32,7 +33,13 @@ public: // model name CStr m_ModelName; // animations - std::vector m_Animations; CSkeletonAnim* m_IdleAnim; CSkeletonAnim* m_WalkAnim; CSkeletonAnim* m_DeathAnim; CSkeletonAnim* m_MeleeAnim; CSkeletonAnim* m_RangedAnim; CSkeletonAnim* GetNamedAnimation( CStr animationName ); + std::vector m_Animations; +CSkeletonAnim* m_IdleAnim; +CSkeletonAnim* m_WalkAnim; +CSkeletonAnim* m_DeathAnim; +CSkeletonAnim* m_MeleeAnim; +CSkeletonAnim* m_RangedAnim; +CSkeletonAnim* GetNamedAnimation( CStr animationName ); // object space bounds of model // CBound m_Bound; // corresponding model