CARLA
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
carla::geom::Mesh Class Reference

Mesh data container, validator and exporter. More...

#include <Mesh.h>

+ Collaboration diagram for carla::geom::Mesh:

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 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...
 
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
 
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={})
 
Meshoperator+= (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)
 

Detailed Description

Mesh data container, validator and exporter.

Definition at line 42 of file Mesh.h.

Member Typedef Documentation

◆ index_type

Definition at line 47 of file Mesh.h.

◆ material_type

Definition at line 49 of file Mesh.h.

◆ normal_type

Definition at line 46 of file Mesh.h.

◆ uv_type

Definition at line 48 of file Mesh.h.

◆ vertex_type

Definition at line 45 of file Mesh.h.

Constructor & Destructor Documentation

◆ Mesh()

carla::geom::Mesh::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 = {} 
)
inline

Definition at line 55 of file Mesh.h.

References IsValid(), FProceduralCustomMesh::Normals, carla::geom::operator+(), FProceduralCustomMesh::Triangles, and FProceduralCustomMesh::Vertices.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddIndex()

void carla::geom::Mesh::AddIndex ( index_type  index)

Appends a index to the indexes list.

Definition at line 99 of file Mesh.cpp.

References _indexes.

Referenced by AddTriangleFan(), and AddTriangleStrip().

+ Here is the caller graph for this function:

◆ AddMaterial()

void carla::geom::Mesh::AddMaterial ( const std::string &  material_name)

Starts applying a new material to the new added triangles.

Definition at line 107 of file Mesh.cpp.

References _indexes, _materials, and EndMaterial().

Referenced by carla::geom::MeshFactory::Generate(), carla::geom::MeshFactory::GenerateLeftWall(), carla::geom::MeshFactory::GenerateRightWall(), and carla::road::Map::GetAllCrosswalkMesh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddNormal()

void carla::geom::Mesh::AddNormal ( normal_type  normal)

Appends a normal to the normal list.

Definition at line 95 of file Mesh.cpp.

References _normals.

◆ AddTriangleFan()

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 74 of file Mesh.cpp.

References AddIndex(), AddVertices(), DEBUG_ASSERT, and GetVerticesNum().

Referenced by carla::road::Map::GetAllCrosswalkMesh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddTriangleStrip()

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 45 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddUV()

void carla::geom::Mesh::AddUV ( uv_type  uv)

Appends a vertex to the vertices list, they will be read 3 in 3.

Definition at line 103 of file Mesh.cpp.

References _uvs.

◆ AddVertex()

void carla::geom::Mesh::AddVertex ( vertex_type  vertex)

Appends a vertex to the vertices list.

Definition at line 87 of file Mesh.cpp.

References _vertices.

◆ AddVertices()

void carla::geom::Mesh::AddVertices ( const std::vector< vertex_type > &  vertices)

Appends a vertex to the vertices list.

Definition at line 91 of file Mesh.cpp.

References _vertices.

Referenced by AddTriangleFan(), and AddTriangleStrip().

+ Here is the caller graph for this function:

◆ EndMaterial()

void carla::geom::Mesh::EndMaterial ( )

Stops applying the material to the new added triangles.

Definition at line 123 of file Mesh.cpp.

References _indexes, and _materials.

Referenced by AddMaterial(), carla::geom::MeshFactory::Generate(), carla::geom::MeshFactory::GenerateLeftWall(), carla::geom::MeshFactory::GenerateRightWall(), and carla::road::Map::GetAllCrosswalkMesh().

+ Here is the caller graph for this function:

◆ GenerateOBJ()

std::string carla::geom::Mesh::GenerateOBJ ( ) const

Returns a string containing the mesh encoded in OBJ.

Units are in meters. It is in Unreal space.

Definition at line 140 of file Mesh.cpp.

References _indexes, _materials, _normals, _uvs, _vertices, and IsValid().

+ Here is the call graph for this function:

