Hey Guys… (@Deltakosh)…
For a couple years now there has been a problem with the toolkit and skinning (Bone Influencers). Use the default XBot.fbx from Mixamo:
I have a WORK around to use Maya and my Reskin Tool to CLEANUP the skeleton.
Now In Unity to export a skeleton, we iterate thru all the bones and build a localTransform matrix to update each bone:
transformToBoneMap[unityBone].matrix = new[] {
localTransform[0, 0], localTransform[1, 0], localTransform[2, 0], localTransform[3, 0],
localTransform[0, 1], localTransform[1, 1], localTransform[2, 1], localTransform[3, 1],
localTransform[0, 2], localTransform[1, 2], localTransform[2, 2], localTransform[3, 2],
localTransform[0, 3], localTransform[1, 3], localTransform[2, 3], localTransform[3, 3]
};
And we create that localTransform matrix by multiplying the INVERSE bindpose with the Parent bone’s INVERSE bindpose
// Unity BindPose is already inverse so take the inverse again :-)
if (transformToBoneMap.ContainsKey(unityBone.parent))
{
var babylonParentBone = transformToBoneMap[unityBone.parent];
babylonBone.parentBoneIndex = babylonParentBone.index;
localTransform = bindPoses[babylonBone.parentBoneIndex] * bindPoses[i].inverse;
}
else
{
if (unityBone != root) {
UnityEngine.Debug.LogWarning("Parent bone transform '" + unityBone.parent.name + "' missing weights for child bone '" + unityBone.name);
}
babylonBone.parentBoneIndex = -1;
localTransform = bindPoses[i].inverse;
}
Now… this works but the SKIN JOB on the model has to be perfect. If it not the when you apply ANY animation to the model you get all Spaghetti Looking Model… Which i still get messages about the model being messed up and you have to use Maya Art Tools to Reskin the model.
While making the GLTF version which does not build a bone matrix for each bone but rather just export the array of bindposes… Everything looks perfect.
gltfSkin.InverseBindMatrices = ExportAccessor(mesh.bindposes, true);
So there is something wrong with the way Unity Babylon Toolkit is encoding the skeleton and bone data. Can you please help me fix this issue.
I tried looking a Babylon.Entities you use for 3DSMAX export. But i cant really tell whats going on in that code… It also looks like you might be decomposing the bind pose matrix and building it back up again and then assigning that to the bone.matrix… I dunno… But something needs to be done to the way babylon toolkit exports skeleton and bones and animations.
Can i count on you guys (the community) to help fix this issue