Page MenuHome

FBX Import - Armatures are incorrect
Open, NormalPublic

Description

This has been there for a very long time. Whenever importing FBX with skeleton/armature from other apps, many times It's completely screwed - bones are rotated in wrong directions and rotations are wrong. Looks like coordinate systems are not converted correctly.

In this case - perfectly normal skeleton from Maya (From actual project where it is used in production in Maya, Unity, Motion builder etc).

Blender: All versions
OS: All OS

Details

Type
Bug

Event Timeline

Philipp Oeser (lichtwerk) triaged this task as Normal priority.

While I cant very the file in another program atm (could do tomorrow) I can confirm the output in blender looks unexpected [tried a couple of settings with no luck]
Hate to ask, but @Bastien Montagne (mont29), could you have a look?

can confirm that provided file reads just fine into Maya or Unity

Using Force Connect Children and Automatic Bone Orientation will help. Besides that, yes, upper part of the skeleton is weird, no idea why. Probably some issue in Pose/bind matrices somehow, armature model of FBX is so complicated…

ghoulish (ghoulish) added a comment.EditedJul 23 2019, 2:34 AM

I'm experiencing this issue with the importer (100% of FBX armatures I import fail to import correctly).

After spending a while looking into it, what appears to be happening is the importer is ignoring (or not successfully using) the PreRotation and PostRotation properties from the FBX LimbNodes to give the bones in Blender the rotation they're supposed to have. When the bones are getting created by the importer, the bones are successfully given proper lengths however the bones aren't getting rotated at all so that the bone tails actually wind up where they're supposed to. I'm not 100% sure about this, but from the reading of the python code I've put in I believe somewhere in the following line the rotation information using the PreRotation and PostRotation info is either not being considered or not being correctly applied:

from line 1931 of import_fbx.py
"# And rotate/move it to its final "rest pose".
bone_matrix = parent_matrix @ self.get_bind_matrix().normalized()"

Looks like at least math behind pre-rotation is wrong.
PreRotation should be something like this
parent_matrix @ rotation_matrix @ parent_matrix.inverted()

wait , what? Are you telling me that those f***ing pre transform matrices need to be inter-mingled with parenting??? In other words, we are supposed to 'cancel' the parent transform for those?

So that would give something like (to get final bind matrix) parent_matrix @ pre_matrix @ parent_matrix.inverted() @ bind_matrix @ post_matrix (which should then be normalized and post-multiplied again with parent_matrix)???

I ô so hate FBX transformations model… :(((

Either apply the "pre rotation" first - assuming bone is transform free when we apply, or cancel any transform before, "pre"-rotate and re-apply transform after.

Current code does parent_matrix @ ((pre_matrix @ bind_matrix) @ post_matrix).normalized()… So that should be correct, right (iirc, order matters, but not associativity, in matrix multiplication…)?

As far as i can understand the pre-rotation concept, it is not as the rotation must apply before any other transform (around 0,0,0).

So assuming object is at 0,0,0 before, should more be like this.
parent_matrix @ (post_matrix @ bind_matrix @ pre_matrix).normalized()

If it is not the case (any translation exist) you must cancel translation and re-apply after pre-rotation.

Yes I have the same issue when importing stuff from Unreal Engine to Blender 2.7X and 2.8
Importing FBX from Unreal Engine to Blender results in distorted bones and wrong IK bones locations and orientation even when connecting to children.
I can also confirm that creating an IK in blender and then exporting it to fbx then importing again will show different results than the originals