MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / main

Function main

scripts/uv.py:19–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 return parser.parse_args();
18
19def 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
43if __name__ == "__main__":
44 main();

Callers 1

uv.pyFile · 0.70

Calls 9

RuntimeErrorClass · 0.85
parse_argsFunction · 0.70
load_meshMethod · 0.45
has_attributeMethod · 0.45
add_attributeMethod · 0.45
get_attributeMethod · 0.45
set_attributeMethod · 0.45
save_meshMethod · 0.45
form_meshMethod · 0.45

Tested by

no test coverage detected