CARLA
Loading...
Searching...
No Matches
carla::geom::Mesh Class Reference

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.
void AddMaterial (const std::string &material_name)
 Starts applying a new material to the new added triangles.
void AddNormal (normal_type normal)
 Appends a normal to the normal list.
void AddTriangleFan (const std::vector< vertex_type > &vertices)
 Adds a triangle fan to the mesh, vertex order is counterclockwise.
void AddTriangleStrip (const std::vector< vertex_type > &vertices)
 Adds a triangle strip to the mesh, vertex order is counterclockwise.
void AddUV (uv_type uv)
 Appends a vertex to the vertices list, they will be read 3 in 3.
void AddUVs (const std::vector< uv_type > &uv)
 Appends uvs.
void AddVertex (vertex_type vertex)
 Appends a vertex to the vertices list.
void AddVertices (const std::vector< vertex_type > &vertices)
 Appends a vertex to the vertices list.
Mesh & ConcatMesh (const Mesh &rhs, int num_vertices_to_link)
 Merges two meshes into a single mesh.
void EndMaterial ()
 Stops applying the material to the new added triangles.
std::string GenerateOBJ () const
 Returns a string containing the mesh encoded in OBJ.
std::string GenerateOBJForRecast () const
 Returns a string containing the mesh encoded in OBJ.
std::string GeneratePLY () const
 Returns a string containing the mesh encoded in PLY.
std::vector< index_type > & GetIndexes ()
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).
const std::vector< material_type > & GetMaterials () const
const std::vector< normal_type > & GetNormals () const
const std::vector< uv_type > & GetUVs () const
std::vector< vertex_type > & GetVertices ()
const std::vector< vertex_type > & GetVertices () const
size_t GetVerticesNum () const
bool IsValid () const
 Check if the mesh can be valid or not.
 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={})
 operator FProceduralCustomMesh () const
Mesh & operator+= (const Mesh &rhs)
 Merges two meshes into a single mesh.

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 44 of file Mesh.h.

Member Typedef Documentation

◆ index_type

Definition at line 49 of file Mesh.h.

◆ material_type

Definition at line 51 of file Mesh.h.

◆ normal_type

Definition at line 48 of file Mesh.h.

◆ uv_type

Definition at line 50 of file Mesh.h.

◆ vertex_type

Definition at line 47 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 57 of file Mesh.h.

Referenced by ConcatMesh(), operator FProceduralCustomMesh(), operator+, and operator+=().

Member Function Documentation

◆ AddIndex()

◆ AddMaterial()

◆ AddNormal()

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

Appends a normal to the normal list.

Definition at line 97 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 76 of file Mesh.cpp.

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

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

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

References _uvs.

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

◆ AddUVs()

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

◆ AddVertex()

◆ AddVertices()

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

◆ ConcatMesh()

Mesh & carla::geom::Mesh::ConcatMesh ( const Mesh & rhs,
int num_vertices_to_link )

Merges two meshes into a single mesh.

Definition at line 346 of file Mesh.cpp.

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

◆ EndMaterial()

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

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

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

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

◆ GeneratePLY()

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

Returns a string containing the mesh encoded in PLY.

Units are in meters.

Definition at line 298 of file Mesh.cpp.

References IsValid().

◆ GetIndexes() [1/2]

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

Definition at line 327 of file Mesh.cpp.

References _indexes.

◆ GetIndexes() [2/2]

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

◆ GetIndexesNum()

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

Definition at line 330 of file Mesh.cpp.

References _indexes.

Referenced by ConcatMesh(), and operator+=().

◆ GetLastVertexIndex()

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

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

Definition at line 342 of file Mesh.cpp.

References _vertices.

◆ GetMaterials()

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

Definition at line 338 of file Mesh.cpp.

References _materials.

Referenced by ConcatMesh(), AOpenDriveGenerator::GenerateRoadMesh(), and operator+=().

◆ GetNormals()

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

Definition at line 319 of file Mesh.cpp.

References _normals.

Referenced by ConcatMesh(), and operator+=().

◆ GetUVs()

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

◆ GetVertices() [1/2]

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

Definition at line 311 of file Mesh.cpp.

References _vertices.

◆ GetVertices() [2/2]

◆ GetVerticesNum()

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

◆ IsValid()

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

◆ operator FProceduralCustomMesh()

◆ operator+=()

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

Merges two meshes into a single mesh.

Definition at line 400 of file Mesh.cpp.

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

◆ operator+

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

Definition at line 438 of file Mesh.cpp.

References Mesh(), and operator+.

Referenced by operator+.

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 245 of file Mesh.h.

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

◆ _uvs

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

Definition at line 249 of file Mesh.h.

Referenced by AddUV(), AddUVs(), ConcatMesh(), 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: