diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-12-20 16:20:23 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-12-20 16:20:23 +0300 |
commit | 665b1a4113bc5a0cf918527b8659d2667e93caf9 (patch) | |
tree | 8397bf372ff64b57dabaf6124bd330bb9766dae1 | |
parent | c0e016dd83a243cb082b21d7477469719f0c9692 (diff) |
Fix T42912: FBX export: Parenting to bones was broken.
-rw-r--r-- | io_scene_fbx/fbx_utils.py | 8 | ||||
-rw-r--r-- | io_scene_fbx/import_fbx.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py index 22ff4be0..4d5cbe8e 100644 --- a/io_scene_fbx/fbx_utils.py +++ b/io_scene_fbx/fbx_utils.py @@ -998,9 +998,15 @@ class ObjectWrapper(metaclass=MetaObjectWrapper): # In fact, this is wrong - since we do not store that matrix in FBX at all, we shall not use it here... #~ matrix = self.bdata.matrix_parent_inverse * matrix if parent._tag == 'BO': + # In bone parent case, local matrix is in ***armature*** space!!!!!!!!!!!! + # So we need to bring it back into parent bone space. + matrix = parent._ref.pose.bones[parent.name].matrix.inverted_safe() * matrix + # In bone parent case, we get transformation in **bone tip** space (sigh). # Have to bring it back into bone root, which is FBX expected value. - matrix = Matrix.Translation((0, (parent.bdata.tail - parent.bdata.head).length, 0)) * matrix + # Actually, since we parent back to bone space above, we do not need that + # correction here it seems... + #~ matrix = Matrix.Translation((0, (parent.bdata.tail - parent.bdata.head).length, 0)) * matrix # Our matrix is in local space, time to bring it in its final desired space. if parent: diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 1db465f9..d70bc90f 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -1637,6 +1637,8 @@ class FbxImportHelperNode: return obj def build_skeleton_children(self, fbx_tmpl, settings, scene): + from mathutils import Matrix + if self.is_bone: for child in self.children: if child.ignore: @@ -1646,6 +1648,7 @@ class FbxImportHelperNode: child_obj.parent = self.bl_obj # get the armature the bone belongs to child_obj.parent_bone = self.bl_bone child_obj.parent_type = 'BONE' + child_obj.matrix_parent_inverse = Matrix() # Blender attaches to the end of a bone, while FBX attaches to the start. bone_child_matrix corrects for that. if child.pre_matrix: |