[Bf-extensions-cvs] [a88815d] master: FBX: better handling of baked rotations (use euler_compat stuff to avoid gaps in rotations).

Bastien Montagne noreply at git.blender.org
Tue Apr 8 20:39:42 CEST 2014


Commit: a88815d45fbf672ac1b7e874e3b412068587878b
Author: Bastien Montagne
Date:   Tue Apr 8 20:37:56 2014 +0200
https://developer.blender.org/rBAa88815d45fbf672ac1b7e874e3b412068587878b

FBX: better handling of baked rotations (use euler_compat stuff to avoid gaps in rotations).

===================================================================

M	io_scene_fbx/export_fbx_bin.py

===================================================================

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index dbb0b1a..2133cb5 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1036,14 +1036,18 @@ def fbx_object_matrix(scene_data, obj, armature=None, local_space=False, global_
     return matrix
 
 
-def fbx_object_tx(scene_data, obj):
+def fbx_object_tx(scene_data, obj, rot_euler_compat=None):
     """
     Generate object transform data (always in local space when possible).
     """
     matrix = fbx_object_matrix(scene_data, obj)
     loc, rot, scale = matrix.decompose()
     matrix_rot = rot.to_matrix()
-    rot = rot.to_euler()  # quat -> euler, we always use 'XYZ' order.
+    # quat -> euler, we always use 'XYZ' order, use ref rotation if given.
+    if rot_euler_compat is not None:
+        rot = rot.to_euler('XYZ', rot_euler_compat)
+    else:
+        rot = rot.to_euler('XYZ')
 
     return loc, rot, scale, matrix, matrix_rot
 
@@ -2158,14 +2162,18 @@ def fbx_animations_objects(scene_data):
     back_currframe = scene.frame_current
     animdata = OrderedDict((obj, []) for obj in objects.keys())
 
+    p_rots = {}
+
     currframe = scene.frame_start
     while currframe < scene.frame_end:
         scene.frame_set(int(currframe), currframe - int(currframe))
         for obj in objects.keys():
             # Get PoseBone from bone...
             tobj = bone_map[obj] if isinstance(obj, Bone) else obj
-            # We compute baked loc/rot/scale for all objects.
-            loc, rot, scale, _m, _mr = fbx_object_tx(scene_data, tobj)
+            # We compute baked loc/rot/scale for all objects (rot being euler-compat with previous value!).
+            p_rot = p_rots.get(tobj, None)
+            loc, rot, scale, _m, _mr = fbx_object_tx(scene_data, tobj, p_rot)
+            p_rots[tobj] = rot
             tx = tuple(loc) + tuple(units_convert_iter(rot, "radian", "degree")) + tuple(scale)
             animdata[obj].append((currframe, tx, [False] * len(tx)))
         currframe += bake_step



More information about the Bf-extensions-cvs mailing list