Hello everyone,
I am trying to import 3d models at runtime using the assimp library. Mesh and bones seems to load fine but there is a problem with bind poses. Imported bones are in the correct place with correct rotation but the mesh is in somewhere else.
As you can see in the image it is like the model is rotated 90 degrees in x axis. Hip bone is in the correct location but the hip mesh is not. Thats why I thought there is a problem with bind pose.
After having all the bones in correct location I use this code to get the bind poses.
bindPoses [boneIndex] = GameObject.Find (bone.BoneName).transform.worldToLocalMatrix;
Any help is appreciated and thank you in advance.
Finally got it working. I have been trying to solve this problem for some days and it is funny how I found the solution in couple of hours after asking it here 
It appears that the inverse of the bone transform (worldToLocalMatrix) is not enough to get the correct bind pose. The code above isn’t wrong but it is incomplete. The inverse of the bone transform should be multiplied with the world transform of the mesh. By mesh I mean the game object that has the skinned mesh renderer attached to it. In this case the code looks like this
bindPoses [boneIndex] = bones[boneIndex].worldToLocalMatrix * mesh.transform.localToWorldMatrix;
And final result is just what I wanted
Hope this helps other people who have a similar problem.
1 Like