From 1df63e6f74e813043a1a67625a5eca1cf0a7cb2b Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Mon, 3 Jul 2023 20:08:00 -0700 Subject: [PATCH] Export only animations relevant to the current model --- art/Exporter.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/art/Exporter.py b/art/Exporter.py index 2383689..fe72e37 100644 --- a/art/Exporter.py +++ b/art/Exporter.py @@ -115,7 +115,7 @@ for o in D.objects: break if parent_index == -1: assert False, f"Couldn't find parent of bone {b}" - print(f"Parent of bone {b.name} is index {parent_index} in list {bones_in_armature}") + #print(f"Parent of bone {b.name} is index {parent_index} in list {bones_in_armature}") write_i32(f, parent_index) write_4x4matrix(f, model_space_pose) @@ -129,7 +129,14 @@ for o in D.objects: assert(len(o.pose.bones) == len(bones_in_armature)) armature = o - for animation in bpy.data.actions: + anims = [] + assert armature.animation_data, "Armatures are assumed to have an animation right now" + for track in armature.animation_data.nla_tracks: + for strip in track.strips: + anims.append(strip.action) + print(f"Writing {len(anims)} animations") + assert(len(anims) == 1) + for animation in anims: armature.animation_data.action = animation startFrame = int(animation.frame_range.x) endFrame = int(animation.frame_range.y)