Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-04-11 22:07:09 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-04-11 22:07:09 +0300
commit76ca00772a56a9779fffb1f2676eeb933c863973 (patch)
treefd1effcff0bf37b1a7274b2fa78c16907238fe83
parentfe05a06332c060cf16be09e4f332ed7bfc435227 (diff)
glTF exporter: fix some rotation issue
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_extract.py7
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py2
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py15
3 files changed, 16 insertions, 8 deletions
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)