1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#pragma once
#include "modelFactoryMesh_fwd.h"
#include <GL/glew.h>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Mesh/Traits.hh>
#include <glm/geometric.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
namespace glm {
template<length_t L, typename T, qualifier Q>
auto
norm(const vec<L, T, Q> & v)
{
return length(v);
}
template<length_t L, typename T, qualifier Q, typename S>
auto
vectorize(vec<L, T, Q> & v, S scalar)
{
v = vec<L, T, Q> {static_cast<T>(scalar)};
}
}
namespace OpenMesh {
template<glm::length_t L, typename T, glm::qualifier Q> struct vector_traits<glm::vec<L, T, Q>> {
using vector_type = glm::vec<L, T, Q>;
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<ModelFactoryTraits> {
ModelFactoryMesh();
OpenMesh::FPropHandleT<bool> smoothFaceProperty;
OpenMesh::FPropHandleT<GLuint> materialFaceProperty;
OpenMesh::FPropHandleT<std::string> nameFaceProperty;
OpenMesh::HPropHandleT<std::string> nameAdjFaceProperty;
template<typename... Vs>
std::pair<std::string, OpenMesh::FaceHandle>
add_namedFace(std::string name, Vs &&... vs)
{
const auto handle = add_face(std::forward<Vs>(vs)...);
configNamedFace(name, handle);
return {std::move(name), handle};
}
private:
void configNamedFace(const std::string & name, OpenMesh::FaceHandle);
};
|