glTF exporter: Add support for use_inherit_rotation and inherit_scale.
Thanks Skywolf285!
This commit is contained in:
parent
40db41a902
commit
63dd8498ac
|
@ -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, 3, 31),
|
||||
"version": (1, 3, 32),
|
||||
'blender': (2, 90, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -161,8 +161,14 @@ def get_bone_matrix(blender_object_if_armature: typing.Optional[bpy.types.Object
|
|||
if bake_bone is None:
|
||||
matrix = pbone.matrix_basis.copy()
|
||||
else:
|
||||
matrix = pbone.matrix
|
||||
matrix = blender_object_if_armature.convert_space(pose_bone=pbone, matrix=matrix, from_space='POSE', to_space='LOCAL')
|
||||
if (pbone.bone.use_inherit_rotation == False or pbone.bone.inherit_scale != "FULL") and pbone.parent != None:
|
||||
rest_mat = (pbone.parent.bone.matrix_local.inverted_safe() @ pbone.bone.matrix_local)
|
||||
matrix = (rest_mat.inverted_safe() @ pbone.parent.matrix.inverted_safe() @ pbone.matrix)
|
||||
else:
|
||||
matrix = pbone.matrix
|
||||
matrix = blender_object_if_armature.convert_space(pose_bone=pbone, matrix=matrix, from_space='POSE', to_space='LOCAL')
|
||||
|
||||
|
||||
data[frame][pbone.name] = matrix
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,14 @@ def gather_joint(blender_object, blender_bone, export_settings):
|
|||
else:
|
||||
correction_matrix_local = gltf2_blender_math.multiply(
|
||||
blender_bone.parent.bone.matrix_local.inverted(), blender_bone.bone.matrix_local)
|
||||
matrix_basis = blender_bone.matrix_basis
|
||||
|
||||
if (blender_bone.bone.use_inherit_rotation == False or blender_bone.bone.inherit_scale != "FULL") and blender_bone.parent != None:
|
||||
rest_mat = (blender_bone.parent.bone.matrix_local.inverted_safe() @ blender_bone.bone.matrix_local)
|
||||
matrix_basis = (rest_mat.inverted_safe() @ blender_bone.parent.matrix.inverted_safe() @ blender_bone.matrix)
|
||||
else:
|
||||
matrix_basis = blender_bone.matrix
|
||||
matrix_basis = blender_object.convert_space(pose_bone=blender_bone, matrix=matrix_basis, from_space='POSE', to_space='LOCAL')
|
||||
|
||||
trans, rot, sca = gltf2_blender_extract.decompose_transition(
|
||||
gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), export_settings)
|
||||
translation, rotation, scale = (None, None, None)
|
||||
|
|
Loading…
Reference in New Issue