-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMesh.h
More file actions
57 lines (42 loc) · 1.6 KB
/
Copy pathMesh.h
File metadata and controls
57 lines (42 loc) · 1.6 KB
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
#ifndef MESH_H
#define MESH_H
#include <glad/glad.h>
#include <vector>
#include <memory>
#include <string>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
class Mesh {
public:
virtual ~Mesh();
const std::vector<glm::vec3> &vertexPositions() const { return _vertexPositions; }
std::vector<glm::vec3> &vertexPositions() { return _vertexPositions; }
const std::vector<glm::vec3> &vertexNormals() const { return _vertexNormals; }
std::vector<glm::vec3> &vertexNormals() { return _vertexNormals; }
const std::vector<glm::vec2> &vertexTexCoords() const { return _vertexTexCoords; }
std::vector<glm::vec2> &vertexTexCoords() { return _vertexTexCoords; }
const std::vector<glm::uvec3> &triangleIndices() const { return _triangleIndices; }
std::vector<glm::uvec3> &triangleIndices() { return _triangleIndices; }
// Compute the parameters of a sphere which bounds the mesh
void computeBoundingSphere(glm::vec3 ¢er, float &radius) const;
void recomputePerVertexNormals(bool angleBased = false);
void recomputePerVertexTextureCoordinates( );
void init();
void render();
void clear();
void addPlane(const float square_half_side = 1.0f);
void addBox(const float w, const float h, const float d);
private:
std::vector<glm::vec3> _vertexPositions;
std::vector<glm::vec3> _vertexNormals;
std::vector<glm::vec2> _vertexTexCoords;
std::vector<glm::uvec3> _triangleIndices;
GLuint _vao = 0;
GLuint _posVbo = 0;
GLuint _normalVbo = 0;
GLuint _texCoordVbo = 0;
GLuint _ibo = 0;
};
// utility: loader
void loadOFF(const std::string &filename, std::shared_ptr<Mesh> meshPtr);
#endif // MESH_H