Well, i read lots of articles and codes for the skinning (and animation) of .x file.
But i still can't make it right
Let me show some information i have learned first.( Please tell if i am wrong )
(1) Let's forget the animation now, only skinning
There're 3 key datas:
1. FrameTransformMatrix (bones and other Frames)
2. BoneOffsetMatrix
3. Vertex Positions, bone indices, weights
(2) The formulas for calculating ( OpenGL order ):
1. BoneCombinedTransformMatrix = RootFrameTransformMatrix * ... * ParentBoneTransformMatrix * CurrentBoneTransformMatrix
My file data looks like this:
[attachment=29058:hierarchy.png]
2. SkinnedPosition = BoneCombinedTransformMatrix * BoneOffsetMatrix * VertexPosition
Then i get the "Rest Pose" model skinned right
[attachment=29059:cat_rest.png]
OK, everything seems good yet.
But when i export the .x file in "Bind Pose", the problem comes out
In Blender, the "Bind Pose":
[attachment=29060:cat_bind_pose_blender.png]
In my app, becomes...
[attachment=29061:cat_bind_pose.png]
Well, i thought it must be the exporter's bug, so i load it in a .x MeshViewer, it's perfect...
So i tried to figure out the relations between all these datas, but my math is bad..
i analyze the structure in blender:
[attachment=29064:struct.png]
after i done lots of matrix calculations, then i have this...
[attachment=29062:bad_1.png]
and this...
[attachment=29063:bad_2.png]
and so on...
i also picked one animation data to multiply with, but it just going more crazy...
Is that something missing in the formula?
I read others code, but still can't find the key point, they seems just use the formulas above...
please help~~thanks~