(mesh, output_obj_path: str = None)
| 482 | |
| 483 | |
| 484 | def export_to_obj(mesh, output_obj_path: str = None): |
| 485 | if output_obj_path is None: |
| 486 | output_obj_path = tempfile.NamedTemporaryFile(suffix=".obj").name |
| 487 | |
| 488 | verts = mesh.verts.detach().cpu().numpy() |
| 489 | faces = mesh.faces.cpu().numpy() |
| 490 | |
| 491 | vertex_colors = np.stack([mesh.vertex_channels[x].detach().cpu().numpy() for x in "RGB"], axis=1) |
| 492 | vertices = [ |
| 493 | "{} {} {} {} {} {}".format(*coord, *color) for coord, color in zip(verts.tolist(), vertex_colors.tolist()) |
| 494 | ] |
| 495 | |
| 496 | faces = ["f {} {} {}".format(str(tri[0] + 1), str(tri[1] + 1), str(tri[2] + 1)) for tri in faces.tolist()] |
| 497 | |
| 498 | combined_data = ["v " + vertex for vertex in vertices] + faces |
| 499 | |
| 500 | with open(output_obj_path, "w") as f: |
| 501 | f.writelines("\n".join(combined_data)) |
| 502 | |
| 503 | |
| 504 | def export_to_video(video_frames: List[np.ndarray], output_video_path: str = None) -> str: |
nothing calls this directly
no outgoing calls
no test coverage detected