#pragma once #include "modelFactoryMesh_fwd.h" #include #include #include #include #include #include #include namespace glm { template auto norm(const vec & v) { return length(v); } template auto vectorize(vec & v, S scalar) { v = vec {static_cast(scalar)}; } } namespace OpenMesh { template struct vector_traits> { using vector_type = glm::vec; using value_type = T; static constexpr glm::length_t size_ = L; }; } 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); HalfedgeAttributes(OpenMesh::Attributes::TexCoord2D); using Point = glm::vec3; using Normal = glm::vec3; using Color = glm::vec4; using TexCoord2D = glm::vec2; }; struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT { ModelFactoryMesh(); OpenMesh::FPropHandleT smoothFaceProperty; OpenMesh::FPropHandleT materialFaceProperty; OpenMesh::FPropHandleT nameFaceProperty; OpenMesh::HPropHandleT nameAdjFaceProperty; template std::pair add_namedFace(std::string name, Vs &&... vs) { const auto handle = add_face(std::forward(vs)...); configNamedFace(name, handle); return {std::move(name), handle}; } private: void configNamedFace(const std::string & name, OpenMesh::FaceHandle); };