Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-05-31 23:18:24 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-05-31 23:18:24 +0300
commita5f2de962763f9c4a037fad0ab2ddf049d73686a (patch)
tree96d6c6db2dc9af15d6240347618f78b800e3ca50 /io_scene_gltf2/blender/exp
parent178738edd2ee2817aaf49bf03b968215795e211c (diff)
glTF exporter: Export multiple actions (from NLA) when sampled is now fixed
Diffstat (limited to 'io_scene_gltf2/blender/exp')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py14
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py1
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py9
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py15
4 files changed, 33 insertions, 6 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 aa81b073..40a30e78 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
@@ -59,11 +59,12 @@ def gather_animation_channels(blender_action: bpy.types.Action,
bone.name,
p,
bake_range_start,
- bake_range_end)
+ bake_range_end,
+ blender_action.name)
channels.append(channel)
else:
for channel_group in __get_channel_groups(blender_action, blender_object, export_settings):
- channel = __gather_animation_channel(channel_group, blender_object, export_settings, None, None, None, None)
+ channel = __gather_animation_channel(channel_group, blender_object, export_settings, None, None, None, None, blender_action.name)
if channel is not None:
channels.append(channel)
@@ -76,7 +77,8 @@ def __gather_animation_channel(channels: typing.Tuple[bpy.types.FCurve],
bake_bone: typing.Union[str, None],
bake_channel: typing.Union[str, None],
bake_range_start,
- bake_range_end
+ bake_range_end,
+ action_name: str
) -> typing.Union[gltf2_io.AnimationChannel, None]:
if not __filter_animation_channel(channels, blender_object, export_settings):
return None
@@ -84,7 +86,7 @@ def __gather_animation_channel(channels: typing.Tuple[bpy.types.FCurve],
return gltf2_io.AnimationChannel(
extensions=__gather_extensions(channels, blender_object, export_settings, bake_bone),
extras=__gather_extras(channels, blender_object, export_settings, bake_bone),
- sampler=__gather_sampler(channels, blender_object, export_settings, bake_bone, bake_channel, bake_range_start, bake_range_end),
+ sampler=__gather_sampler(channels, blender_object, export_settings, bake_bone, bake_channel, bake_range_start, bake_range_end, action_name),
target=__gather_target(channels, blender_object, export_settings, bake_bone, bake_channel)
)
@@ -118,7 +120,8 @@ def __gather_sampler(channels: typing.Tuple[bpy.types.FCurve],
bake_bone: typing.Union[str, None],
bake_channel: typing.Union[str, None],
bake_range_start,
- bake_range_end
+ bake_range_end,
+ action_name
) -> gltf2_io.AnimationSampler:
return gltf2_blender_gather_animation_samplers.gather_animation_sampler(
channels,
@@ -127,6 +130,7 @@ def __gather_sampler(channels: typing.Tuple[bpy.types.FCurve],
bake_channel,
bake_range_start,
bake_range_end,
+ action_name,
export_settings
)
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 fd0bb9c5..beeebf93 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
@@ -114,6 +114,7 @@ def gather_keyframes(blender_object_if_armature: typing.Optional[bpy.types.Objec
bake_channel: typing.Union[str, None],
bake_range_start,
bake_range_end,
+ action_name: str,
export_settings
) -> typing.List[Keyframe]:
"""Convert the blender action groups' fcurves to keyframes for use in glTF."""
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
index b4b5a943..8c01a940 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
@@ -36,6 +36,7 @@ def gather_animation_sampler(channels: typing.Tuple[bpy.types.FCurve],
bake_channel: typing.Union[str, None],
bake_range_start,
bake_range_end,
+ action_name: str,
export_settings
) -> gltf2_io.AnimationSampler:
@@ -57,7 +58,8 @@ def gather_animation_sampler(channels: typing.Tuple[bpy.types.FCurve],
return gltf2_io.AnimationSampler(
extensions=__gather_extensions(channels, blender_object_if_armature, export_settings, bake_bone, bake_channel),
extras=__gather_extras(channels, blender_object_if_armature, export_settings, bake_bone, bake_channel),
- input=__gather_input(channels, blender_object_if_armature, non_keyed_values, bake_bone, bake_channel, bake_range_start, bake_range_end, export_settings),
+ input=__gather_input(channels, blender_object_if_armature, non_keyed_values,
+ bake_bone, bake_channel, bake_range_start, bake_range_end, action_name, export_settings),
interpolation=__gather_interpolation(channels, blender_object_if_armature, export_settings, bake_bone, bake_channel),
output=__gather_output(channels, blender_object.matrix_parent_inverse.copy().freeze(),
blender_object_if_armature,
@@ -66,6 +68,7 @@ def gather_animation_sampler(channels: typing.Tuple[bpy.types.FCurve],
bake_channel,
bake_range_start,
bake_range_end,
+ action_name,
export_settings)
)
@@ -166,6 +169,7 @@ def __gather_input(channels: typing.Tuple[bpy.types.FCurve],
bake_channel: typing.Union[str, None],
bake_range_start,
bake_range_end,
+ action_name,
export_settings
) -> gltf2_io.Accessor:
"""Gather the key time codes."""
@@ -176,6 +180,7 @@ def __gather_input(channels: typing.Tuple[bpy.types.FCurve],
bake_channel,
bake_range_start,
bake_range_end,
+ action_name,
export_settings)
times = [k.seconds for k in keyframes]
@@ -225,6 +230,7 @@ def __gather_output(channels: typing.Tuple[bpy.types.FCurve],
bake_channel: typing.Union[str, None],
bake_range_start,
bake_range_end,
+ action_name,
export_settings
) -> gltf2_io.Accessor:
"""Gather the data of the keyframes."""
@@ -235,6 +241,7 @@ def __gather_output(channels: typing.Tuple[bpy.types.FCurve],
bake_channel,
bake_range_start,
bake_range_end,
+ action_name,
export_settings)
if bake_bone is not None:
target_datapath = "pose.bones['" + bake_bone + "']." + bake_channel
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 65335534..6473f5de 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
@@ -33,12 +33,27 @@ def gather_animations(blender_object: bpy.types.Object, export_settings) -> typi
# Collect all 'actions' affecting this object. There is a direct mapping between blender actions and glTF animations
blender_actions = __get_blender_actions(blender_object)
+ # save the current active action of the object, if any
+ # We will restore it after export
+ current_action = None
+ if blender_object.animation_data and blender_object.animation_data.action:
+ current_action = blender_object.animation_data.action
+
# Export all collected actions.
for blender_action in blender_actions:
+
+ # Set action as active, to be able to bake if needed
+ if blender_object.animation_data: # Not for shapekeys!
+ blender_object.animation_data.action = blender_action
+
animation = __gather_animation(blender_action, blender_object, export_settings)
if animation is not None:
animations.append(animation)
+ # Restore current action
+ if blender_object.animation_data:
+ blender_object.animation_data.action = current_action
+
return animations