[Bf-extensions-cvs] [76ca0077] master: glTF exporter: fix some rotation issue

Julien Duroure noreply at git.blender.org
Thu Apr 11 21:07:41 CEST 2019


Commit: 76ca00772a56a9779fffb1f2676eeb933c863973
Author: Julien Duroure
Date:   Thu Apr 11 21:07:09 2019 +0200
Branches: master
https://developer.blender.org/rBA76ca00772a56a9779fffb1f2676eeb933c863973

glTF exporter: fix some rotation issue

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

M	io_scene_gltf2/blender/exp/gltf2_blender_extract.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py

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

diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index d0347c97..6bdbcdad 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -102,13 +102,8 @@ def convert_swizzle_scale(scale, export_settings):
         return Vector((scale[0], scale[1], scale[2]))
 
 
-def decompose_transition(matrix, context, export_settings):
+def decompose_transition(matrix, export_settings):
     translation, rotation, scale = matrix.decompose()
-    """Decompose a matrix depending if it is associated to a joint or node."""
-    if context == 'NODE':
-        translation = convert_swizzle_location(translation, export_settings)
-        rotation = convert_swizzle_rotation(rotation, export_settings)
-        scale = convert_swizzle_scale(scale, export_settings)
 
     # Put w at the end.
     rotation = Quaternion((rotation[1], rotation[2], rotation[3], rotation[0]))
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
index 38e47031..410c12d3 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
@@ -48,7 +48,7 @@ def gather_joint(blender_bone, export_settings):
         # matrix_basis = blender_object.convert_space(blender_bone, blender_bone.matrix, from_space='POSE',
         #                                             to_space='LOCAL')
     trans, rot, sca = gltf2_blender_extract.decompose_transition(
-        gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), 'JOINT', export_settings)
+        gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), export_settings)
     translation, rotation, scale = (None, None, None)
     if trans[0] != 0.0 or trans[1] != 0.0 or trans[2] != 0.0:
         translation = [trans[0], trans[1], trans[2]]
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
index d3dea8b9..df34d45c 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -256,7 +256,20 @@ def __gather_name(blender_object, export_settings):
 
 
 def __gather_trans_rot_scale(blender_object, export_settings):
-    trans, rot, sca = gltf2_blender_extract.decompose_transition(blender_object.matrix_local, 'NODE', export_settings)
+    trans = gltf2_blender_extract.convert_swizzle_location(blender_object.location, export_settings)
+
+    if blender_object.rotation_mode in ['QUATERNION', 'AXIS_ANGLE']:
+        rotation = blender_object.rotation_quaternion
+    else:
+        rotation = blender_object.rotation_euler.to_quaternion()
+
+    rotation = gltf2_blender_extract.convert_swizzle_rotation(rotation, export_settings)
+
+    # Put w at the end.
+    rot = Quaternion((rotation[1], rotation[2], rotation[3], rotation[0]))
+
+    sca = gltf2_blender_extract.convert_swizzle_scale(blender_object.scale, export_settings)
+
     if blender_object.instance_type == 'COLLECTION' and blender_object.instance_collection:
         trans = -gltf2_blender_extract.convert_swizzle_location(
             blender_object.instance_collection.instance_offset, export_settings)



More information about the Bf-extensions-cvs mailing list