I'm having an issue when trying to animate a mesh within my game using smooth skinning. I'm exporting a mesh, it's joints, and all animation data from Maya and it's importing properly within the game. I've also got my joints displayed in-game as spheres, just to make sure they are animating properly, and they are. I'm having trouble when transforming the vertices to bone space, and I'm clueless as to why. Here's a basic run-down of what I'm currently doing.
- Precalculating the inverse of each bone in it's bind-pose. The bone hierarchy is also set up here, I'm only setting their local matrices as their world matrices are calculated upon request.
- Interpolating matrices between keyframes, this appears to be working as the spheres are animating correctly.
- Copying the meshes vertices from the bind-pose into a seperate buffer to be modified
- Transforming each vertex:
For each vertex
For each influencing bone in vertex
Vertex tempvert;
tempvert = vertex.position * local bone inverse matrix;
tempvert = tempvert * interpolation of the bones world matrix between the current and next frame;
tempvert *= influence weight;
vertex += tempvert;
- Update the GPU with the transformed vertices
I've also tried switching around local and world transforms for the bones, but to no avail. I'm pretty sure I'm doing something stupid, I just want to make sure that's the case before I go tearing apart my math library.
Thanks for the help.