remove ".animations" file support from Ms3d and add support for populating+writing an AnimationsChunk in ConvertToMeshFile from the passed metadata object
This commit is contained in:
parent
029a340f11
commit
872ffde4c0
|
@ -220,19 +220,16 @@ BOOL ConvertToMeshFile(const std::string &meshFilename, const Ms3d *source, cons
|
|||
}
|
||||
WriteChunk(keyframes, fp);
|
||||
|
||||
AnimationsChunk *animations = new AnimationsChunk();
|
||||
for (int i = 0; i < source->GetNumAnimations(); ++i)
|
||||
if (metadata->IsLoaded() && metadata->GetNumAnimations() > 0)
|
||||
{
|
||||
const Ms3dAnimation *animation = source->GetAnimation(i);
|
||||
|
||||
AnimationSequence a;
|
||||
a.name = animation->name;
|
||||
a.start = animation->startFrame;
|
||||
a.end = animation->endFrame;
|
||||
|
||||
animations->animations.push_back(a);
|
||||
AnimationsChunk *animations = new AnimationsChunk();
|
||||
for (uint32_t i = 0; i < metadata->GetNumAnimations(); ++i)
|
||||
{
|
||||
AnimationSequence animation = metadata->GetAnimations()[i];
|
||||
animations->animations.push_back(animation);
|
||||
}
|
||||
WriteChunk(animations, fp);
|
||||
}
|
||||
WriteChunk(animations, fp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -186,57 +186,6 @@ BOOL Ms3d::Load(const std::string &file)
|
|||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
// check for an animation definition file
|
||||
std::string animationFile = file;
|
||||
animationFile.erase(animationFile.find_last_of('.', std::string::npos));
|
||||
animationFile.append(".animations");
|
||||
|
||||
fp = fopen(animationFile.c_str(), "r");
|
||||
if (fp != NULL)
|
||||
{
|
||||
char *buffer = new char[80];
|
||||
std::string line;
|
||||
std::string name;
|
||||
std::string temp;
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
fgets(buffer, 80, fp);
|
||||
line = buffer;
|
||||
|
||||
if (strlen(buffer) > 5) // minimum length for a viable frame definition
|
||||
{
|
||||
// get animation name
|
||||
int nameEnd = line.find_first_of(',');
|
||||
if (nameEnd == std::string::npos)
|
||||
continue;
|
||||
name = line.substr(0, nameEnd);
|
||||
|
||||
// get start frame index
|
||||
int startEnd = line.find_first_of(',', nameEnd + 1);
|
||||
if (startEnd == std::string::npos)
|
||||
continue;
|
||||
temp = line.substr(nameEnd + 1, startEnd);
|
||||
start = atoi(temp.c_str());
|
||||
|
||||
// get end frame index
|
||||
temp = line.substr(startEnd + 1, std::string::npos);
|
||||
end = atoi(temp.c_str());
|
||||
|
||||
Ms3dAnimation *animation = new Ms3dAnimation();
|
||||
animation->name = name;
|
||||
animation->startFrame = start;
|
||||
animation->endFrame = end;
|
||||
m_animations.push_back(*animation);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE_ARRAY(buffer);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "../geometry/vector3.h"
|
||||
#include "../geometry/vector2.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Ms3dHeader
|
||||
{
|
||||
|
@ -95,13 +94,6 @@ struct Ms3dJoint
|
|||
}
|
||||
};
|
||||
|
||||
struct Ms3dAnimation
|
||||
{
|
||||
std::string name;
|
||||
uint32_t startFrame;
|
||||
uint32_t endFrame;
|
||||
};
|
||||
|
||||
class Ms3d
|
||||
{
|
||||
public:
|
||||
|
@ -116,7 +108,6 @@ public:
|
|||
uint16_t GetNumMeshes() const { return m_numMeshes; }
|
||||
uint16_t GetNumMaterials() const { return m_numMaterials; }
|
||||
uint16_t GetNumJoints() const { return m_numJoints; }
|
||||
uint32_t GetNumAnimations() const { return m_animations.size(); }
|
||||
float GetAnimationFps() const { return m_animationFps; }
|
||||
uint32_t GetNumFrames() const { return m_numFrames; }
|
||||
Ms3dVertex* GetVertices() const { return m_vertices; }
|
||||
|
@ -124,7 +115,6 @@ public:
|
|||
Ms3dMesh* GetMeshes() const { return m_meshes; }
|
||||
Ms3dMaterial* GetMaterials() const { return m_materials; }
|
||||
Ms3dJoint* GetJoints() const { return m_joints; }
|
||||
const Ms3dAnimation* GetAnimation(int index) const { return &m_animations[index]; }
|
||||
|
||||
int32_t FindIndexOfMesh(const std::string &meshName) const;
|
||||
int32_t FindIndexOfJoint(const std::string &jointName) const;
|
||||
|
@ -144,7 +134,6 @@ private:
|
|||
Ms3dMesh *m_meshes;
|
||||
Ms3dMaterial *m_materials;
|
||||
Ms3dJoint *m_joints;
|
||||
std::vector<Ms3dAnimation> m_animations;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Reference in a new issue