mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-26 21:37:01 +00:00
Compare commits
1 Commits
a633610dc4
...
3c20464e93
Author | SHA1 | Date | |
---|---|---|---|
|
3c20464e93 |
@ -17,6 +17,4 @@ pub struct AnimationPlayerLink(pub Entity);
|
|||||||
|
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct Animated{
|
pub struct Animated;
|
||||||
pub animations: Vec<String>
|
|
||||||
}
|
|
@ -3520,16 +3520,8 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"isComponent": true,
|
"isComponent": true,
|
||||||
"isResource": false,
|
"isResource": false,
|
||||||
"properties": {
|
"properties": {},
|
||||||
"animations": {
|
"required": [],
|
||||||
"type": {
|
|
||||||
"$ref": "#/$defs/alloc::vec::Vec<alloc::string::String>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"animations"
|
|
||||||
],
|
|
||||||
"short_name": "Animated",
|
"short_name": "Animated",
|
||||||
"title": "bevy_gltf_blueprints::animation::Animated",
|
"title": "bevy_gltf_blueprints::animation::Animated",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
Binary file not shown.
@ -25,40 +25,19 @@ def remove_unwanted_custom_properties(object):
|
|||||||
del object[cp]
|
del object[cp]
|
||||||
|
|
||||||
# TODO: rename actions ?
|
# TODO: rename actions ?
|
||||||
# reference https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py#L481
|
|
||||||
def copy_animation_data(source, target):
|
def copy_animation_data(source, target):
|
||||||
"""if source.data:
|
"""if source.data:
|
||||||
data = source.data.copy()
|
data = source.data.copy()
|
||||||
target.data = data"""
|
target.data = data"""
|
||||||
if source.animation_data and source.animation_data:
|
if source.animation_data and source.animation_data:
|
||||||
#print("copying animation data from", source.name, "to", target.name)
|
#print("copying animation data from", source.name, "to", target.name)
|
||||||
print("I have animation data")
|
"""print("I have animation data")
|
||||||
ad = source.animation_data
|
ad = source.animation_data
|
||||||
"""if ad.action:
|
if ad.action:
|
||||||
print(source.name,'uses',ad.action.name)"""
|
print(source.name,'uses',ad.action.name)
|
||||||
|
for t in ad.nla_tracks:
|
||||||
animations = []
|
for s in t.strips:
|
||||||
blender_actions = []
|
print(source.name,'uses',s.action.name)"""
|
||||||
blender_tracks = {}
|
|
||||||
|
|
||||||
# TODO: this might need to be modified/ adapted to match the standard gltf exporter settings
|
|
||||||
for track in ad.nla_tracks:
|
|
||||||
#print("track", track.name, track.active)
|
|
||||||
non_muted_strips = [strip for strip in track.strips if strip.action is not None and strip.mute is False]
|
|
||||||
|
|
||||||
for strip in non_muted_strips: #t.strips:
|
|
||||||
print(" ", source.name,'uses',strip.action.name, "active", strip.active, "action", strip.action)
|
|
||||||
blender_actions.append(strip.action)
|
|
||||||
blender_tracks[strip.action.name] = track.name
|
|
||||||
|
|
||||||
# Remove duplicate actions.
|
|
||||||
blender_actions = list(set(blender_actions))
|
|
||||||
# sort animations alphabetically (case insensitive) so they have a defined order and match Blender's Action list
|
|
||||||
blender_actions.sort(key = lambda a: a.name.lower())
|
|
||||||
|
|
||||||
for action in blender_actions:
|
|
||||||
animations.append(blender_tracks[action.name])
|
|
||||||
print("animations", animations)
|
|
||||||
|
|
||||||
"""if target.animation_data == None:
|
"""if target.animation_data == None:
|
||||||
target.animation_data_create()
|
target.animation_data_create()
|
||||||
@ -67,7 +46,7 @@ def copy_animation_data(source, target):
|
|||||||
with bpy.context.temp_override(active_object=source, selected_editable_objects=[target]):
|
with bpy.context.temp_override(active_object=source, selected_editable_objects=[target]):
|
||||||
bpy.ops.object.make_links_data(type='ANIMATION')
|
bpy.ops.object.make_links_data(type='ANIMATION')
|
||||||
# we add an "animated" flag component
|
# we add an "animated" flag component
|
||||||
target['Animated'] = f'(animations: {animations})'.replace("'", '"') #'(animations: [])' #
|
target['Animated'] = '()'
|
||||||
"""print("copying animation data for", source.name, target.animation_data)
|
"""print("copying animation data for", source.name, target.animation_data)
|
||||||
properties = [p.identifier for p in source.animation_data.bl_rna.properties if not p.is_readonly]
|
properties = [p.identifier for p in source.animation_data.bl_rna.properties if not p.is_readonly]
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
@ -118,7 +97,8 @@ def duplicate_object(object, parent, combine_mode, destination_collection, libra
|
|||||||
"""if object.parent == None:
|
"""if object.parent == None:
|
||||||
if parent_empty is not None:
|
if parent_empty is not None:
|
||||||
copy.parent = parent_empty
|
copy.parent = parent_empty
|
||||||
"""
|
if object.animation_data:
|
||||||
|
copy['Animated'] = '()'"""
|
||||||
|
|
||||||
print(nester, "copy", copy)
|
print(nester, "copy", copy)
|
||||||
# do this both for empty replacements & normal copies
|
# do this both for empty replacements & normal copies
|
||||||
|
Loading…
Reference in New Issue
Block a user