#!/usr/bin/env python3 """Read a binary FBX (Kaydara 7.x): skeleton, animation length and root joint. Walks the node tree, collecting LimbNode/Root models as joints and the longest KeyTime track as the timeline, then reads the `Connections` block to find which joint sits at the top of the hierarchy. Frame rate is measured from the key times themselves rather than assumed. Self-contained; no external deps. """ import os, struct, sys, zlib SCALAR = {"Y": 2, "C": 1, "I": 4, "F": 4, "D": 8, "L": 8} ELEM = {"f": 4, "d": 8, "l": 8, "i": 4, "b": 1} FBX_KTIME = 46186158000 # ktime units per second def _parse(path): d = open(path, "rb").read() if d[:21] != b"Kaydara FBX Binary \x00": raise ValueError("not a binary FBX") version = struct.unpack("= 7500 NREC = 25 if u64 else 13 joints, keytimes = [], [] # joints: (uid, name); keytimes: (n, type, slice) models, links = {}, [] # every Model uid -> name; child -> parent edges animated = [] # object-property edges: curve node -> the model it drives def rd_prop(p): t = chr(d[p]); s = p; p += 1 if t in SCALAR: p += SCALAR[t]; return p, (t, d[s + 1:p]) if t in ELEM: length, enc, clen = struct.unpack("= 3: uid = struct.unpack("= 3 and props[0][1] in (b"OO", b"OP"): try: a = struct.unpack(" 1 else 0.0, "root_joint": roots[0][1] if roots else "", "num_animated": len(driven), "joints": sorted(set(names)), "joint_names": "|".join(sorted(set(names)))[:400], } if __name__ == "__main__": for p in sys.argv[1:]: try: r = probe(p) print("%-34s ver=%s joints=%-4d keys=%-5d %-5s fps %.2fs root=%s" % ( os.path.basename(p), r["fbx_version"], r["num_joints"], r["keyframes"], r["fps"], r["duration_sec"], r["root_joint"])) except Exception as e: print("%-34s ERROR %s" % (os.path.basename(p), str(e)[:60]))