diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-05 01:59:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-05 01:59:16 +0000 |
commit | d4c073a18adaed73973f34c6c39fc15664d9211d (patch) | |
tree | 44536af3af0284ab75eae79ef81a5e4452019269 /assetFactory/modelFactoryMesh.h | |
parent | Add helper operator to perform vec3*mat4 and perspective divide (diff) | |
parent | Remove old hard coded asset factory test, run entirely from XML load and rend... (diff) | |
download | ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.bz2 ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.xz ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.zip |
Merge branch 'model-factory'
Diffstat (limited to 'assetFactory/modelFactoryMesh.h')
-rw-r--r-- | assetFactory/modelFactoryMesh.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h new file mode 100644 index 0000000..258913b --- /dev/null +++ b/assetFactory/modelFactoryMesh.h @@ -0,0 +1,39 @@ +#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> +#include <glm/vec4.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 | OpenMesh::Attributes::Color); + EdgeAttributes(OpenMesh::Attributes::Status); + VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); + using Point = OpenMesh::glmvec<float, 3>; + using Normal = OpenMesh::glmvec<float, 3>; + using Color = glm::vec4; +}; + +struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT<ModelFactoryTraits> { + ModelFactoryMesh(); + + OpenMesh::FPropHandleT<bool> smoothFaceProperty; + OpenMesh::FPropHandleT<std::string> nameFaceProperty; + + std::pair<std::string, OpenMesh::FaceHandle> add_namedFace(std::string name, std::vector<OpenMesh::VertexHandle> p); +}; |