-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.h
41 lines (33 loc) · 981 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
#pragma once
#include <GL/glew.h>
#include <GL/glut.h>
#include "Vector.h"
#include "Matrix.h"
#include "ShaderProgram.h"
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
class Mesh {
public:
typedef Vector3f Vertex;
struct Face {
GLuint indices[3];
Vector3f normal;
Vector3f tangent, bitangent;
};
private:
std::vector<Vertex> vertices;
std::vector<Face> faces;
std::vector<Vector3f> vertexNormals;
std::vector<Vector2f> texCoords;
Vector3f calcFaceNormal(const Face & face, size_t cornerIndex) const;
float calcCornerAngle(const Face & face, size_t cornerIndex) const;
public:
static Mesh createFromDatFile(const std::string & filename);
const std::vector<Vertex> & getVertices() const;
const std::vector<Vector2f> & getTexCoords() const;
const std::vector<Vector3f> & getVertexNormals() const;
void draw(const ShaderProgram & shaderProgram, const Face & face) const;
void draw(const ShaderProgram & shaderProgram) const;
};