1
\$\begingroup\$

I'm reading from the FBX format and I'm using Bones to animate an object, and I'm at the point where I have to decide on the code that actually moves the vertexes.

So far I thought on two methods:

Create a bone class that has an array of XYZ and an array of vertexes addresses and the weight. The array of XYZ (and rotations' values) will be filled from their positions/rotations at every frame. My model object will have an array of this bones class, and at each call I'll update the vertexes by multiplying the bones' XYZ for the vertexes, something like:

for(int i = 0; i < object->bonesCount; i++)
{
    for(int j = 0; j < object->bones[i]->vertexesCount; j++)
    {
        object->bones[i]->vertex[j].xyz *= object->bones[i].xyz; //plus rotation
    }
}

And the second method is having an array of vertexes * amount of frames, I do something like the above code and I save each vertexes' positions at every frame in the array, so I don't have to call the loop above (I think it might impact performance), but I'd have much more arrays to work with.

So my questions are, (1) which is the best approach for this, and (2) is there another method I didn't think of? Any info related to this is appreciated, as I have nothing done yet and I'm still elaborating on how it should be before I start coding (I try to avoid doing the first thing I come up with so there's less chances of needing to recode it later).

Thanks!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Usually you don't want to store array of positions of vertexes per frame but rather transformations of joints. This opens room for optimisations like interpolating positions between poses and allows you to blend animations. Such transformation can be stored in efficient so called "SQT" format (Scale, Quaternion of rotation, Translation vector)

struct JointPose
{
   Quaternion m_rotation;
   Vector3 m_translation;
   float m_scale;
};

Personally I recommend Game Engine Architecture book by Jason Gregory. Chapter Animations System.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .