glTF exporter: fix transforms for mesh parented directly to bones

This commit is contained in:
Julien Duroure 2019-11-24 10:59:25 +01:00
parent a6ce1b121e
commit a96fa1e611
2 changed files with 4 additions and 4 deletions

View File

@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 1, 15),
"version": (1, 1, 16),
'blender': (2, 81, 6),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -174,8 +174,8 @@ def __gather_children(blender_object, blender_scene, export_settings):
rot_quat = Quaternion(rot)
axis_basis_change = Matrix(
((1.0, 0.0, 0.0, 0.0), (0.0, 0.0, -1.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0)))
mat = gltf2_blender_math.multiply(axis_basis_change, child.matrix_basis)
mat = gltf2_blender_math.multiply(child.matrix_parent_inverse, mat)
mat = gltf2_blender_math.multiply(child.matrix_parent_inverse, child.matrix_basis)
mat = gltf2_blender_math.multiply(mat, axis_basis_change)
_, rot_quat, _ = mat.decompose()
child_node.rotation = [rot_quat[1], rot_quat[2], rot_quat[3], rot_quat[0]]
@ -185,7 +185,7 @@ def __gather_children(blender_object, blender_scene, export_settings):
if trans is None:
trans = [0, 0, 0]
# bones go down their local y axis
bone_tail = [0, blender_bone.length, 0]
bone_tail = [0, blender_bone.length / blender_bone.matrix.to_scale()[1], 0]
child_node.translation = [trans[idx] + bone_tail[idx] for idx in range(3)]
parent_joint.children.append(child_node)