◆ GenerateOBJForRecast()

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 196 of file Mesh.cpp.

References _indexes, _materials, _vertices, and IsValid().

+ Here is the call graph for this function:

◆ GeneratePLY()

std::string carla::geom::Mesh::GeneratePLY ( ) const

Returns a string containing the mesh encoded in PLY.

Units are in meters.

Definition at line 240 of file Mesh.cpp.

References IsValid().

+ Here is the call graph for this function:

◆ GetIndexes()

const std::vector< Mesh::index_type > & carla::geom::Mesh::GetIndexes ( ) const

Definition at line 265 of file Mesh.cpp.

References _indexes.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetIndexesNum()

size_t carla::geom::Mesh::GetIndexesNum ( ) const

Definition at line 269 of file Mesh.cpp.

References _indexes.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetLastVertexIndex()

size_t carla::geom::Mesh::GetLastVertexIndex ( ) const

Returns the index of the last added vertex (number of vertices).

Definition at line 281 of file Mesh.cpp.

References _vertices.

◆ GetMaterials()

const std::vector< Mesh::material_type > & carla::geom::Mesh::GetMaterials ( ) const

Definition at line 277 of file Mesh.cpp.

References _materials.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetNormals()

const std::vector< Mesh::normal_type > & carla::geom::Mesh::GetNormals ( ) const

Definition at line 261 of file Mesh.cpp.

References _normals.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetUVs()

const std::vector< Mesh::uv_type > & carla::geom::Mesh::GetUVs ( ) const

Definition at line 273 of file Mesh.cpp.

References _uvs.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetVertices() [1/2]

const std::vector< Mesh::vertex_type > & carla::geom::Mesh::GetVertices ( ) const

Definition at line 249 of file Mesh.cpp.

References _vertices.

Referenced by operator+=().

+ Here is the caller graph for this function:

◆ GetVertices() [2/2]

std::vector< Mesh::vertex_type > & carla::geom::Mesh::GetVertices ( )

Definition at line 253 of file Mesh.cpp.

References _vertices.

◆ GetVerticesNum()

size_t carla::geom::Mesh::GetVerticesNum ( ) const

Definition at line 257 of file Mesh.cpp.

References _vertices.

Referenced by AddTriangleFan(), AddTriangleStrip(), and operator+=().

+ Here is the caller graph for this function:

◆ IsValid()

bool carla::geom::Mesh::IsValid ( ) const

Check if the mesh can be valid or not.

Definition at line 18 of file Mesh.cpp.

References _indexes, _materials, and _vertices.

Referenced by GenerateOBJ(), GenerateOBJForRecast(), and GeneratePLY().

+ Here is the caller graph for this function:

◆ operator+=()

Mesh & carla::geom::Mesh::operator+= ( const Mesh rhs)

Merges two meshes into a single mesh.

Definition at line 285 of file Mesh.cpp.

References _indexes, _materials, _normals, _uvs, _vertices, GetIndexes(), GetIndexesNum(), GetMaterials(), GetNormals(), GetUVs(), GetVertices(), and GetVerticesNum().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator+

Mesh operator+ ( const Mesh lhs,
const Mesh rhs 
)
friend

Definition at line 323 of file Mesh.cpp.

Member Data Documentation

◆ _indexes

std::vector<index_type> carla::geom::Mesh::_indexes
private

◆ _materials

std::vector<material_type> carla::geom::Mesh::_materials
private

◆ _normals

std::vector<normal_type> carla::geom::Mesh::_normals
private

Definition at line 221 of file Mesh.h.

Referenced by AddNormal(), GenerateOBJ(), GetNormals(), and operator+=().

◆ _uvs

std::vector<uv_type> carla::geom::Mesh::_uvs
private

Definition at line 225 of file Mesh.h.

Referenced by AddUV(), GenerateOBJ(), GetUVs(), and operator+=().

◆ _vertices

std::vector<vertex_type> carla::geom::Mesh::_vertices
private

The documentation for this class was generated from the following files: