I've been trying to get my head around how to properly set up a skinning animation system using the bone transform data that can be imported using the Open Asset Import Library (http://assimp.sourceforge.net) but always seem to fail, which I admit is starting to get on my nerves.
I've made a good 5+ attempts inspired by this article: http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html as well as the limited hints that are given in the Assimp documentation. One thing to note is that I'm using DirectX rather than OpenGL, so things in the above tutorial will obviously not match to 100%, which may be where I'm going wrong. I'm adhering to the standard matrix multiplication order of scale * rotation * translation and I'm transposing all of Assimp's imported matrices which the documentation suggests are in a right handed format. Comparing my animation frame matrices to that exposed by the assimp_view application, they do seem to match so the problem most likely lies in the way I append all these local matrices in order to construct the final transform of each bone. Pseudo-code of my approach to that:
XMMATRIX transform = bone.localTransform;
BoneData *pParent = bone.pParent;
while(pParent) {
transform = pParent.localTransform * transform;
pParent = pParent.pParent;
}
// The actual bone matrix applied to each vertex, scaled by its weight, is calculated like so:
XMMATRIX mat = globalMeshInverseTransform * transform * bone.offsetMatrix;
The other thing I'm doing differently from all info on this I've been able to find is that I'm doing the vertex transformation on the CPU by updating the vertex buffer rather than doing it in a vertex shader. I do see the upside to the vshader approach, I just want to see that I'm able to do it in this, presumably easier, way before moving on to that though.
So my question is basically; is there anything obvious one needs to do when using DX rather than OGL or when setting vertex data on the CPU rather than in the vertex shader (not likely) that I've missed, or is there some more to-the-point tutorial on how to go about this somewhere (I've searched but haven't been able to find any), preferably using DirectX?
Thanks for any pointers,
Husbjörn