Mesh#

class genesis.engine.mesh.Mesh(mesh, surface: Surface | None = None, uvs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None, convexify=False, decimate=False, decimate_face_num=500, decimate_aggressiveness=0, metadata=None)[source]#

Genesis’s own triangle mesh object. This is a wrapper of trimesh.Trimesh with some additional features and attributes. The internal trimesh object can be accessed via self.trimesh. We perform both convexification and decimation to preprocess the mesh for simulation if specified.

Parameters:
  • surface (genesis.Surface) – The mesh’s surface object.

  • uvs (np.ndarray) – The mesh’s uv coordinates.

  • convexify (bool) – Whether to convexify the mesh.

  • decimate (bool) – Whether to decimate the mesh.

  • decimate_face_num (int) – The target number of faces after decimation.

  • decimate_aggressiveness (int) – How hard the decimation process will try to match the target number of faces, as a integer ranging from 0 to 8. 0 is losseless. 2 preserves all features of the original geometry. 5 may significantly alters the original geometry if necessary. 8 does what needs to be done at all costs. Default to 0.

  • metadata (dict) – The metadata of the mesh.

convexify()[source]#

Convexify the mesh.

decimate(decimate_face_num, decimate_aggressiveness, convexify)[source]#

Decimate the mesh.

remesh(edge_len_abs=None, edge_len_ratio=0.01, fix=True)[source]#

Remesh for tetrahedralization.

tetrahedralize(tet_cfg)[source]#

Tetrahedralize the mesh.

particlize(p_size=0.01, sampler='random')[source]#

Sample particles using the mesh volume.

clear_visuals()[source]#

Clear the mesh’s visual attributes by resetting the surface to gs.surfaces.Default().

get_unique_edges()[source]#

Get the unique edges of the mesh.

copy()[source]#

Copy the mesh.

classmethod from_trimesh(mesh, scale=None, convexify=False, decimate=False, decimate_face_num=500, decimate_aggressiveness=2, metadata=None, surface=None)[source]#

Create a genesis.Mesh from a trimesh.Trimesh object.

classmethod from_attrs(verts, faces, normals=None, surface=None, uvs=None, scale=None)[source]#

Create a genesis.Mesh from mesh attribtues including vertices, faces, and normals.

classmethod from_morph_surface(morph, surface=None)[source]#

Create a genesis.Mesh from morph and surface options. If the morph is a Mesh morph (morphs.Mesh), it could contain multiple submeshes, so we return a list.

set_color(color)[source]#

Set the mesh’s color.

update_trimesh_visual()[source]#

Update the trimesh obj’s visual attributes using its surface and uvs.

apply_transform(T)[source]#

Apply a 4x4 transformation matrix (translation on the right column) to the mesh.

show()[source]#

Visualize the mesh using trimesh’s built-in viewer.

property uid#

Return the mesh’s uid.

property trimesh#

Return the mesh’s trimesh object.

property is_convex: bool#

Whether the mesh is convex.

property metadata#

Metadata of the mesh.

property verts#

Vertices of the mesh.

property faces#

Faces of the mesh.

property normals#

Normals of the mesh.

property surface#

Surface of the mesh.

property uvs#

UVs of the mesh.

property area#

Surface area of the mesh.

property volume#

Volume of the mesh.