paint_mesh: also write .pcol (points + colours) for fbx2gim
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -254,13 +254,21 @@ def main():
|
|||||||
glb = os.path.join(out, f"{name}_painted.glb")
|
glb = os.path.join(out, f"{name}_painted.glb")
|
||||||
with open(glb, "wb") as f:
|
with open(glb, "wb") as f:
|
||||||
f.write(trimesh.exchange.gltf.export_glb(painted, include_normals=True))
|
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")
|
obj = os.path.join(out, f"{name}_mixamo.obj")
|
||||||
plain = trimesh.Trimesh(mesh.vertices, mesh.faces, process=False)
|
plain = trimesh.Trimesh(mesh.vertices, mesh.faces, process=False)
|
||||||
with open(obj, "w", encoding="utf-8") as f:
|
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))
|
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")
|
png = os.path.join(out, f"{name}_painted.png")
|
||||||
preview(mesh, colours, png)
|
preview(mesh, colours, png)
|
||||||
print(f"-> {glb}\n-> {obj}\n-> {png}")
|
print(f"-> {glb}\n-> {pcol}\n-> {obj}\n-> {png}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user