I am new to skeletal animation and I have read that, to animate a mesh using skeletal I would have to use a hierarchy of bones which I did making each bone node in my scene graph and then to deform the mesh I have to get the inverse absolute matrix of the bone before interpolation (which I believe is what they call the pose) multiply that for the interpolated absolute matrix of the bone to get transition matrix and to deform the mesh I would have to multiply the vertex times the transition matrix times the weight and sum all this result with any other bone that deform the same vertex.
to be more specific to get the absolute of each bone I do this
void CNode::update()
{
calculateAnimation(); //update the relativeMatrix with the interpolate keyfrmas
if(this->Parent!=null)
absMatrix = Parent->absMatrix * relativeMatrix;
else
absMatrix = RelativeMatrix;
for(int n=0; n<child.count; n++)
{
child[n]->update(); //keep going with the childrens
}
}
now I get the inverse of this absMatrix matrix before any interpolation that change the relativeMatrix one time only so to do the vertex deformation in this function
void CMesh::skinMesh(){
CVec3 vec;
for(int n=0; n < vertex.count; n++)
{
vec.clear();
for(int i; i < vertex[n].weight.count && vertex[n].bindBone[n] ; i++)
{
vec+= vertex[n].bindBone[n]->transitionMatrix * vertex[n].weight[n]
}
outVertex[n] = vec;
}
that doesn’t work for me because every vertex rotate around the center of the mesh axis instead of the parent of bone that deform the vertices, I thought it was logical considering that transition = InverAbs *absoulteMatrix will get me the the amount of rotation the bone has gain due to the interpolation so assuming it rotate 20 degrees the vertices will rotate 20 deg from the vertices origin so I guess I am missing something to make the vertices rotation around the parent of the bone which is deforming them,
the only way I could make it work was to transform the vertex with the inverse of the bone absolute matrix before interpolation and the with the interpolate absolute matrix, but that make it to slow since two multiplication happened instead of one, please help me.