网格 (Mesh)#
- class genesis.engine.mesh.Mesh(mesh, surface: Surface | None = None, uvs: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None, scale: ndarray[tuple[Any, ...], dtype[_ScalarT]] | float | None = None, convexify=False, decimate=False, decimate_face_num=500, decimate_aggressiveness=0, metadata=None, is_mesh_zup: bool = True)[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.
- 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.
- clear_visuals()[source]#
Clear the mesh’s visual attributes by resetting the surface to gs.surfaces.Default().
- classmethod from_trimesh(mesh, scale=None, convexify=False, decimate=False, decimate_face_num=500, decimate_aggressiveness=2, metadata=None, surface=None, is_mesh_zup=True)[source]#
Create a genesis.Mesh from a trimesh.Trimesh object.
- classmethod from_attrs(verts, faces, normals=None, surface=None, uvs=None, scale=None, metadata=None, is_mesh_zup=True)[source]#
Create a genesis.Mesh from mesh attributes 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 sub-meshes, so we return a list.
- 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.
- 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.