diff options
-rwxr-xr-x | io_scene_gltf2/__init__.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/com/gltf2_blender_data_path.py | 11 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py | 14 |
3 files changed, 25 insertions, 2 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index f72b94b8..2aaf1753 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -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, 8), + "version": (1, 1, 9), 'blender': (2, 81, 6), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/com/gltf2_blender_data_path.py b/io_scene_gltf2/blender/com/gltf2_blender_data_path.py index c5ce4025..6ba77709 100755 --- a/io_scene_gltf2/blender/com/gltf2_blender_data_path.py +++ b/io_scene_gltf2/blender/com/gltf2_blender_data_path.py @@ -26,3 +26,14 @@ def get_target_object_path(data_path: str) -> str: return "" return path_split[0] +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"] + elif target_property in ["rotation_axis_angle"]: + return True, ["AXIS_ANGLE"] + else: + return False, [] + 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 611cd74a..8f2f036e 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 @@ -15,7 +15,7 @@ import bpy import typing -from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name +from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name, get_rotation_modes 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 @@ -200,6 +200,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 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: @@ -239,6 +240,13 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t gltf2_io_debug.print_console("WARNING", "Animation target {} not found".format(object_path)) 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) + if rotation and target.rotation_mode not in rotation_modes: + multiple_rotation_mode_detected = True + continue + # group channels by target object and affected property of the target target_properties = targets.get(target, {}) channels = target_properties.get(target_property, []) @@ -250,5 +258,9 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t for p in targets.values(): groups += list(p.values()) + if multiple_rotation_mode_detected is True: + gltf2_io_debug.print_console("WARNING", "Multiple rotation mode detected for {}".format(blender_object.name)) + + return map(tuple, groups) |