Well met!
I'm still having trouble with bone-based animations ... with the Offset-matrix to be exact. Let me briefly break down what I am doing:
- Export/Import the mesh and the bones in bindpos (vertices "as-they-are", untransformed by bones)
(bones as transformation-matrices in their parents coord-system, the "local matrix")
- Compute "inverse bindpos matrices", beeing the inverse of each bones "local matrix" in bindposition
- For each frame, animate the current "local matrix" of each bone, still in their parents coord-system
- For each bone, compute a "final matrix" with
D3DXMATRIX CalcCombinedMatrix( int jointID )
{
if(joints[jointID].parentID == -1){
return joints[jointID].localTransMatrix * joints[jointID].inverseBindposMatrix;
}else{
return joints[jointID].localTransMatrix * joints[jointID].inverseBindposMatrix *
CalcCombinedMatrix(joints[jointID].parentID);
}
}
What I get is what I expect: The model is overall right, but all the rotations are happening around the model-center, instead of each bones parent.
What I need, according to this, this and this, is an "offset-matrix" I multiply to every bone (after my CalcCombinedMatrix), to move the bone transformations into their parents space, instead of the models center.
But I can not seem to get that matrix right. I am somehow supposed to use the center of the model for computations, and somewhat multiply every bones local matrix with it. I can't seem to get it working thought.
Could you try to make it clear to me how the offset-matrix is supposed to be computed? I can't really seem to grasp/visualize how I have to put the matrix I need together.
Thank you very much!
-gnomgrol