-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWEMesh.h
More file actions
144 lines (116 loc) · 4.26 KB
/
WEMesh.h
File metadata and controls
144 lines (116 loc) · 4.26 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//
// Created by madhawa on 2020-02-01.
//
#ifndef NANOGUI_TEST_WEMESH_H
#include <WingedEdge/Vertex.h>
#include <WingedEdge/Face.h>
#include <nanogui/common.h>
#include <WingedEdge/OBJMesh.h>
#include <WingedEdge/Edge.h>
namespace WingedEdge {
#define NANOGUI_TEST_WEMESH_H
/**
* Class used to hold WingedEdge representation of a Mesh.
*/
class WEMesh {
public:
WEMesh();
~WEMesh();
/**
* Populates WingedEdge faces, edges and vertices with appropriate inter-links using provided vertices and faces (vertex indices)
* @param vertices 3xn array of vertices
* @param faces 3xt array of vertex indices of each triangular face
* @return true if success
*/
bool loadModel(nanogui::MatrixXf vertices, nanogui::MatrixXu faces);
/**
* Populates VertexMatrix, NormalMatrix and FaceMatrix for Smooth Shading Purpose.
* @return True if success
*/
bool populateSmoothShadingMatrices();
/**
* Populates VertexMatrix, NormalMatrix and FaceMatrix for Flat Shading Purpose.
* @return True if success
*/
bool populateFlatShadingMatrices();
/**
* Populates ExpandedVertexMatrix, that holds vertices used to draw wireFrame on top of shaded mesh.
* @param epsilon Expansion length
*/
void populateExpandedVertexMatrix(float epsilon);
/**
* Fill vertices and faces matrix of provided objMesh using the information available in WingedEdge structure.
* @param objMesh
*/
void fillOBJMesh(WingedEdge::OBJMesh* objMesh) const;
/**
* Check whether a model is loaded.
* @return True if model is loaded. Otherwise false.
*/
bool isModelLoaded() const;
/**
* Returns minimum coordinate in all 3 axis. Used to set camera parameters when a new model is loaded.
* @return
*/
nanogui::Vector3f getMinPoint() const;
/**
* Returns maximum coordinate in all 3 axis. Used to set camera parameters when a new model is loaded.
* @return
*/
nanogui::Vector3f getMaxPoint() const;
/**
* Returns matrix of normals used for rendering purpose. Populated by populateFlatShadingMatrices or populateSmoothShadingMatrices
* @return
*/
nanogui::MatrixXf getNormalMatrix() const;
/**
* Returns matrix of vertices used for rendering purpose. Populated by populateFlatShadingMatrices or populateSmoothShadingMatrices
* @return
*/
nanogui::MatrixXf getVertexMatrix() const;
/**
* Returns matrix of faces used for rendering purpose. Populated by populateFlatShadingMatrices or populateSmoothShadingMatrices
* @return
*/
nanogui::MatrixXu getFaceMatrix() const;
/**
* Returns matrix of vertices used for rendering wireframes on top of solid mesh. Populated by populateExpandedVertexMatrix.
* @return
*/
nanogui::MatrixXf getExpandedVertexMatrix() const;
Vertex* getVertices() const;
Edge* getEdges() const;
Face* getFaces() const;
int getVertexCount() const;
int getEdgeCount() const;
int getFaceCount() const;
void allocateVertices(int v);
void allocateEdges(int e);
void allocateFaces(int f);
private:
// WingedEdge elements live in following arrays
Vertex* mVertices;
Edge* mEdges;
Face* mFaces;
int mVertexCount;
int mFaceCount;
int mEdgeCount;
nanogui::Vector3f mMinPoint;
nanogui::Vector3f mMaxPoint;
// Populated by populateFlatShadingMatrix, populateSmoothShadingMatrix methods
nanogui::MatrixXf mNormalMatrix;
nanogui::MatrixXf mVertexMatrix;
nanogui::MatrixXu mFaceMatrix;
// Populated by populateExpandedVertexMatrix method
nanogui::MatrixXf mExpandedVertexMatrix;
// Used to avoid re-calculations
bool mSmoothedShaded;
bool mFlatShaded;
bool mModelLoaded;
/**
* Unload mesh.
*/
void unloadModel();
};
}
#endif //NANOGUI_TEST_WEMESH_H