glTF exporter: add check rotation + delta rotation both animated
This commit is contained in:
parent
cbad9300d7
commit
ee2a0831d8
|
@ -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, 24),
|
||||
"version": (1, 3, 25),
|
||||
'blender': (2, 90, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -28,11 +28,15 @@ def get_target_object_path(data_path: str) -> str:
|
|||
|
||||
def get_rotation_modes(target_property: str) -> str:
|
||||
"""Retrieve rotation modes based on target_property"""
|
||||
if target_property in ["rotation_euler", "delta_rotation_euler"]:
|
||||
return True, ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"]
|
||||
elif target_property in ["rotation_quaternion", "delta_rotation_quaternion"]:
|
||||
return True, ["QUATERNION"]
|
||||
if target_property == "rotation_euler":
|
||||
return True, False, ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"]
|
||||
elif target_property == "delta_rotation_euler":
|
||||
return True, True, ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"]
|
||||
elif target_property == "rotation_quaternion":
|
||||
return True, False, ["QUATERNION"]
|
||||
elif target_property == "delta_rotation_quaternion":
|
||||
return True, True, ["QUATERNION"]
|
||||
elif target_property in ["rotation_axis_angle"]:
|
||||
return True, ["AXIS_ANGLE"]
|
||||
return True, False, ["AXIS_ANGLE"]
|
||||
else:
|
||||
return False, []
|
||||
return False, False, []
|
||||
|
|
|
@ -278,6 +278,7 @@ def __gather_target(channels: typing.Tuple[bpy.types.FCurve],
|
|||
def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.types.Object, export_settings):
|
||||
targets = {}
|
||||
multiple_rotation_mode_detected = False
|
||||
delta_rotation_detection = [False, False] # Normal / Delta
|
||||
for fcurve in blender_action.fcurves:
|
||||
# In some invalid files, channel hasn't any keyframes ... this channel need to be ignored
|
||||
if len(fcurve.keyframe_points) == 0:
|
||||
|
@ -318,8 +319,22 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t
|
|||
continue
|
||||
|
||||
# Detect that object or bone are not multiple keyed for euler and quaternion
|
||||
# Keep only the current rotation mode used by object / bone
|
||||
rotation, rotation_modes = get_rotation_modes(target_property)
|
||||
# Keep only the current rotation mode used by object
|
||||
rotation, delta, rotation_modes = get_rotation_modes(target_property)
|
||||
|
||||
# Delta rotation management
|
||||
if delta is False:
|
||||
if delta_rotation_detection[1] is True: # normal rotation coming, but delta is already present
|
||||
multiple_rotation_mode_detected = True
|
||||
continue
|
||||
delta_rotation_detection[0] = True
|
||||
else:
|
||||
if delta_rotation_detection[0] is True: # delta rotation coming, but normal is already present
|
||||
multiple_rotation_mode_detected = True
|
||||
continue
|
||||
delta_rotation_detection[1] = True
|
||||
|
||||
|
||||
if rotation and target.rotation_mode not in rotation_modes:
|
||||
multiple_rotation_mode_detected = True
|
||||
continue
|
||||
|
@ -347,6 +362,8 @@ def __gather_armature_object_channel_groups(blender_action: bpy.types.Action, bl
|
|||
if blender_object.type != "ARMATURE":
|
||||
return tuple()
|
||||
|
||||
delta_rotation_detection = [False, False] # Normal / Delta
|
||||
|
||||
for fcurve in blender_action.fcurves:
|
||||
object_path = get_target_object_path(fcurve.data_path)
|
||||
if object_path != "":
|
||||
|
@ -363,8 +380,19 @@ def __gather_armature_object_channel_groups(blender_action: bpy.types.Action, bl
|
|||
target = gltf2_blender_get.get_object_from_datapath(blender_object, object_path)
|
||||
|
||||
# Detect that armature is not multiple keyed for euler and quaternion
|
||||
# Keep only the current rotation mode used by object
|
||||
rotation, rotation_modes = get_rotation_modes(target_property)
|
||||
# Keep only the current rotation mode used by bone
|
||||
rotation, delta, rotation_modes = get_rotation_modes(target_property)
|
||||
|
||||
# Delta rotation management
|
||||
if delta is False:
|
||||
if delta_rotation_detection[1] is True: # normal rotation coming, but delta is already present
|
||||
continue
|
||||
delta_rotation_detection[0] = True
|
||||
else:
|
||||
if delta_rotation_detection[0] is True: # delta rotation coming, but normal is already present
|
||||
continue
|
||||
delta_rotation_detection[1] = True
|
||||
|
||||
if rotation and target.rotation_mode not in rotation_modes:
|
||||
continue
|
||||
|
||||
|
|
Loading…
Reference in New Issue