summaryrefslogtreecommitdiff
path: root/assetFactory/modelFactoryMesh.h
blob: d0ffc26d61ddd79daa2536fee407b994fb419e38 (plain)
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
#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;
};