feat(naming): dance registry + two-stage naming system; archive non-keepers
Keep aloha1(+pp), dance1(+pp), hakadance1. Archive hakadance2, alohaOG, firedance1, hakaOG (all variants) to archive/. New dances get provisional nd## ids at conversion; rename to a dance code (haka01 etc.) only on adoption via tools/rename_clip.py. Registry: docs/dances/REGISTRY.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""rename_clip.py — rename the animation inside a GLB (for dance-code adoption).
|
||||
|
||||
Used when a provisional dance (nd##) is adopted and gets its final dance code
|
||||
(see docs/dances/REGISTRY.md). Renames the clip baked into the GLB; the pack
|
||||
rename is just the output filename.
|
||||
|
||||
Usage:
|
||||
blender --background --python tools/rename_clip.py -- \
|
||||
--src <in.glb> --out <out.glb> --name <NewClipName>
|
||||
"""
|
||||
import bpy, sys, argparse
|
||||
|
||||
def parse():
|
||||
argv = sys.argv[sys.argv.index("--")+1:] if "--" in sys.argv else []
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--src", required=True)
|
||||
p.add_argument("--out", required=True)
|
||||
p.add_argument("--name", required=True)
|
||||
return p.parse_args(argv)
|
||||
|
||||
def main():
|
||||
a = parse()
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
bpy.ops.import_scene.gltf(filepath=a.src)
|
||||
arm = next(o for o in bpy.data.objects if o.type == 'ARMATURE')
|
||||
act = arm.animation_data.action
|
||||
if getattr(act, "slots", None) and arm.animation_data.action_slot is None:
|
||||
arm.animation_data.action_slot = act.slots[0]
|
||||
old = act.name
|
||||
act.name = a.name
|
||||
|
||||
for t in list(arm.animation_data.nla_tracks):
|
||||
arm.animation_data.nla_tracks.remove(t)
|
||||
track = arm.animation_data.nla_tracks.new()
|
||||
track.name = a.name
|
||||
strip = track.strips.new(a.name, 0, act)
|
||||
strip.name = a.name
|
||||
arm.animation_data.action = None
|
||||
|
||||
for o in [o for o in bpy.data.objects if o.type == 'MESH']:
|
||||
bpy.data.objects.remove(o, do_unlink=True)
|
||||
|
||||
bpy.ops.export_scene.gltf(
|
||||
filepath=a.out,
|
||||
export_animation_mode="NLA_TRACKS",
|
||||
export_force_sampling=True,
|
||||
export_optimize_animation_size=False,
|
||||
)
|
||||
print(f"[rename_clip] '{old}' -> '{a.name}' EXPORTED {a.out}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user