diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-31 19:37:50 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-31 19:37:50 +0300 |
commit | 96a957faf31e15ed4922b9cb544fd154b01dee5e (patch) | |
tree | e5f89c0e2ec80caa7a1f5fc622872826c85b4cd0 | |
parent | e3f4241e295df0e1efa725606b3823f06db7a36b (diff) |
Fix T48977: rigged meshes' animation is not really supported in FBX.
rigged meshes are global, but implicitly local to their armature... so far
was exporting their animation in global space, and trying to correct it back to local
on import, but this cannot work that way - and actually does not make much sense.
So for now, fully disabling tranform animation of rigged meshes. Did quick check with
Unreal engine, and looks like it is totally ignoring any rigged mesh animation anyway.
If a kind miracle gives us some day full specs of that format, we may learn
what exact behavior is expected in that case.
-rw-r--r-- | io_scene_fbx/__init__.py | 2 | ||||
-rw-r--r-- | io_scene_fbx/export_fbx_bin.py | 3 | ||||
-rw-r--r-- | io_scene_fbx/import_fbx.py | 16 |
3 files changed, 18 insertions, 3 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 687e0904..e9180ea2 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier", - "version": (3, 7, 5), + "version": (3, 7, 6), "blender": (2, 77, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions", diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index 831426d6..4979dfc3 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -1881,11 +1881,12 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No p_rots = {} for ob_obj in objects: + if ob_obj.parented_to_armature: + continue ACNW = AnimationCurveNodeWrapper loc, rot, scale, _m, _mr = ob_obj.fbx_object_tx(scene_data) rot_deg = tuple(convert_rad_to_deg_iter(rot)) force_key = (simplify_fac == 0.0) or (ob_obj.is_bone and force_keying) - print(force_key, simplify_fac) animdata_ob[ob_obj] = (ACNW(ob_obj.key, 'LCL_TRANSLATION', force_key, force_sek, loc), ACNW(ob_obj.key, 'LCL_ROTATION', force_key, force_sek, rot_deg), ACNW(ob_obj.key, 'LCL_SCALING', force_key, force_sek, scale)) diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 4055a3b0..75a8db65 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -671,8 +671,13 @@ def blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, anim_o id_data = item.id_data else: id_data = item.bl_obj + # XXX Ignore rigged mesh animations - those are a nightmare to handle, see note about it in + # FbxImportHelperNode class definition. + if id_data.type == 'MESH' and id_data.parent and id_data.parent.type == 'ARMATURE': + continue if id_data is None: continue + # Create new action if needed (should always be needed! key = (as_uuid, al_uuid, id_data) action = actions.get(key) @@ -1466,7 +1471,7 @@ class FbxImportHelperNode: """ __slots__ = ( - '_parent', 'anim_compensation_matrix', 'armature_setup', 'armature', 'bind_matrix', + '_parent', 'anim_compensation_matrix', 'is_global_animation', 'armature_setup', 'armature', 'bind_matrix', 'bl_bone', 'bl_data', 'bl_obj', 'bone_child_matrix', 'children', 'clusters', 'fbx_elem', 'fbx_name', 'fbx_transform_data', 'fbx_type', 'is_armature', 'has_bone_children', 'is_bone', 'is_root', 'is_leaf', @@ -1494,7 +1499,15 @@ class FbxImportHelperNode: self.matrix, self.matrix_as_parent, self.matrix_geom = (None, None, None) self.post_matrix = None # correction matrix that needs to be applied after the FBX transform self.bone_child_matrix = None # Objects attached to a bone end not the beginning, this matrix corrects for that + + # XXX Those two are to handle the fact that rigged meshes are not linked to their armature in FBX, which implies + # that their animation is in global space (afaik...). + # This is actually not really solvable currently, since anim_compensation_matrix is not valid if armature + # itself is animated (we'd have to recompute global-to-local anim_compensation_matrix for each frame, + # and for each armature action... beyond being an insane work). + # Solution for now: do not read rigged meshes animations at all! sic... self.anim_compensation_matrix = None # a mesh moved in the hierarchy may have a different local matrix. This compensates animations for this. + self.is_global_animation = False self.meshes = None # List of meshes influenced by this bone. self.clusters = [] # Deformer Cluster nodes @@ -1786,6 +1799,7 @@ class FbxImportHelperNode: old_matrix = m.matrix m.matrix = armature_matrix_inv * m.get_world_matrix() m.anim_compensation_matrix = old_matrix.inverted_safe() * m.matrix + m.is_global_animation = True m.parent = self self.meshes = meshes else: |