forked from bshea5/Workspace_3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMesh.h
64 lines (59 loc) · 2.6 KB
/
Mesh.h
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
/*
Mesh.h
Mesh will store the vertices(vec4's) in a 2D vector. There will be a
default set of vertices, but the user can change the number of columns
and rows. The user can also change the width of each row. The
vertices will be used to draw the faces in a mesh
Use algebra3 to store xyz coordinates as vec4 objects
*/
#include "algebra3.h"
#include <vector>
class Mesh {
private:
int wireframe; // toggle wireframe = 1
int numCols; // number of columns in terms of faces
int numRows; // number of rows in terms of faces
int numPolys; // number of faces
double rowWidth; // width of each row
double colDepth; // depth of each column
const int MAXHEIGHT = 2;// maximun z value for height to the mesh
double color[3]; // rgb color
std::vector<std::vector<vec4> > v; /* vector of vectors, sub-vectors
hold vertices for a row */
std::vector<std::vector<vec4> > original; // hold the original mesh here to revert back
public:
// constructors ////////
Mesh(); // default a mesh
Mesh(int c, int r, double w, double d, double rgb[3]); //constructor with parameters for mesh
~Mesh(); // deconstructor
///////////////////////////
// Getters and Setters ////
const int getWireFrame(); // return wireframe status
const int getNumCols();
const int getNumRows();
const int getNumPolys();
const double getRowWidth();
const double getColDepth();
const double getRed(); // return red value
const double getGreen(); // return green value
const double getBlue(); // return blue value
const mat4 getQuad(int q); // get a Quad from vertices
const vec4 getVertex(int r, int c); // get a vertex
std::vector<std::vector<vec4>> getVertices();
void setWireFrame(int n); // toggle wireframe status
void setNumCols(int n); // set number of columns
void setNumRows(int n); // set number of rows
void setRowWidth(double n); // set width of each row
void setColDepth(double n); // set depth of each column
void setColor(double rgb[3]); // set color of the mesh
void setVertex(int r, int c, vec4 vertex); // change a vertex
void setVertices(std::vector<std::vector<vec4>> newV); // set new mesh
void setOriginal(); // save current mesh as the original
///////////////////////////
// Other functions //////////////
///////////////////////////
void buildVertices(); // construct vertice based on fields
void printVertices(); // print each vertice in the mesh
void sub_divide(int n); // sub-divide n times
void revertToOriginal(); // revert back to original mesh
};