Class representing a mesh and containing the geometric (and optionally texture) data of the scene captured by the spatial mapping module. More...
Types | |
typedef std::vector< size_t > | chunkList |
Vector of chunks id. More... | |
Functions | |
Mesh () | |
Default constructor. More... | |
~Mesh () | |
Default destructor. More... | |
Chunk & | operator[] (int index) |
Defines the [] operator to directly access the desired chunk. More... | |
size_t | getNumberOfTriangles () |
Computes the total number of triangles stored in all chunks. More... | |
void | updateMeshFromChunkList (chunkList IDs=chunkList()) |
Updates vertices / normals / triangles / uv from chunk data pointed by the given sl::Mesh::chunkList. More... | |
chunkList | getVisibleList (Transform camera_pose) |
Computes the sl::Mesh::chunkList of visible chunks from a specific point of view. More... | |
chunkList | getSurroundingList (Transform camera_pose, float radius) |
Computes the sl::Mesh::chunkList of chunks close to a specific point of view. More... | |
bool | filter (MeshFilterParameters mesh_filter_params=MeshFilterParameters(), bool update_chunk_only=false) |
Filters the mesh. More... | |
bool | applyTexture (MESH_TEXTURE_FORMAT texture_format=MESH_TEXTURE_FORMAT::RGB) |
Applies a texture to the mesh. More... | |
void | mergeChunks (int faces_per_chunk) |
Merges current chunks. More... | |
sl::float3 | getGravityEstimate () |
Estimates the gravity vector. More... | |
std::vector< int > | getBoundaries () |
Compute the indices of boundary vertices. More... | |
bool | save (String filename, MESH_FILE_FORMAT type=MESH_FILE_FORMAT::OBJ, chunkList IDs=chunkList()) |
Saves the current sl::Mesh into a file. More... | |
bool | load (String filename, bool update_chunk_only=false) |
Loads the mesh from a file. More... | |
void | clear () |
Clears all the data. More... | |
Attributes | |
std::vector< Chunk > | chunks |
Vector of chunks constituting the sl::Mesh. More... | |
std::vector< float3 > | vertices |
Vector of vertices. More... | |
std::vector< uint3 > | triangles |
Vector of triangles/faces. More... | |
std::vector< float3 > | normals |
Vector of normals. More... | |
std::vector< uchar3 > | colors |
Vector of colors. More... | |
std::vector< float2 > | uv |
UVs defines the 2D projection of each vertices onto the texture. More... | |
Mat | texture |
Texture of the sl::Mesh. 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.
typedef std::vector<size_t> chunkList |
Vector of chunks id.
~Mesh | ( | ) |
Default destructor.
Chunk& operator[] | ( | int | index | ) |
Defines the [] operator to directly access the desired chunk.
size_t getNumberOfTriangles | ( | ) |
Computes the total number of triangles stored in all chunks.
Updates vertices / normals / triangles / uv from chunk data pointed by the given sl::Mesh::chunkList.
IDs | : Indices of chunks which will be concatenated. Default: (empty). |
Computes the sl::Mesh::chunkList of visible chunks from a specific point of view.
camera_pose | : Point of view (given in the same reference as the vertices). |
Computes the sl::Mesh::chunkList 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). |
bool filter | ( | MeshFilterParameters | mesh_filter_params = MeshFilterParameters() , |
bool | 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.
mesh_filter_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 applyTexture | ( | MESH_TEXTURE_FORMAT | 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.
Vectors 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. |
void mergeChunks | ( | 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. |
sl::float3 getGravityEstimate | ( | ) |
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).
std::vector<int> getBoundaries | ( | ) |
Compute the indices of boundary vertices.
bool save | ( | String | filename, |
MESH_FILE_FORMAT | type = MESH_FILE_FORMAT::OBJ , |
||
chunkList | IDs = chunkList() |
||
) |
Saves the current sl::Mesh into a file.
filename | : Path of the file to store the mesh in. |
type | : File extension type. Default: sl::MESH_FILE_FORMAT::OBJ. |
IDs | : Set of chunks to be saved. Default: (empty) (all chunks are saved) |
bool load | ( | String | filename, |
bool | update_chunk_only = false |
||
) |
void clear | ( | ) |
Clears all the data.
std::vector<float3> vertices |
Vector of vertices.
Vertices are defined by a 3D point {x, y, z}
.
std::vector<uint3> triangles |
Vector of triangles/faces.
Triangles are defined as a set of three vertices indexes {v1, v2, v3}
.
std::vector<float3> normals |
Vector of normals.
Normals are defined by three components {nx, ny, nz}
.
std::vector<uchar3> colors |
Vector of colors.
Colors are defined by three components {b, g, r}
.
std::vector<float2> uv |
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 |
Texture of the sl::Mesh.