glTF exporter: Fix TRS when parent is skined
This commit is contained in:
parent
c61b075849
commit
83290c67a6
|
@ -4,7 +4,7 @@
|
|||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||
"version": (3, 4, 33),
|
||||
"version": (3, 4, 34),
|
||||
'blender': (3, 3, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -26,6 +26,9 @@ def gather_node(vnode, export_settings):
|
|||
blender_object = vnode.blender_object
|
||||
|
||||
skin = gather_skin(vnode.uuid, export_settings)
|
||||
if skin is not None:
|
||||
vnode.skin = skin
|
||||
|
||||
node = gltf2_io.Node(
|
||||
camera=__gather_camera(blender_object, export_settings),
|
||||
children=__gather_children(vnode, blender_object, export_settings),
|
||||
|
@ -50,9 +53,6 @@ def gather_node(vnode, export_settings):
|
|||
|
||||
vnode.node = node
|
||||
|
||||
if node.skin is not None:
|
||||
vnode.skin = skin
|
||||
|
||||
return node
|
||||
|
||||
|
||||
|
@ -314,9 +314,15 @@ def __gather_trans_rot_scale(vnode, export_settings):
|
|||
trans, rot, sca = vnode.matrix_world.decompose()
|
||||
else:
|
||||
# calculate local matrix
|
||||
trans, rot, sca = (export_settings['vtree'].nodes[vnode.parent_uuid].matrix_world.inverted_safe() @ vnode.matrix_world).decompose()
|
||||
|
||||
|
||||
if export_settings['vtree'].nodes[vnode.parent_uuid].skin is None:
|
||||
trans, rot, sca = (export_settings['vtree'].nodes[vnode.parent_uuid].matrix_world.inverted_safe() @ vnode.matrix_world).decompose()
|
||||
else:
|
||||
# But ... if parent has skin, the parent TRS are not taken into account, so don't get local from parent, but from armature
|
||||
# It also depens if skined mesh is parented to armature or not
|
||||
if export_settings['vtree'].nodes[vnode.parent_uuid].parent_uuid is not None and export_settings['vtree'].nodes[export_settings['vtree'].nodes[vnode.parent_uuid].parent_uuid].blender_type == VExportNode.ARMATURE:
|
||||
trans, rot, sca = (export_settings['vtree'].nodes[export_settings['vtree'].nodes[vnode.parent_uuid].armature].matrix_world.inverted_safe() @ vnode.matrix_world).decompose()
|
||||
else:
|
||||
trans, rot, sca = vnode.matrix_world.decompose()
|
||||
|
||||
# make sure the rotation is normalized
|
||||
rot.normalize()
|
||||
|
|
Loading…
Reference in New Issue