Making your own Model format, idea's, comments, concerns?

Started by
9 comments, last by Dirge 21 years, 10 months ago
I'm doing skeleton animation in my engine and I came to a solution to the problem you're mentionning. It works only if you're using bone animation and works very well with skinning.

Basicaly, I have a Joint (it's a bone) class and a Skeleton class. The skeleton obviously contain all the bones that have pointers to each others in child/sibling order.

Details aside, here are the important parts :

class CJoint
{
public:
std::string m_Name;
CJoint *m_Child;
CJoint *m_Sibling;

std::vector m_IndexList;

sRenderList *m_RenderList;

};

class CSkeleton
{
CJoint *RootNode;
public:
struct sRenderList
{
int *m_IndexList;
float *m_TextureCoordinates;
float *m_VertexCoordinates;
point3 *m_Vertex;
CMaterialUnit m_Material;
};
sRenderList *m_RenderList;
};


So, the idea is to have all the vertex, texture and index data in the skeleton class. It's optimised for OpenGL, so the data is stored in arrays that are ready to be drawn with DrawIndexPrimitive(). Only the vertex data has to be updated each frame, the rest stays the same.

To update the data, I start going throught my tree and I use the index in CJoint to find the corresponding vertex to apply the bone transformation matrix to them. I output the result in my float *m_TextureCoordinates array and it's all ready to render ^_^.

Obviously, I cut animation part and some other stuff for simplification sake so there might be some missing stuff and optimisations.

EDIT : Oh yeah, I forgot to mention that each models can have many textures, that's why there's an array of renderlist and indexlist.


[edited by - Dark Rain on June 11, 2002 2:59:29 AM]

This topic is closed to new replies.

Advertisement