14 #ifdef LIBCARLA_INCLUDED_FROM_UE4 16 #endif // LIBCARLA_INCLUDED_FROM_UE4 26 const std::string &new_name,
55 Mesh(
const std::vector<vertex_type> &vertices = {},
56 const std::vector<normal_type> &normals = {},
57 const std::vector<index_type> &indexes = {},
58 const std::vector<uv_type> &uvs = {})
59 : _vertices(vertices),
76 void AddTriangleStrip(
const std::vector<vertex_type> &vertices);
79 void AddTriangleFan(
const std::vector<vertex_type> &vertices);
85 void AddVertices(
const std::vector<vertex_type> &vertices);
97 void AddMaterial(
const std::string &material_name);
108 std::string GenerateOBJ()
const;
114 std::string GenerateOBJForRecast()
const;
118 std::string GeneratePLY()
const;
124 const std::vector<vertex_type> &GetVertices()
const;
126 std::vector<vertex_type> &GetVertices();
128 size_t GetVerticesNum()
const;
130 const std::vector<normal_type> &GetNormals()
const;
132 const std::vector<index_type> &GetIndexes()
const;
134 size_t GetIndexesNum()
const;
136 const std::vector<uv_type> &GetUVs()
const;
138 const std::vector<material_type> &GetMaterials()
const;
141 size_t GetLastVertexIndex()
const;
152 #ifdef LIBCARLA_INCLUDED_FROM_UE4 158 for (
const auto Vertex : GetVertices())
161 Mesh.
Vertices.Add(FVector{1e2f * Vertex.x, 1e2f * Vertex.y, 1e2f * Vertex.z});
164 const auto Indexes = GetIndexes();
165 TArray<FTriIndices> TriIndices;
166 for (
auto i = 0u; i < Indexes.size(); i += 3)
168 FTriIndices Triangle;
175 Triangle.v0 = Indexes[i] - 1;
176 Triangle.v1 = Indexes[i + 2] - 1;
177 Triangle.v2 = Indexes[i + 1] - 1;
178 TriIndices.Add(Triangle);
182 TArray<FVector> Normals;
185 for (
const auto &Triangle : TriIndices) {
189 Normal.X = (U.Y * V.Z) - (U.Z * V.Y);
190 Normal.Y = (U.Z * V.X) - (U.X * V.Z);
191 Normal.Z = (U.X * V.Y) - (U.Y * V.X);
193 Normal = Normal.GetSafeNormal(.0001f);
194 if (Normal != FVector::ZeroVector)
198 if (FVector::DotProduct(Normal, FVector(0,0,1)) < 0)
202 Mesh.
Normals[Triangle.v0] = Normal;
203 Mesh.
Normals[Triangle.v1] = Normal;
204 Mesh.
Normals[Triangle.v2] = Normal;
211 #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::vector< index_type > _indexes
std::vector< uv_type > _uvs
std::vector< normal_type > _normals
std::vector< vertex_type > _vertices