From 256436af403b2985e5daecc0e4fd67ed0eb494fb Mon Sep 17 00:00:00 2001 From: notpete Date: Thu, 20 May 2004 17:36:16 +0000 Subject: [PATCH] Adjusted animation loading to store animation with each ObjectEntry for future reference. This was SVN commit r243. --- source/terrain/ObjectEntry.cpp | 29 ++++++++++++++++++++--------- source/terrain/ObjectEntry.h | 4 +++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/source/terrain/ObjectEntry.cpp b/source/terrain/ObjectEntry.cpp index 71f348aefe..a79ca2f366 100755 --- a/source/terrain/ObjectEntry.cpp +++ b/source/terrain/ObjectEntry.cpp @@ -62,16 +62,27 @@ bool CObjectEntry::BuildModel() m_Model->SetTexture(CTexture((const char*) texturefilename)); + // animations? 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); + // yes; iterate through and load each one + for (uint i=0;i0) { + CStr animfilename("mods\\official\\"); + animfilename+=m_Animations[i].m_FileName; + + try { + m_Animations[i].m_AnimData=CSkeletonAnim::Load((const char*) animfilename); + } catch (...) { + m_Animations[i].m_AnimData=0; + } + } + } + + // set the first valid animation found as current + for (uint i=0;iSetAnimation(m_Animations[i].m_AnimData); + break; } } } diff --git a/source/terrain/ObjectEntry.h b/source/terrain/ObjectEntry.h index 318d47087f..19bf776a62 100755 --- a/source/terrain/ObjectEntry.h +++ b/source/terrain/ObjectEntry.h @@ -2,6 +2,7 @@ #define _OBJECTENTRY_H class CModel; +class CSkeletonAnim; #include #include "CStr.h" @@ -14,6 +15,7 @@ public: struct Anim { CStr m_AnimName; CStr m_FileName; + CSkeletonAnim* m_AnimData; }; public: @@ -31,7 +33,7 @@ public: CStr m_TextureName; // model name CStr m_ModelName; - // animation name + // list of valid animations for this object std::vector m_Animations; // object space bounds of model // CBound m_Bound;