Class representing a mesh and containing the geometric (and optionally texture) data of the scene captured by the spatial mapping module. More...
Functions | |
list[Chunk] | chunks (self) |
List of chunks constituting the sl.Mesh. | |
Chunk | __getitem__ (self, x) |
Gets a chunk from chunks. | |
bool | filter (self, params=MeshFilterParameters(), update_chunk_only=False) |
Filters the mesh. More... | |
bool | apply_texture (self, texture_format=MESH_TEXTURE_FORMAT.RGB) |
Applies a texture to the mesh. More... | |
bool | save (self, str filename, typeMesh=MESH_FILE_FORMAT.OBJ, id=[]) |
Saves the current sl.Mesh into a file. More... | |
bool | load (self, str filename, update_mesh=False) |
Loads the mesh from a file. More... | |
None | clear (self) |
Clears all the data. | |
np.array[float] | vertices (self) |
NumPy array of vertices. More... | |
np.array[int] | triangles (self) |
NumPy array of triangles/faces. More... | |
np.array[float] | normals (self) |
NumPy array of normals. More... | |
np.array[int] | colors (self) |
NumPy array of colors. More... | |
np.array[float] | uv (self) |
UVs defines the 2D projection of each vertices onto the texture. More... | |
Mat | texture (self) |
Texture of the sl.Mesh. More... | |
int | get_number_of_triangles (self) |
Computes the total number of triangles stored in all chunks. More... | |
np.array[int] | get_boundaries (self) |
Compute the indices of boundary vertices. More... | |
None | merge_chunks (self, int faces_per_chunk) |
Merges current chunks. More... | |
np.array[float] | get_gravity_estimate (self) |
Estimates the gravity vector. More... | |
list[int] | get_visible_list (self, Transform camera_pose) |
Computes the id list of visible chunks from a specific point of view. More... | |
list[int] | get_surrounding_list (self, Transform camera_pose, float radius) |
Computes the id list of chunks close to a specific point of view. More... | |
None | update_mesh_from_chunklist (self, id=[]) |
Updates vertices / normals / triangles / uv from chunk data pointed by the given list of id. More... | |
Class representing a mesh and containing the geometric (and optionally texture) data of the scene captured by the spatial mapping module.
By default the mesh is defined as a set of chunks.
This way we update only the data that has to be updated avoiding a time consuming remapping process every time a small part of the sl.Mesh is updated.
bool filter | ( | self, | |
params = MeshFilterParameters() , |
|||
update_chunk_only = False |
|||
) |
Filters the mesh.
The resulting mesh is smoothed, small holes are filled, and small blobs of non-connected triangles are deleted.
params | : Filtering parameters. Default: a preset of sl.MeshFilterParameters. |
update_chunk_only | : Whether to only update chunks (and not vertices / normals / triangles). Default: False. |
bool apply_texture | ( | self, | |
texture_format = MESH_TEXTURE_FORMAT.RGB |
|||
) |
Applies a texture to the mesh.
By using this method you will get access to uv, and texture.
The number of triangles in the mesh may slightly differ before and after calling this method due to missing texture information.
There is only one texture for the mesh, the uv of each chunk are expressed for it in its entirety.
NumPy arrays of vertices / normals and uv have now the same size.
texture_format | : Number of channels desired for the computed texture. Default: sl.MESH_TEXTURE_FORMAT.RGB. |
bool save | ( | self, | |
str | filename, | ||
typeMesh = MESH_FILE_FORMAT.OBJ , |
|||
id = [] |
|||
) |
Saves the current sl.Mesh into a file.
filename | : Path of the file to store the mesh in. |
typeMesh | : File extension type. Default: sl.MESH_FILE_FORMAT.OBJ. |
id | : Set of chunks to be saved. Default: (empty) (all chunks are saved) |
bool load | ( | self, | |
str | filename, | ||
update_mesh = False |
|||
) |
np.array[float] vertices | ( | self | ) |
NumPy array of vertices.
Vertices are defined by a 3D point [x, y, z]
.
np.array[int] triangles | ( | self | ) |
NumPy array of triangles/faces.
Triangle defined as a set of three vertices indexes [v1, v2, v3]
.
np.array[float] normals | ( | self | ) |
NumPy array of normals.
Normals are defined by three components [nx, ny, nz]
.
np.array[int] colors | ( | self | ) |
NumPy array of colors.
Colors are defined by three components [r, g, b]
.
np.array[float] uv | ( | self | ) |
UVs defines the 2D projection of each vertices onto the texture.
Values are normalized [0, 1] and start from the bottom left corner of the texture (as requested by OpenGL). In order to display a textured mesh you need to bind the texture and then draw each triangle by picking its uv values.
Mat texture | ( | self | ) |
Texture of the sl.Mesh.
int get_number_of_triangles | ( | self | ) |
Computes the total number of triangles stored in all chunks.
np.array[int] get_boundaries | ( | self | ) |
Compute the indices of boundary vertices.
None merge_chunks | ( | self, | |
int | faces_per_chunk | ||
) |
Merges current chunks.
This method can be used to merge chunks into bigger sets to improve rendering process.
faces_per_chunk | : Number of faces per chunk. |
np.array[float] get_gravity_estimate | ( | self | ) |
Estimates the gravity vector.
This method looks for a dominant plane in the whole mesh considering that it is the floor (or a horizontal plane).
list[int] get_visible_list | ( | self, | |
Transform | camera_pose | ||
) |
Computes the id list of visible chunks from a specific point of view.
camera_pose | : Point of view (given in the same reference as the vertices). |
list[int] get_surrounding_list | ( | self, | |
Transform | camera_pose, | ||
float | radius | ||
) |
Computes the id list of chunks close to a specific point of view.
camera_pose | : Point of view (given in the same reference as the vertices). |
radius | : Radius determining closeness (given in the same unit as the mesh). |
None update_mesh_from_chunklist | ( | self, | |
id = [] |
|||
) |