Hi,
I'd like to convert two aiScenes. Scene A is loaded from an arbitrary model, which can have any node structure and any mTransformations. Scene B is a more digestable, strict one: it's mRootNode has the mTransformation of identity matrix, and has all the meshes. Skeletons are stored as mRootNode's children, without meshes, their mTransformation matrices converted for the new mRootNode.
I'm able to convert everything, except for aiNodeAnim objects. I convert all mesh vertices, for bone nodes I calculate mTransformation for world A, multiply it by parent's world matrix' inverse. For offsetmatrix in B, I multiply the parent node's world matrix in B with this, and take it's inverse. Everything seems to be fine. I use a slightly modified version of assview.c to visualize the bind-pose and the animation-pose for the first frame.
Now for the animation-pose, I get the referenced node, and replace it's mTransformation by the matrix composed from the first element of mPositionKeys, mRotationKeys, mScalingKeys for each bone (channel). My first question is, how come that these sometimes reference a node which is not part of the skeleton (they have meshes, but no aiNodes)? I fix this by generating aiNodes in that node in A for the same node as bone and weight of 1.0, calculating the offsetmatrix from the node's mTranslation in A.
I repeat the step above for all channels, and I assume I should have the first frame's animation-pose in the node structure of A. Then I convert every mTransformation matrices from world A into world B, I decompose them into mPositionKeys,mRotationKeys,mScalingKeys for B.
The strange thing is, if I don't change the mTransformation with the aNodeAnim's data, then I can generate an animation-pose for B correctly. However if I recalculate mTransformation in A using aiNodeAnim's keys, then I get distorted results.
So in assview, bind-pose for A works, animation-pose for first frame of A works; bind-pose for B works, but first animation-pose of B only works if I leave the mTransformations of A as-is, and I don't replace them with composed aiNodeAnim keys. It is strange, because the assview.c does nothing special, it composes the mTransformation matrices exactly the same way as I'm trying to (and if I don't change those, the bind-pose A copied to animation-pose B aiNodeAnims correctly, meaning everything else I do is correct, I think).
What conversion do I miss for aiNodeAnim? Any help would be appreciated
bzt