-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMesh.h
92 lines (61 loc) · 1.95 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
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
#ifndef MESH_H
#define MESH_H
#include "ShaderLoader.h"
#include "SceneObject.h"
#include "Material.h"
#include <GL/glew.h>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/glm.hpp>
#include <string>
#include <vector>
using namespace std;
class Mesh
{
public:
Mesh();
virtual ~Mesh();
void Load(string input_file);
void Subdivide();
void ResetMesh();
void PrepareToDraw();
void DrawWireframe();
void Cleanup();
void Draw();
vector<ModelFace*> GetFaceIndexesFromVertexIndex(int modelIndex, int vertIndex);
void OutputToBitmap(string bmpName, int width, int height);
int Mesh::getTotalVertexCount();
GLuint LoadDefaultShaders();
GLuint LoadGouraudShaders();
void SetMVP(glm::mat4 mvp){ ModelViewProjectionMatrix = mvp; }
vector<GLfloat> GLF_getVertexPositions() { return vertex_positions; };
vector<GLfloat> GLF_getVertexColors() { return vertex_colors; };
vector<GLuint> GLUI_getFaceIndexes() { return face_indexes; };
vector<GLfloat> GLF_getFaceNormals() { return face_normals; };
void cacheVerticesFacesAndColors();
void cacheVerticesFacesAndColors_Radiosity();
void cacheVerticesFacesAndColors_Radiosity_II();
private:
void parseObject(ifstream& fileStream, SceneObject& currentObject, int totalVertexCount);
void parseMaterials(string materialsFileName);
Material* getMaterialPtrByName(string matName);
vector<GLfloat> vertex_positions;
vector<GLfloat> vertex_colors;
vector<GLuint> face_indexes;
vector<GLfloat> face_normals;
public:
vector<SceneObject> sceneModel;
private:
vector<SceneObject> startingSceneModel;
vector<Material> materials;
glm::mat4 ModelViewProjectionMatrix;
ShaderLoader shaderLoader;
//OpenGL IDs
GLuint vertexBufferID;
GLuint colorBufferID;
GLuint elementBufferID;
GLuint shaderProgramID;
glm::vec3 interpolatedColorForVertex(int modelIndex, int currentFaceIndex, int currentVertex);
vector<int> GetFaceIndexesFromVertexIndex_Radiosity(int modelIndex, int vertIndex);
};
#endif