From 09d752e8453415daff11e94f87d8692a04b4eeff Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 6 Jul 2022 09:23:43 +0200 Subject: glTF exporter: export all actions of a single armature is now under an export option --- io_scene_gltf2/__init__.py | 14 ++++++++++- .../blender/exp/gltf2_blender_gather_animations.py | 29 +++++++++++----------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 39763f8d..bf23d017 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -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, 3, 11), + "version": (3, 3, 12), 'blender': (3, 3, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -395,6 +395,15 @@ class ExportGLTF2_Base: default=False ) + export_anim_single_armature: BoolProperty( + name='Export all Armature Actions', + description=( + "Export all actions of a single armature. " + "WARNING: works only if you exports a single armature" + ), + default=True + ) + export_current_frame: BoolProperty( name='Use Current Frame', description='Export the scene in the current animation frame', @@ -577,11 +586,13 @@ class ExportGLTF2_Base: export_settings['gltf_nla_strips'] = self.export_nla_strips export_settings['gltf_nla_strips_merged_animation_name'] = self.export_nla_strips_merged_animation_name export_settings['gltf_optimize_animation'] = self.optimize_animation_size + export_settings['gltf_export_anim_single_armature'] = self.export_anim_single_armature else: export_settings['gltf_frame_range'] = False export_settings['gltf_move_keyframes'] = False export_settings['gltf_force_sampling'] = False export_settings['gltf_optimize_animation'] = False + export_settings['gltf_export_anim_single_armature'] = False export_settings['gltf_skins'] = self.export_skins if self.export_skins: export_settings['gltf_all_vertex_influences'] = self.export_all_influences @@ -874,6 +885,7 @@ class GLTF_PT_export_animation_export(bpy.types.Panel): if operator.export_nla_strips is False: layout.prop(operator, 'export_nla_strips_merged_animation_name') layout.prop(operator, 'optimize_animation_size') + layout.prop(operator, 'export_anim_single_armature') class GLTF_PT_export_animation_shapekeys(bpy.types.Panel): diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py index a3a7a4c2..2d579d5b 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py @@ -319,20 +319,21 @@ def __get_blender_actions(blender_object: bpy.types.Object, action_on_type[strip.action.name] = "SHAPEKEY" # If there are only 1 armature, include all animations, even if not in NLA - if blender_object.type == "ARMATURE": - if len(export_settings['vtree'].get_all_node_of_type(VExportNode.ARMATURE)) == 1: - # Keep all actions on objects (no Shapekey animation) - for act in [a for a in bpy.data.actions if a.id_root == "OBJECT"]: - # We need to check this is an armature action - # Checking that at least 1 bone is animated - if not __is_armature_action(act): - continue - # Check if this action is already taken into account - if act.name in blender_tracks.keys(): - continue - blender_actions.append(act) - blender_tracks[act.name] = None - action_on_type[act.name] = "OBJECT" + if export_settings['gltf_export_anim_single_armature'] is True: + if blender_object.type == "ARMATURE": + if len(export_settings['vtree'].get_all_node_of_type(VExportNode.ARMATURE)) == 1: + # Keep all actions on objects (no Shapekey animation) + for act in [a for a in bpy.data.actions if a.id_root == "OBJECT"]: + # We need to check this is an armature action + # Checking that at least 1 bone is animated + if not __is_armature_action(act): + continue + # Check if this action is already taken into account + if act.name in blender_tracks.keys(): + continue + blender_actions.append(act) + blender_tracks[act.name] = None + action_on_type[act.name] = "OBJECT" export_user_extensions('gather_actions_hook', export_settings, blender_object, blender_actions, blender_tracks, action_on_type) -- cgit v1.2.3