()
| 17 | return parser.parse_args(); |
| 18 | |
| 19 | def main(): |
| 20 | args = parse_args(); |
| 21 | mesh = pymesh.load_mesh(args.input_mesh); |
| 22 | if not mesh.has_attribute("corner_texture"): |
| 23 | raise RuntimeError("Mesh contains no uv!"); |
| 24 | |
| 25 | mesh.add_attribute("face_area"); |
| 26 | cutted_mesh = pymesh.cut_mesh(mesh); |
| 27 | |
| 28 | uvs = cutted_mesh.get_attribute("corner_texture").reshape((-1, 2)); |
| 29 | faces = cutted_mesh.faces; |
| 30 | per_vertex_uv = np.ndarray((cutted_mesh.num_vertices, 2)); |
| 31 | per_vertex_uv[faces.ravel(order="C")] = uvs; |
| 32 | |
| 33 | if not args.save_uv: |
| 34 | cutted_mesh.add_attribute("u"); |
| 35 | cutted_mesh.set_attribute("u", per_vertex_uv[:,0]); |
| 36 | cutted_mesh.add_attribute("v"); |
| 37 | cutted_mesh.set_attribute("v", per_vertex_uv[:,1]); |
| 38 | pymesh.save_mesh(args.output_mesh, cutted_mesh, "u", "v"); |
| 39 | else: |
| 40 | uv_mesh = pymesh.form_mesh(per_vertex_uv, faces); |
| 41 | pymesh.save_mesh(args.output_mesh, uv_mesh); |
| 42 | |
| 43 | if __name__ == "__main__": |
| 44 | main(); |
no test coverage detected