A mesh contains the geometric (and optionally texture) data of the scene captured by spatial mapping. More...
Types | |
typedef std::vector< size_t > | chunkList |
Functions | |
Mesh () | |
Default constructor which creates an empty Mesh. More... | |
~Mesh () | |
Mesh 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 chunkList. More... | |
chunkList | getVisibleList (Transform camera_pose) |
Computes the list of visible chunks from a specific point of view. More... | |
chunkList | getSurroundingList (Transform camera_pose, float radius) |
Computes the list of chunks which are 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 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 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 |
std::vector< float3 > | vertices |
std::vector< uint3 > | triangles |
std::vector< float3 > | normals |
std::vector< float2 > | uv |
Mat | texture |
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.
typedef std::vector<size_t> chunkList |
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.
Computes the list of visible chunks from a specific point of view.
camera_pose | : the point of view, given in world reference. |
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. |
bool filter | ( | MeshFilterParameters | mesh_filter_params = MeshFilterParameters() , |
bool | update_chunk_only = false |
||
) |
Filters the mesh.
The resulting mesh in smoothed, small holes are filled and small blobs of non connected triangles are deleted.
mesh_filter_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 : false. |
bool applyTexture | ( | MESH_TEXTURE_FORMAT | 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. |
void mergeChunks | ( | 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). |
sl::float3 getGravityEstimate | ( | ) |
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.
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 Mesh into a file.
filename | : the path and filename of the mesh. |
type | : defines the file type (extension). default : MESH_FILE_FORMAT::OBJ. |
IDs | : (by default empty) Specify a set of chunks to be saved, if none provided all chunks are saved. default : (empty). |
bool load | ( | String | filename, |
bool | update_chunk_only = false |
||
) |
Loads the mesh from a file.
filename | : the path and filename of the mesh (do not forget the extension). |
update_chunk_only | : if set to false the mesh data (vertices/normals/triangles) is updated otherwise only the chunk data is updated. default : false. |
void clear | ( | ) |
Clears all the data.
std::vector<Chunk> chunks |
contains the list of chunks
std::vector<float3> vertices |
Vertices are defined by a 3D point {x,y,z}.
std::vector<uint3> triangles |
Vector of triangles, defined as a set of three vertices {v1, v2, v3}.
std::vector<float3> normals |
Normals are defined by three components, {nx, ny, nz}. Normals are defined for each vertex.
std::vector<float2> uv |
UVs define the 2D projection of each vertex onto the Texture.
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.
Mat texture |
Texture of the Mesh.