14 #ifdef LIBCARLA_INCLUDED_FROM_UE4 18 #endif // LIBCARLA_INCLUDED_FROM_UE4 28 const std::string &new_name,
57 Mesh(
const std::vector<vertex_type> &vertices = {},
58 const std::vector<normal_type> &normals = {},
59 const std::vector<index_type> &indexes = {},
60 const std::vector<uv_type> &uvs = {})
61 : _vertices(vertices),
78 void AddTriangleStrip(
const std::vector<vertex_type> &vertices);
81 void AddTriangleFan(
const std::vector<vertex_type> &vertices);
87 void AddVertices(
const std::vector<vertex_type> &vertices);
99 void AddUVs(
const std::vector<uv_type> & uv);
102 void AddMaterial(
const std::string &material_name);
113 std::string GenerateOBJ()
const;
119 std::string GenerateOBJForRecast()
const;
123 std::string GeneratePLY()
const;
129 const std::vector<vertex_type> &GetVertices()
const;
131 std::vector<vertex_type> &GetVertices();
133 size_t GetVerticesNum()
const;
135 const std::vector<normal_type> &GetNormals()
const;
137 const std::vector<index_type>& GetIndexes()
const;
139 std::vector<index_type> &GetIndexes();
141 size_t GetIndexesNum()
const;
143 const std::vector<uv_type> &GetUVs()
const;
145 const std::vector<material_type> &GetMaterials()
const;
148 size_t GetLastVertexIndex()
const;
151 Mesh& ConcatMesh(
const Mesh& rhs,
int num_vertices_to_link);
162 #ifdef LIBCARLA_INCLUDED_FROM_UE4 168 for (
const auto Vertex : GetVertices())
171 Mesh.
Vertices.Add(FVector{1e2f * Vertex.x, 1e2f * Vertex.y, 1e2f * Vertex.z});
174 const auto Indexes = GetIndexes();
175 TArray<FTriIndices> TriIndices;
176 for (
auto i = 0u; i < Indexes.size(); i += 3)
185 Triangle.v0 = Indexes[i] - 1;
186 Triangle.v1 = Indexes[i + 2] - 1;
187 Triangle.v2 = Indexes[i + 1] - 1;
188 TriIndices.Add(Triangle);
192 TArray<FVector> Normals;
195 for (
const auto &
Triangle : TriIndices) {
199 Normal.X = (U.Y * V.Z) - (U.Z * V.Y);
200 Normal.Y = (U.Z * V.X) - (U.X * V.Z);
201 Normal.Z = (U.X * V.Y) - (U.Y * V.X);
203 Normal = Normal.GetSafeNormal(.0001f);
204 if (Normal != FVector::ZeroVector)
208 if (FVector::DotProduct(Normal, FVector(0,0,1)) < 0)
218 for (
const auto uv : GetUVs())
221 Mesh.
UV0.Add(FVector2D{uv.x, uv.y});
227 #endif // LIBCARLA_INCLUDED_FROM_UE4
A definition of a Carla Mesh.
Mesh operator+(const Mesh &lhs, const Mesh &rhs)
MeshMaterial(const std::string &new_name, size_t start=0u, size_t end=0u)
TArray< int32 > Triangles
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={})
This file contains definitions of common data structures used in traffic manager. ...
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
TArray< FVector > Normals
Material that references the vertex index start and end of a mesh where it is affecting.
TArray< FVector > Vertices
std::vector< material_type > _materials
Mesh data container, validator and exporter.
std::array< int, 3 > Triangle
std::vector< index_type > _indexes
std::vector< uv_type > _uvs
std::vector< normal_type > _normals
std::vector< vertex_type > _vertices