(mesh, output_obj_path: str = None)
| 93 | |
| 94 | |
| 95 | def export_to_obj(mesh, output_obj_path: str = None): |
| 96 | if output_obj_path is None: |
| 97 | output_obj_path = tempfile.NamedTemporaryFile(suffix=".obj").name |
| 98 | |
| 99 | verts = mesh.verts.detach().cpu().numpy() |
| 100 | faces = mesh.faces.cpu().numpy() |
| 101 | |
| 102 | vertex_colors = np.stack([mesh.vertex_channels[x].detach().cpu().numpy() for x in "RGB"], axis=1) |
| 103 | vertices = [ |
| 104 | "{} {} {} {} {} {}".format(*coord, *color) for coord, color in zip(verts.tolist(), vertex_colors.tolist()) |
| 105 | ] |
| 106 | |
| 107 | faces = ["f {} {} {}".format(str(tri[0] + 1), str(tri[1] + 1), str(tri[2] + 1)) for tri in faces.tolist()] |
| 108 | |
| 109 | combined_data = ["v " + vertex for vertex in vertices] + faces |
| 110 | |
| 111 | with open(output_obj_path, "w") as f: |
| 112 | f.writelines("\n".join(combined_data)) |
| 113 | |
| 114 | |
| 115 | def _legacy_export_to_video( |
nothing calls this directly
no outgoing calls
no test coverage detected