-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.h
55 lines (44 loc) · 989 Bytes
/
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
#pragma once
#include <vector>
using namespace std;
struct Vertex
{
float* coords, * normals; //3d coordinates etc
int idx; //who am i; verts[idx]
vector< int > vertList; //adj vertices
vector< int > triList;
vector< int > edgeList;
Vertex(int i, float* c) : idx(i), coords(c) {};
};
struct Edge
{
int idx; //edges[idx]
int v1i, v2i; //endpnts
float length;
Edge(int id, int v1, int v2) : idx(id), v1i(v1), v2i(v2) { computeLength(); };
void computeLength()
{
length = 7;
}
};
struct Triangle
{
int idx; //tris[idx]
int v1i, v2i, v3i;
Triangle(int id, int v1, int v2, int v3) : idx(id), v1i(v1), v2i(v2), v3i(v3) {};
};
class Mesh
{
private:
void addTriangle(int v1, int v2, int v3);
void addEdge(int v1, int v2);
void addVertex(float x, float y, float z);
bool makeVertsNeighbor(int v1i, int v2i);
public:
vector< Vertex* > verts;
vector< Triangle* > tris;
vector< Edge* > edges;
Mesh() {};
void createCube(float side);
void loadOff(char* name);
};