summaryrefslogtreecommitdiff
path: root/assetFactory/modelFactoryMesh.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-02-16 23:54:22 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-02-16 23:54:22 +0000
commitc22c676dfee583bd48e1f962378f580f8310838b (patch)
treea060664c21934da0c54d54ac42f0a5ded5813498 /assetFactory/modelFactoryMesh.h
parentFirst cut of the model factory and the hardcoded Brush 47 model (diff)
downloadilt-c22c676dfee583bd48e1f962378f580f8310838b.tar.bz2
ilt-c22c676dfee583bd48e1f962378f580f8310838b.tar.xz
ilt-c22c676dfee583bd48e1f962378f580f8310838b.zip
Refactor so ModelFactoryMesh can define the smooth property on faces
Diffstat (limited to 'assetFactory/modelFactoryMesh.h')
-rw-r--r--assetFactory/modelFactoryMesh.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h
new file mode 100644
index 0000000..d0ffc26
--- /dev/null
+++ b/assetFactory/modelFactoryMesh.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "modelFactoryMesh_fwd.h"
+#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
+#include <OpenMesh/Core/Mesh/Traits.hh>
+#include <glm/geometric.hpp>
+#include <glm/vec3.hpp>
+
+namespace OpenMesh {
+ template<typename Scalar, int DIM> struct glmvec : public VectorT<Scalar, DIM> {
+ using VectorT<Scalar, DIM>::VectorT;
+ glmvec(const VectorT<Scalar, DIM> & v) : VectorT<Scalar, DIM> {v} { }
+ operator glm::vec<DIM, Scalar>() const
+ {
+ glm::vec<DIM, Scalar> out;
+ std::copy(this->begin(), this->end(), &out[0]);
+ return out;
+ }
+ };
+}
+
+struct ModelFactoryTraits : public OpenMesh::DefaultTraits {
+ FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
+ EdgeAttributes(OpenMesh::Attributes::Status);
+ VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
+ using Point = OpenMesh::glmvec<float, 3>;
+ using Normal = OpenMesh::glmvec<float, 3>;
+};
+
+struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT<ModelFactoryTraits> {
+ ModelFactoryMesh();
+
+ OpenMesh::FPropHandleT<bool> smoothFaceProperty;
+};