glTF exporter: export animation on armature itself when sampled animation export
This commit is contained in:
parent
5c1b4497da
commit
171648da57
|
@ -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, 41),
|
||||
"version": (1, 1, 42),
|
||||
'blender': (2, 81, 6),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -83,6 +83,18 @@ def gather_animation_channels(blender_action: bpy.types.Action,
|
|||
channels.append(channel)
|
||||
|
||||
|
||||
# Retrieve animation on armature object itself, if any
|
||||
fcurves_armature = __gather_armature_object_channel_groups(blender_action, blender_object, export_settings)
|
||||
for channel_group in fcurves_armature:
|
||||
# No need to sort on armature, that can't have SK
|
||||
if len(channel_group) == 0:
|
||||
# Only errors on channels, ignoring
|
||||
continue
|
||||
channel = __gather_animation_channel(channel_group, blender_object, export_settings, None, None, bake_range_start, bake_range_end, blender_action.name, None)
|
||||
if channel is not None:
|
||||
channels.append(channel)
|
||||
|
||||
|
||||
# Retrieve channels for drivers, if needed
|
||||
drivers_to_manage = gltf2_blender_gather_drivers.get_sk_drivers(blender_object)
|
||||
for obj, fcurves in drivers_to_manage:
|
||||
|
@ -316,6 +328,46 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t
|
|||
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)
|
||||
|
||||
def __gather_armature_object_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.types.Object, export_settings):
|
||||
|
||||
targets = {}
|
||||
|
||||
if blender_object.type != "ARMATURE":
|
||||
return tuple()
|
||||
|
||||
for fcurve in blender_action.fcurves:
|
||||
object_path = get_target_object_path(fcurve.data_path)
|
||||
if object_path != "":
|
||||
continue
|
||||
|
||||
# In some invalid files, channel hasn't any keyframes ... this channel need to be ignored
|
||||
if len(fcurve.keyframe_points) == 0:
|
||||
continue
|
||||
try:
|
||||
target_property = get_target_property_name(fcurve.data_path)
|
||||
except:
|
||||
gltf2_io_debug.print_console("WARNING", "Invalid animation fcurve name on action {}".format(blender_action.name))
|
||||
continue
|
||||
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)
|
||||
if rotation and target.rotation_mode not in rotation_modes:
|
||||
continue
|
||||
|
||||
# group channels by target object and affected property of the target
|
||||
target_properties = targets.get(target, {})
|
||||
channels = target_properties.get(target_property, [])
|
||||
channels.append(fcurve)
|
||||
target_properties[target_property] = channels
|
||||
targets[target] = target_properties
|
||||
|
||||
groups = []
|
||||
for p in targets.values():
|
||||
groups += list(p.values())
|
||||
|
||||
return map(tuple, groups)
|
||||
|
||||
|
|
Loading…
Reference in New Issue