MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / clean_mesh

Function clean_mesh

Scripts/clean_meshes.py:49–66  ·  view source on GitHub ↗

Clean up a mesh using trimesh.

(mesh)

Source from the content-addressed store, hash-verified

47
48
49def clean_mesh(mesh):
50 """Clean up a mesh using trimesh."""
51 print(f" Original: {len(mesh.vertices)} vertices, {len(mesh.faces)} faces")
52
53 mesh.merge_vertices(merge_tex=False, merge_norm=False)
54 mesh.remove_unreferenced_vertices()
55 try:
56 import networkx # noqa: F401 - trimesh's fix_normals requires it
57 mesh.fix_normals()
58 except ImportError:
59 print(" Warning: networkx not installed, skipping fix_normals (GLB may have lighting issues)")
60
61 # Rotate -90 degrees around X for GLTF Y-up -> Unreal Z-up
62 rotation_matrix = trimesh.transformations.rotation_matrix(-np.radians(90), [1, 0, 0])
63 mesh.apply_transform(rotation_matrix)
64
65 print(f" Cleaned: {len(mesh.vertices)} vertices, {len(mesh.faces)} faces")
66 return mesh
67
68
69def convert_mesh(input_path: Path, output_path: Path) -> bool:

Callers 1

convert_meshFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected