I am currently developing a video game using my own game engine I develop at the same time. While making a good progress in the past months, I am currently stuck. I assume I only miss a minor thing, but I need another pair of eyes and I really hope you can help me!
I wrote a converter which reads FBX files (using the official FBX SDK 2017.0.1) and converts them into my own custom file format. I am able to read meshes, texture and material information, the skeleton and all animation stacks. In my game (engine) I am able to display the textured meshes and animate them with any of the read animation stacks.
However, there is one problem for me. I bought meshes for NPC characters from a 3D artist and I also bought a huge animation pack from another artist. The character meshes include the perfectly textured and rigged mesh with all joints and the animation pack contains a rigged dummy mesh with all joints and animations.
I want to be able to use any animation from the animation pack on any mesh from the character artist.
My first step was to write a joint mapper. When reading the files I know which joint has which type. So, I am able to map the joints from the character mesh to the animation mesh and vice versa. The skeletons of both meshes are pretty similar and the mapping is going to work out.
In the FBX samples the animation calculation for a given vertex is:
Inv(Mesh_GlobalPosition * Mesh_GeometryTransform) * Joint_GlobalPosition * Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix * Mesh_GeometryTransform
Since Mesh_GeometryTransform is the identity matrix for all files I have bought, I can remove it from the term above. The result is:
Inv(Mesh_GlobalPosition) * Joint_GlobalPosition * Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix
Joint_GlobalPosition is the transformation in Bone Space and the only matrix that is time-dependent in this equation. Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix is used to transform the World Space to the Bone Space, as I understood. Finally, Inv(Mesh_GlobalPosition) is used to transform the result back to World Space.
If I understood something wrong, please correct me!!!
The joints which are used for the animation mesh are in a different space than the joints from the character mesh, because they come from different artists. I believe the missing part is to map between the joint spaces of both meshes. However, I do not know where to enter the mapping and I also don't know which spaces do I need to map? Object Space? Bone Space?
I'd appreciate any kind of help and will reward a useable solution with credits in my game!