"""Re-import the os_rig FBX files and print per-object origin / bounds (Unity space) / tris / materials, check required named children, tri budgets, the 6x6 footprint of tile-sized pieces and decal/screen UVs. Run: blender -b --factory-startup --python verify_os_rig.py -- [names]""" import bpy, os, sys d = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "Assets", "Art", "Models")) REQ = { "SM_DeckTile": ["Body", "Floats", "Rail_N", "Rail_S", "Rail_E", "Rail_W"], "SM_LaunchPad": ["Body", "RocketMount", "Bay"], "SM_Rocket": ["Body", "Flame"], "SM_LaunchLever": ["Body", "Lever"], "SM_Dock": ["Body", "Spawn"], "SM_Ladder": ["Body"], "SM_CrewCabin": ["Body"], "SM_Terminal": ["Body", "Screen"], } BUDGET = {"SM_DeckTile": 6000, "SM_LaunchPad": 15000, "SM_Rocket": 15000, "SM_CrewCabin": 15000, "SM_Terminal": 5000} FOOT = {"SM_DeckTile": 3.0, "SM_LaunchPad": 3.0} # |x|,|z| (unity) must stay inside UV01 = {"M_Screen", "M_Logo", "M_RocketDecal"} # faces must be UV'd inside 0..1 names = (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) or list(REQ) def U(v): # blender -> unity return (-v.x, v.z, -v.y) bad = 0 for n in names: bpy.ops.wm.read_factory_settings(use_empty=True) bpy.ops.import_scene.fbx(filepath=os.path.join(d, n + ".fbx")) bpy.context.view_layer.update() total = 0 gmn = [1e9] * 3 gmx = [-1e9] * 3 rows, found, probs = [], set(), [] for o in sorted(bpy.context.scene.objects, key=lambda o: o.name): found.add(o.name) org = U(o.matrix_world.translation) if o.type != "MESH": rows.append(f" {o.name:<12} {o.type:<6} origin({org[0]:.3f},{org[1]:.3f},{org[2]:.3f})") continue me = o.data tris = sum(len(f.vertices) - 2 for f in me.polygons) total += tris pts = [U(o.matrix_world @ v.co) for v in me.vertices] mn = [min(p[i] for p in pts) for i in range(3)] mx = [max(p[i] for p in pts) for i in range(3)] gmn = [min(a, b) for a, b in zip(gmn, mn)] gmx = [max(a, b) for a, b in zip(gmx, mx)] mats = sorted({m.name for m in me.materials if m}) uvl = me.uv_layers.active if uvl is None: probs.append(f"{o.name}: no UVs") else: for p in me.polygons: mname = me.materials[p.material_index].name if me.materials else "" if mname.split(".")[0] in UV01: for li in p.loop_indices: u, v = uvl.data[li].uv if not (-1e-4 <= u <= 1.0001 and -1e-4 <= v <= 1.0001): probs.append(f"{o.name}: {mname} UV out of 0..1 ({u:.3f},{v:.3f})") break rows.append(f" {o.name:<12} MESH origin({org[0]:.3f},{org[1]:.3f},{org[2]:.3f}) size({mx[0]-mn[0]:.2f} x {mx[1]-mn[1]:.2f} x {mx[2]-mn[2]:.2f}) " f"x[{mn[0]:.2f},{mx[0]:.2f}] y[{mn[1]:.2f},{mx[1]:.2f}] z[{mn[2]:.2f},{mx[2]:.2f}] tris={tris} [{','.join(mats)}]") missing = [r for r in REQ.get(n, []) if r not in found] if n in BUDGET and total > BUDGET[n]: probs.append(f"tris {total} > budget {BUDGET[n]}") if n in FOOT: lim = FOOT[n] + 1e-3 if gmn[0] < -lim or gmx[0] > lim or gmn[2] < -lim or gmx[2] > lim: probs.append(f"outside 6x6 footprint x[{gmn[0]:.3f},{gmx[0]:.3f}] z[{gmn[2]:.3f},{gmx[2]:.3f}]") probs = sorted(set(probs)) bad += len(missing) + len(probs) print(f"OSRIG|{n}|tris={total}|size {gmx[0]-gmn[0]:.2f} x {gmx[1]-gmn[1]:.2f} x {gmx[2]-gmn[2]:.2f}|" f"x[{gmn[0]:.2f},{gmx[0]:.2f}] y[{gmn[1]:.2f},{gmx[1]:.2f}] z[{gmn[2]:.2f},{gmx[2]:.2f}]|missing={missing or 'none'}|problems={probs or 'none'}") for r in rows: print(r) print(f"OSRIG|RESULT|{'OK' if bad == 0 else 'ISSUES %d' % bad}")