Mesh data container, validator and exporter. More...
#include <Mesh.h>
Public Types | |
using | index_type = size_t |
using | material_type = MeshMaterial |
using | normal_type = Vector3D |
using | uv_type = Vector2D |
using | vertex_type = Vector3D |
Public Member Functions | |
void | AddIndex (index_type index) |
Appends a index to the indexes list. More... | |
void | AddMaterial (const std::string &material_name) |
Starts applying a new material to the new added triangles. More... | |
void | AddNormal (normal_type normal) |
Appends a normal to the normal list. More... | |
void | AddTriangleFan (const std::vector< vertex_type > &vertices) |
Adds a triangle fan to the mesh, vertex order is counterclockwise. More... | |
void | AddTriangleStrip (const std::vector< vertex_type > &vertices) |
Adds a triangle strip to the mesh, vertex order is counterclockwise. More... | |
void | AddUV (uv_type uv) |
Appends a vertex to the vertices list, they will be read 3 in 3. More... | |
void | AddUVs (const std::vector< uv_type > &uv) |
Appends uvs. More... | |
void | AddVertex (vertex_type vertex) |
Appends a vertex to the vertices list. More... | |
void | AddVertices (const std::vector< vertex_type > &vertices) |
Appends a vertex to the vertices list. More... | |
Mesh & | ConcatMesh (const Mesh &rhs, int num_vertices_to_link) |
Merges two meshes into a single mesh. More... | |
void | EndMaterial () |
Stops applying the material to the new added triangles. More... | |
std::string | GenerateOBJ () const |
Returns a string containing the mesh encoded in OBJ. More... | |
std::string | GenerateOBJForRecast () const |
Returns a string containing the mesh encoded in OBJ. More... | |
std::string | GeneratePLY () const |
Returns a string containing the mesh encoded in PLY. More... | |
const std::vector< index_type > & | GetIndexes () const |
std::vector< index_type > & | GetIndexes () |
size_t | GetIndexesNum () const |
size_t | GetLastVertexIndex () const |
Returns the index of the last added vertex (number of vertices). More... | |
const std::vector< material_type > & | GetMaterials () const |
const std::vector< normal_type > & | GetNormals () const |
const std::vector< uv_type > & | GetUVs () const |
const std::vector< vertex_type > & | GetVertices () const |
std::vector< vertex_type > & | GetVertices () |
size_t | GetVerticesNum () const |
bool | IsValid () const |
Check if the mesh can be valid or not. More... | |
Mesh (const std::vector< vertex_type > &vertices={}, const std::vector< normal_type > &normals={}, const std::vector< index_type > &indexes={}, const std::vector< uv_type > &uvs={}) | |
Mesh & | operator+= (const Mesh &rhs) |
Merges two meshes into a single mesh. More... | |
Private Attributes | |
std::vector< index_type > | _indexes |
std::vector< material_type > | _materials |
std::vector< normal_type > | _normals |
std::vector< uv_type > | _uvs |
std::vector< vertex_type > | _vertices |
Friends | |
Mesh | operator+ (const Mesh &lhs, const Mesh &rhs) |
using carla::geom::Mesh::index_type = size_t |
using carla::geom::Mesh::uv_type = Vector2D |
|
inline |
Definition at line 57 of file Mesh.h.
References IsValid(), FProceduralCustomMesh::Normals, carla::geom::operator+(), FProceduralCustomMesh::Triangles, FProceduralCustomMesh::UV0, and FProceduralCustomMesh::Vertices.
void carla::geom::Mesh::AddIndex | ( | index_type | index | ) |
Appends a index to the indexes list.
Definition at line 101 of file Mesh.cpp.
References _indexes.
Referenced by AddTriangleFan(), AddTriangleStrip(), carla::geom::MeshFactory::GenerateLaneMarksForCenterLine(), carla::geom::MeshFactory::GenerateLaneMarksForNotCenterLine(), carla::geom::MeshFactory::GenerateSidewalk(), carla::geom::MeshFactory::GenerateTesselated(), and carla::road::Map::SDFToMesh().
void carla::geom::Mesh::AddMaterial | ( | const std::string & | material_name | ) |
Starts applying a new material to the new added triangles.
Definition at line 113 of file Mesh.cpp.
References _indexes, _materials, and EndMaterial().
Referenced by carla::geom::MeshFactory::Generate(), carla::geom::MeshFactory::GenerateLeftWall(), carla::geom::MeshFactory::GenerateRightWall(), carla::geom::MeshFactory::GenerateSidewalk(), carla::geom::MeshFactory::GenerateTesselated(), and carla::road::Map::GetAllCrosswalkMesh().
void carla::geom::Mesh::AddNormal | ( | normal_type | normal | ) |
void carla::geom::Mesh::AddTriangleFan | ( | const std::vector< vertex_type > & | vertices | ) |
Adds a triangle fan to the mesh, vertex order is counterclockwise.
Definition at line 76 of file Mesh.cpp.
References AddIndex(), AddVertices(), DEBUG_ASSERT, and GetVerticesNum().
Referenced by carla::road::Map::GetAllCrosswalkMesh().
void carla::geom::Mesh::AddTriangleStrip | ( | const std::vector< vertex_type > & | vertices | ) |
Adds a triangle strip to the mesh, vertex order is counterclockwise.
Definition at line 47 of file Mesh.cpp.
References AddIndex(), AddVertices(), DEBUG_ASSERT, and GetVerticesNum().
Referenced by carla::geom::MeshFactory::Generate(), carla::geom::MeshFactory::GenerateLeftWall(), and carla::geom::MeshFactory::GenerateRightWall().
void carla::geom::Mesh::AddUV | ( | uv_type | uv | ) |
void carla::geom::Mesh::AddUVs | ( | const std::vector< uv_type > & | uv | ) |
Appends uvs.
Definition at line 109 of file Mesh.cpp.
References _uvs.
Referenced by carla::geom::MeshFactory::GenerateSidewalk(), and carla::geom::MeshFactory::GenerateTesselated().
void carla::geom::Mesh::AddVertex | ( | vertex_type | vertex | ) |
Appends a vertex to the vertices list.
Definition at line 89 of file Mesh.cpp.
References _vertices.
Referenced by carla::geom::MeshFactory::GenerateLaneMarksForCenterLine(), carla::geom::MeshFactory::GenerateLaneMarksForNotCenterLine(), and carla::road::Map::SDFToMesh().
void carla::geom::Mesh::AddVertices | ( | const std::vector< vertex_type > & | vertices | ) |
Appends a vertex to the vertices list.
Definition at line 93 of file Mesh.cpp.
References _vertices.
Referenced by AddTriangleFan(), AddTriangleStrip(), carla::geom::MeshFactory::GenerateSidewalk(), and carla::geom::MeshFactory::GenerateTesselated().
Merges two meshes into a single mesh.
Definition at line 294 of file Mesh.cpp.
References _indexes, _materials, _normals, _uvs, _vertices, GetIndexes(), GetIndexesNum(), GetMaterials(), GetNormals(), GetUVs(), GetVertices(), GetVerticesNum(), and IsValid().
void carla::geom::Mesh::EndMaterial | ( | ) |
Stops applying the material to the new added triangles.
Definition at line 129 of file Mesh.cpp.
References _indexes, and _materials.
Referenced by AddMaterial(), carla::geom::MeshFactory::Generate(), carla::geom::MeshFactory::GenerateLeftWall(), carla::geom::MeshFactory::GenerateRightWall(), carla::geom::MeshFactory::GenerateSidewalk(), carla::geom::MeshFactory::GenerateTesselated(), and carla::road::Map::GetAllCrosswalkMesh().
std::string carla::geom::Mesh::GenerateOBJ | ( | ) | const |
std::string carla::geom::Mesh::GenerateOBJForRecast | ( | ) | const |
Returns a string containing the mesh encoded in OBJ.
Units are in meters. This function exports the OBJ file specifically to be consumed by Recast library. Changes the build face direction and the coordinate space.
Definition at line 202 of file Mesh.cpp.
References _indexes, _materials, _vertices, and IsValid().
std::string carla::geom::Mesh::GeneratePLY | ( | ) | const |
const std::vector< Mesh::index_type > & carla::geom::Mesh::GetIndexes | ( | ) | const |
Definition at line 271 of file Mesh.cpp.
References _indexes.
Referenced by ConcatMesh(), and operator+=().
std::vector< Mesh::index_type > & carla::geom::Mesh::GetIndexes | ( | ) |
size_t carla::geom::Mesh::GetIndexesNum | ( | ) | const |
Definition at line 278 of file Mesh.cpp.
References _indexes.
Referenced by ConcatMesh(), and operator+=().
size_t carla::geom::Mesh::GetLastVertexIndex | ( | ) | const |
const std::vector< Mesh::material_type > & carla::geom::Mesh::GetMaterials | ( | ) | const |
Definition at line 286 of file Mesh.cpp.
References _materials.
Referenced by ConcatMesh(), and operator+=().
const std::vector< Mesh::normal_type > & carla::geom::Mesh::GetNormals | ( | ) | const |
Definition at line 267 of file Mesh.cpp.
References _normals.
Referenced by ConcatMesh(), and operator+=().
const std::vector< Mesh::uv_type > & carla::geom::Mesh::GetUVs | ( | ) | const |
Definition at line 282 of file Mesh.cpp.
References _uvs.
Referenced by ConcatMesh(), and operator+=().
const std::vector< Mesh::vertex_type > & carla::geom::Mesh::GetVertices | ( | ) | const |
Definition at line 255 of file Mesh.cpp.
References _vertices.
Referenced by ConcatMesh(), carla::geom::MeshFactory::GenerateLaneMarksForCenterLine(), carla::geom::MeshFactory::GenerateLaneMarksForNotCenterLine(), operator+=(), and carla::road::Map::SDFToMesh().
std::vector< Mesh::vertex_type > & carla::geom::Mesh::GetVertices | ( | ) |
size_t carla::geom::Mesh::GetVerticesNum | ( | ) | const |
Definition at line 263 of file Mesh.cpp.
References _vertices.
Referenced by AddTriangleFan(), AddTriangleStrip(), ConcatMesh(), and operator+=().
bool carla::geom::Mesh::IsValid | ( | ) | const |
Check if the mesh can be valid or not.
Definition at line 20 of file Mesh.cpp.
References _indexes, _materials, and _vertices.
Referenced by ConcatMesh(), carla::geom::MeshFactory::GenerateLaneMarksForCenterLine(), carla::geom::MeshFactory::GenerateLaneMarksForNotCenterLine(), GenerateOBJ(), GenerateOBJForRecast(), and GeneratePLY().
Merges two meshes into a single mesh.
Definition at line 347 of file Mesh.cpp.
References _indexes, _materials, _normals, _uvs, _vertices, GetIndexes(), GetIndexesNum(), GetMaterials(), GetNormals(), GetUVs(), GetVertices(), and GetVerticesNum().
|
private |
Definition at line 239 of file Mesh.h.
Referenced by AddIndex(), AddMaterial(), ConcatMesh(), EndMaterial(), GenerateOBJ(), GenerateOBJForRecast(), GetIndexes(), GetIndexesNum(), IsValid(), and operator+=().
|
private |
Definition at line 243 of file Mesh.h.
Referenced by AddMaterial(), ConcatMesh(), EndMaterial(), GenerateOBJ(), GenerateOBJForRecast(), GetMaterials(), IsValid(), and operator+=().
|
private |
Definition at line 237 of file Mesh.h.
Referenced by AddNormal(), ConcatMesh(), GenerateOBJ(), GetNormals(), and operator+=().
|
private |
Definition at line 241 of file Mesh.h.
Referenced by AddUV(), AddUVs(), ConcatMesh(), GenerateOBJ(), GetUVs(), and operator+=().
|
private |
Definition at line 235 of file Mesh.h.
Referenced by AddVertex(), AddVertices(), ConcatMesh(), GenerateOBJ(), GenerateOBJForRecast(), GetLastVertexIndex(), GetVertices(), GetVerticesNum(), IsValid(), and operator+=().