1
0
forked from 0ad/0ad

Adjusted animation loading to store animation with each ObjectEntry for future reference.

This was SVN commit r243.
This commit is contained in:
notpete 2004-05-20 17:36:16 +00:00
parent 53e8734d4f
commit 256436af40
2 changed files with 23 additions and 10 deletions

View File

@ -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;i<m_Animations.size();i++) {
if (m_Animations[i].m_FileName.Length()>0) {
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;i<m_Animations.size();i++) {
if (m_Animations[i].m_AnimData) {
m_Model->SetAnimation(m_Animations[i].m_AnimData);
break;
}
}
}

View File

@ -2,6 +2,7 @@
#define _OBJECTENTRY_H
class CModel;
class CSkeletonAnim;
#include <vector>
#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<Anim> m_Animations;
// object space bounds of model
// CBound m_Bound;