From 715d4879fdd096ac82367984fdb22117d48737a4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 15 Feb 2023 02:26:06 +0000 Subject: First cut of the model factory and the hardcoded Brush 47 model Requires temporary change to the fragment shader to hardcode some visible colour to the model --- assetFactory/factoryMesh.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 assetFactory/factoryMesh.cpp (limited to 'assetFactory/factoryMesh.cpp') 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 + +Mesh::Ptr +FactoryMesh::createMesh() const +{ + constexpr glm::vec2 NullUV {}; + + ModelFactoryMesh mesh; + for (const auto & use : uses) { + use->createMesh(mesh, glm::identity()); + } + mesh.garbage_collection(); + + mesh.triangulate(); + mesh.update_face_normals(); + std::vector 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(vertices, vectorOfN(vertices.size())); +} -- cgit v1.2.3