Code: Select all
//Build the joint heirarchy
for (Joint j : joints)
{
if (!j.hasParentJoint())
j.ModelSpaceTransform = j.ParentSpaceTransform;
else
j.ModelSpaceTransform = j.getParent().WorldSpaceTransform * j.ParentSpaceTransform;
}
//Animate the model using keyframe data
for (Joint j : joints)
{
j.AnimationParentSpaceTransform = j.ParentSpaceTransform * keyframe;
if (!j.hasParentJoint())
j.AnimationWorldSpaceTransform = j.AnimationParentSpaceTransform;
else
j.AnimationWorldSpaceTransform = j.getParent().AnimationWorldSpaceTransform * j.AnimationParentSpaceTransform;
}
// Transform a vertex V
Joint joint = V.getJoint();
Vertex animatedVertex = joint.AnimationWorldSpaceTransform * joint.WorldSpaceTransform.inverse() * V;