-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangleMesh.h
70 lines (49 loc) · 1.46 KB
/
TriangleMesh.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
65
66
67
68
69
70
#ifndef _TRIANGLE_MESH_INCLUDE
#define _TRIANGLE_MESH_INCLUDE
#include <string>
#include <vector>
#include <deque>
#include <glm/glm.hpp>
#include "ShaderProgram.h"
#include "Ray.hpp"
#include "PointOctree.hpp"
#include "TrianglesOctree.hpp"
using namespace std;
// Class TriangleMesh renders a very simple room with textures
class TriangleMesh
{
public:
TriangleMesh();
void addVertex(const glm::vec3 &position);
void addTriangle(int v0, int v1, int v2);
void buildCube();
void buildTile();
void buildDot();
void Preprocess();
TriangleMesh * VertexClustering(size_t depth);
TriangleMesh * VertexClustering_GRID(size_t grid_size);
int RayCast(Ray3D ray, bool use_triangles = true);
void TestRaysPerSecond(size_t total_rays);
void sendToOpenGL(ShaderProgram &program);
void render(ShaderProgram &program) const;
void renderPoints() const;
void free();
private:
vector<glm::vec3> vertices;
vector<unsigned int> triangles;
vector<glm::vec3> triangle_normals;
vector<std::deque<int>> faces_per_vertex_;
vector<glm::vec3> vertex_colors;
vector<glm::vec3> vertex_normals;
/* Bounding box info */
GLfloat min_x, max_x, min_y, max_y, min_z, max_z;
PointOctree<int, 1> * octree_vertices;
TrianglesOctree<5, 15> * octree_triangles;
GLuint vao;
GLuint ebo;
GLuint vbo_position;
GLuint vbo_normals;
GLint posLocation;
GLint normalLocation;
};
#endif // _TRIANGLE_MESH_INCLUDE