6 #include <reactphysics3d/collision/shapes/ConcaveMeshShape.h>
7 #include <reactphysics3d/collision/TriangleMesh.h>
8 #include <reactphysics3d/collision/TriangleVertexArray.h>
17 using std::make_unique;
19 using std::unique_ptr;
29 TerrainMesh::TerrainMesh()
36 vector<Triangle> triangles;
37 vector<Vector3> indexedVertices;
40 for (
const auto& triangle: triangles) {
41 for (
const auto& vertex: triangle.getVertices()) {
44 for (; i < indexedVertices.size(); i++) {
45 if (indexedVertices[i].equals(vertexTransformed) ==
true)
break;
47 if (i == indexedVertices.size()) {
48 indexedVertices.push_back(vertexTransformed);
49 vertices.push_back(vertexTransformed[0]);
50 vertices.push_back(vertexTransformed[1]);
51 vertices.push_back(vertexTransformed[2]);
68 Console::println(
"TerrainMesh::setScale(): != 1.0f: Not supported!");
75 Console::println(
"TerrainMesh::setTransform(): Not supported!");
89 if (this->world !=
nullptr && this->world !=
world) {
90 Console::println(
"TerrainMesh::createCollisionShape(): already attached to a world.");
96 static_cast<uint32_t
>(
vertices.size() / 3),
99 static_cast<uint32_t
>(
indices.size() / 3),
102 reactphysics3d::TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE,
103 reactphysics3d::TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE
117 terrainMesh->indices =
indices;
Dynamic physics world class.
reactphysics3d::PhysicsCommon physicsCommon
Bounding volume interface.
reactphysics3d::CollisionShape * collisionShape
Terrain mesh physics primitive.
vector< int32_t > indices
reactphysics3d::TriangleMesh * triangleMesh
BoundingVolume * clone() const override
Clones this bounding volume.
unique_ptr< reactphysics3d::TriangleVertexArray > triangleVertexArray
void setTransform(const Transform &transform) override
Transform bounding volume from given transform.
~TerrainMesh()
Destructor.
void destroyCollisionShape() override
Destroy collision shape.
void setScale(const Vector3 &scale) override
Set local scale.
TerrainMesh()
Public constructor.
void createCollisionShape(World *world) override
Create collision shap.
Triangle entity, this is not directly connectable with physics engine.
void getTriangles(vector< Triangle > &triangles, int nodeIdx=-1)
Retrieves list of triangles of all or given nodes.
Vector3 multiply(const Vector3 &vector3) const
Multiplies this matrix with vector3.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector3 & set(float x, float y, float z)
Sets this vector3 by its components.
bool equals(const Vector3 &vector3, float tolerance=Math::EPSILON) const
Compares this vector3 with given vector3.