diff options
Diffstat (limited to 'assetFactory/factoryMesh.cpp')
-rw-r--r-- | assetFactory/factoryMesh.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp new file mode 100644 index 0000000..1b89d14 --- /dev/null +++ b/assetFactory/factoryMesh.cpp @@ -0,0 +1,27 @@ +#include "factoryMesh.h" +#include "assetFactoryConfig.h" +#include "collections.hpp" +#include "gfx/models/vertex.hpp" +#include <glm/ext/matrix_transform.hpp> + +Mesh::Ptr +FactoryMesh::createMesh() const +{ + constexpr glm::vec2 NullUV {}; + + ModelFactoryMesh mesh; + for (const auto & use : uses) { + use->createMesh(mesh, glm::identity<Mutation::Matrix>()); + } + mesh.garbage_collection(); + + mesh.triangulate(); + mesh.update_face_normals(); + std::vector<Vertex> vertices; + for (const auto & face : mesh.faces()) { + for (const auto & vertex : mesh.fv_range(face)) { + vertices.emplace_back(mesh.point(vertex), NullUV, mesh.property(mesh.face_normals_pph(), face)); + } + } + return std::make_shared<Mesh>(vertices, vectorOfN(vertices.size())); +} |