#!/usr/bin/env python3 """Render a T2MESH02/03 (per-vertex PBR) binary mesh to a PNG for eyeballing the demo's textured output. Mirrors the viewer's orientation-independent shading.""" import struct, sys, numpy as np from PIL import Image path = sys.argv[1]; out = sys.argv[2] if len(sys.argv) > 2 else "mesh_pbr.png" b = open(path, "rb").read() magic = b[:8]; nv, nt = struct.unpack("= 0) & (xx < W) & (yy >= 0) & (yy < H) img[yy[m], xx[m]] = col[m] return (img**(1/2.2)*255).reshape(H//SS, SS, W//SS, SS, 3).mean((1, 3)).astype(np.uint8) row = np.concatenate([render(12, 25), render(12, 150), render(65, 20)], 1) Image.fromarray(row).save(out) print("wrote", out, flush=True)