Uvmap a mesh file using xatlas. All existing textures are discarded. Args: filename: input mesh file out_filename: an obj file with uv mapping (without mtl) Returns:
(
filename: str,
out_filename: str = None,
)
| 842 | |
| 843 | |
| 844 | def remesh_file( |
| 845 | filename: str, |
| 846 | out_filename: str = None, |
| 847 | ) -> T.Dict[str, T.Any]: |
| 848 | """ |
| 849 | Uvmap a mesh file using xatlas. All existing textures are discarded. |
| 850 | |
| 851 | Args: |
| 852 | filename: |
| 853 | input mesh file |
| 854 | out_filename: |
| 855 | an obj file with uv mapping (without mtl) |
| 856 | |
| 857 | Returns: |
| 858 | |
| 859 | """ |
| 860 | |
| 861 | mesh = o3d.io.read_triangle_mesh(filename, enable_post_processing=True) |
| 862 | vertices = np.asarray(mesh.vertices) |
| 863 | triangle_ids = np.asarray(mesh.triangles) |
| 864 | |
| 865 | out_dict = remesh(vertices, triangle_ids) |
| 866 | |
| 867 | if out_filename is not None: |
| 868 | xatlas.export( |
| 869 | out_filename, |
| 870 | vertices[out_dict['vmapping']], |
| 871 | out_dict['indices'], |
| 872 | out_dict['uvs'], |
| 873 | ) |
| 874 | return out_dict |
| 875 | |
| 876 | |
| 877 | def remesh( |