paint_mesh: also write .pcol (points + colours) for fbx2gim

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 02:13:01 +01:00
parent 953ec56630
commit fa2d0592fd

View File

@@ -254,13 +254,21 @@ def main():
glb = os.path.join(out, f"{name}_painted.glb")
with open(glb, "wb") as f:
f.write(trimesh.exchange.gltf.export_glb(painted, include_normals=True))
# Punkte + Farben schlicht binär (fbx2gim überträgt sie auf die Mixamo-Figur; Assimp liest die
# Farben aus der GLB nicht zuverlässig): int Anzahl, je Punkt 3 float + 4 byte RGBA
pcol = os.path.join(out, f"{name}_painted.pcol")
rgba = (np.c_[np.clip(colours, 0, 1), np.ones(len(colours))] * 255).round().astype(np.uint8)
rec = np.zeros(len(colours), dtype=[("p", "<f4", 3), ("c", "u1", 4)])
rec["p"] = mesh.vertices; rec["c"] = rgba
with open(pcol, "wb") as f:
f.write(np.int32(len(rec)).tobytes()); f.write(rec.tobytes())
obj = os.path.join(out, f"{name}_mixamo.obj")
plain = trimesh.Trimesh(mesh.vertices, mesh.faces, process=False)
with open(obj, "w", encoding="utf-8") as f:
f.write(trimesh.exchange.obj.export_obj(plain, include_normals=True, include_color=False, include_texture=False))
png = os.path.join(out, f"{name}_painted.png")
preview(mesh, colours, png)
print(f"-> {glb}\n-> {obj}\n-> {png}")
print(f"-> {glb}\n-> {pcol}\n-> {obj}\n-> {png}")
return 0