diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2022-09-19 10:24:35 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2022-09-19 10:24:35 +0300 |
commit | 58db76bcc6ae799084d5ee8094515d0fad0fa01b (patch) | |
tree | 515194baf44d2410786b7dd9b8f8d09fce9f638a /io_scene_gltf2/blender/exp | |
parent | b9c0e2878e91ea955e2a765f0b68261f079b8ac3 (diff) |
glTF exporter: manage delta transform animation
Diffstat (limited to 'io_scene_gltf2/blender/exp')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py | 50 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py | 6 |
2 files changed, 42 insertions, 14 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py index 3e67f1f7..e7235254 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py @@ -4,7 +4,7 @@ import bpy import typing -from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name, get_rotation_modes +from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name, get_rotation_modes, get_delta_modes, is_location, is_rotation, is_scale from io_scene_gltf2.io.com import gltf2_io from io_scene_gltf2.io.com import gltf2_io_debug from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached @@ -364,6 +364,8 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t targets = {} multiple_rotation_mode_detected = False delta_rotation_detection = [False, False] # Normal / Delta + delta_location_detection = [False, False] # Normal / Delta + delta_scale_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: @@ -405,24 +407,46 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t # Detect that object or bone are not multiple keyed for euler and quaternion # Keep only the current rotation mode used by object - rotation, delta, rotation_modes = get_rotation_modes(target_property) + rotation, rotation_modes = get_rotation_modes(target_property) + delta = get_delta_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 + if is_rotation(target_property) : + 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: multiple_rotation_mode_detected = True continue - delta_rotation_detection[1] = True + # Delta location management + if is_location(target_property): + if delta is False: + if delta_location_detection[1] is True: # normal location coming, but delta is already present + continue + delta_location_detection[0] = True + else: + if delta_location_detection[0] is True: # delta location coming, but normal is already present + continue + delta_location_detection[1] = True - if rotation and target.rotation_mode not in rotation_modes: - multiple_rotation_mode_detected = True - continue + # Delta scale management + if is_scale(target_property): + if delta is False: + if delta_scale_detection[1] is True: # normal scale coming, but delta is already present + continue + delta_scale_detection[0] = True + else: + if delta_scale_detection[0] is True: # delta scale coming, but normal is already present + continue + delta_scale_detection[1] = True # group channels by target object and affected property of the target target_properties = targets.get(target, {}) diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py index 53d78945..b73c61b8 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py @@ -45,6 +45,7 @@ class Keyframe: length = { "delta_location": 3, "delta_rotation_euler": 3, + "delta_scale": 3, "location": 3, "rotation_axis_angle": 4, "rotation_euler": 3, @@ -367,7 +368,10 @@ def gather_keyframes(blender_obj_uuid: str, "rotation_axis_angle": [rot.to_axis_angle()[1], rot.to_axis_angle()[0][0], rot.to_axis_angle()[0][1], rot.to_axis_angle()[0][2]], "rotation_euler": rot.to_euler(), "rotation_quaternion": rot, - "scale": sca + "scale": sca, + "delta_location": trans, + "delta_rotation_euler": rot.to_euler(), + "delta_scale": sca }[target] else: key.value = get_sk_driver_values(driver_obj_uuid, frame, channels, export_settings) |