A mesh contains the geometric (and optionally texture) data of the scene captured by spatial mapping. More...
Functions | |
def | chunks (self) |
contains the list of chunks | |
def | __getitem__ (self, x) |
gets a chunk from the list | |
def | filter (self, params=MeshFilterParameters(), update_chunk_only=True) |
Filters the mesh. More... | |
def | apply_texture (self, texture_format=MESH_TEXTURE_FORMAT.RGB) |
Applies texture to the mesh. More... | |
def | save (self, str filename, typeMesh=MESH_FILE_FORMAT.OBJ, id=[]) |
Saves the current Mesh into a file. More... | |
def | load (self, str filename, update_mesh=False) |
Loads the mesh from a file. More... | |
def | clear (self) |
Clears all the data. | |
def | vertices (self) |
Vertices are defined by a 3D point (numpy array) | |
def | triangles (self) |
List of triangles, defined as a set of three vertices. More... | |
def | normals (self) |
Normals are defined by three components, {nx, ny, nz}. More... | |
def | uv (self) |
UVs define the 2D projection of each vertex onto the texture . More... | |
def | texture (self) |
Texture of the Mesh. More... | |
def | get_number_of_triangles (self) |
Computes the total number of triangles stored in all chunks. More... | |
def | get_boundaries (self) |
Computes the indices of boundary vertices. More... | |
def | merge_chunks (self, int faces_per_chunk) |
Merges current chunks. More... | |
def | get_gravity_estimate (self) |
Estimates the gravity vector. More... | |
def | get_visible_list (self, Transform camera_pose) |
Computes the list of visible chunks from a specific point of view. More... | |
def | get_surrounding_list (self, Transform camera_pose, float radius) |
Computes the list of chunks which are close to a specific point of view. More... | |
def | update_mesh_from_chunklist (self, id=[]) |
Updates vertices / normals / triangles uv from chunk data pointed by given chunkList. More... | |
A mesh contains the geometric (and optionally texture) data of the scene captured by spatial mapping.
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 Mesh is updated.
def filter | ( | self, | |
params = MeshFilterParameters() , |
|||
update_chunk_only = True |
|||
) |
Filters the mesh.
The resulting mesh in smoothed, small holes are filled and small blobs of non connected triangles are deleted.
params | : defines the filtering parameters, for more info checkout the MeshFilterParameters documentation. default : preset. |
update_chunk_only | : if set to false the mesh data (vertices/normals/triangles) is updated otherwise only the chunk data is updated. default : true. |
def apply_texture | ( | self, | |
texture_format = MESH_TEXTURE_FORMAT.RGB |
|||
) |
Applies texture to the mesh.
By using this function you will get access to uv, and texture. The number of triangles in the mesh may slightly differ before and after calling this function 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. Vectors of vertices/normals and uv have now the same size.
texture_format | : defines the number of channels desired for the computed texture. default : MESH_TEXTURE_FORMAT.RGB. |
def save | ( | self, | |
str | filename, | ||
typeMesh = MESH_FILE_FORMAT.OBJ , |
|||
id = [] |
|||
) |
Saves the current Mesh into a file.
filename | : the path and filename of the mesh. |
typeMesh | : defines the file type (extension). default : MESH_FILE_FORMAT.OBJ. |
id | : specifies a set of chunks to be saved, if none provided all chunks are saved. default : (empty) |
def load | ( | self, | |
str | filename, | ||
update_mesh = False |
|||
) |
Loads the mesh from a file.
filename | : the path and filename of the mesh (do not forget the extension). |
update_mesh | : if set to false the mesh data (vertices/normals/triangles) are updated otherwise only the chunk's data are updated. default : false. |
def triangles | ( | self | ) |
List of triangles, defined as a set of three vertices.
The information is stored in a numpy array
def normals | ( | self | ) |
Normals are defined by three components, {nx, ny, nz}.
Normals are defined for each vertex. (numpy array)
def uv | ( | self | ) |
UVs define the 2D projection of each vertex onto the texture .
(numpy array) Values are normalized [0;1], starting 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.
def texture | ( | self | ) |
Texture of the Mesh.
def get_number_of_triangles | ( | self | ) |
Computes the total number of triangles stored in all chunks.
def get_boundaries | ( | self | ) |
Computes the indices of boundary vertices.
def merge_chunks | ( | self, | |
int | faces_per_chunk | ||
) |
Merges current chunks.
This can be used to merge chunks into bigger sets to improve rendering process.
faces_per_chunk | : defines the new number of faces per chunk (useful for Unity that doesn't handle chunks over 65K vertices). |
def get_gravity_estimate | ( | self | ) |
Estimates the gravity vector.
This function looks for a dominant plane in the whole mesh considering that it is the floor (or a horizontal plane). This can be used to find the gravity and then create realistic physical interactions.
def get_visible_list | ( | self, | |
Transform | camera_pose | ||
) |
Computes the list of visible chunks from a specific point of view.
camera_pose | : the point of view, given in world reference. |
def get_surrounding_list | ( | self, | |
Transform | camera_pose, | ||
float | radius | ||
) |
Computes the list of chunks which are close to a specific point of view.
camera_pose | : the point of view, given in world reference. |
radius | : the radius in defined UNIT |
def update_mesh_from_chunklist | ( | self, | |
id = [] |
|||
) |