#!/usr/bin/env python3 """Functional check: can animation/ actually drive character_refined/? Uses real node-tree bone names (not regex).""" import os,sys,json,collections HERE=os.path.dirname(os.path.abspath(__file__)); sys.path.insert(0,HERE) from fbx_bones import bones ROOT=os.path.dirname(HERE) A=os.path.join(ROOT,"animation"); R=os.path.join(ROOT,"character_refined") af=sorted(f for f in os.listdir(A) if f.endswith(".fbx")) print("parsing %d animations..."%len(af),flush=True) abones={}; sizes=collections.Counter() for i,f in enumerate(af,1): s=bones(os.path.join(A,f)); abones[f]=s; sizes[len(s)]+=1 if i%800==0: print(" %d/%d"%(i,len(af)),flush=True) union=set().union(*abones.values()) core=set.intersection(*abones.values()) print(" animation bone-count histogram:",dict(sorted(sizes.items()))) print(" union=%d core(in every animation)=%d"%(len(union),len(core))) if union-core: print(" bones not in every animation:",sorted(x for x in union-core)) rf=sorted(f for f in os.listdir(R) if f.endswith(".fbx")) print("\nparsing %d characters..."%len(rf),flush=True) rb={} for i,f in enumerate(rf,1): rb[f]=bones(os.path.join(R,f)) if i%40==0: print(" %d/%d"%(i,len(rf)),flush=True) full=[f for f in rf if union<=rb[f]] corefull=[f for f in rf if core<=rb[f]] partial=[(f,len(rb[f]),sorted(core-rb[f])[:4]) for f in rf if not core<=rb[f]] print("\n=== RETARGET COMPATIBILITY ===") print(" characters covering the FULL animation union (%d bones): %d/114"%(len(union),len(full))) print(" characters covering the CORE rig (%d bones) : %d/114"%(len(core),len(corefull))) print(" characters missing some core bones : %d"%len(partial)) hist=collections.Counter(len(v) for v in rb.values()) print(" character bone-count histogram:",dict(sorted(hist.items()))) print("\n characters with a reduced rig (will simply receive no data on absent bones):") for f,n,miss in sorted(partial,key=lambda x:x[1])[:15]: print(" %-26s %3d bones | e.g. missing %s"%(f,n,miss)) json.dump({f:sorted(v) for f,v in rb.items()},open(os.path.join(ROOT,"character_bones.json"),"w"),indent=1) assert union==core, "union != core; inspect before writing a single-key file" json.dump({"mixamo":sorted(union)},open(os.path.join(ROOT,"animation_bones.json"),"w"),indent=1) print("\nwrote ../character_bones.json and ../animation_bones.json")