-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmesh.hpp
More file actions
65 lines (52 loc) · 1.42 KB
/
mesh.hpp
File metadata and controls
65 lines (52 loc) · 1.42 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
58
59
60
61
62
63
64
65
#ifndef MESH_HPP
#define MESH_HPP
#include <string>
#include <vector>
#include <utility>
#include <glm/glm.hpp>
#include "gl_core_3_3.h"
class Mesh {
public:
Mesh(std::string filename);
~Mesh() { release(); }
// Return the bounding box of this object
std::pair<glm::vec3, glm::vec3> boundingBox() const
{
return std::make_pair(minBB, maxBB);
}
void load(std::string filename);
void draw();
void move(const float&, const float&, const float&);
void rotate(const float&, const float&, const float&);
// Mesh vertex format
struct Vtx {
glm::vec3 pos; // Position
glm::vec3 norm; // Normal
};
void getVerticesPos(std::vector<glm::vec3>&, std::vector<unsigned int>&);
void getVerticesNorm(std::vector<glm::vec3>&, std::vector<unsigned int>&);
protected:
void release(); // Release OpenGL resources
// Bounding box
glm::vec3 minBB;
glm::vec3 maxBB;
// OpenGL resources
GLuint vao; // Vertex array object
GLuint vbuf; // Vertex buffer
GLsizei vcount; // Number of vertices
glm::vec3 currentOffset;
glm::vec3 currentRotation;
std::vector<glm::vec3> raw_vertices;
std::vector<glm::vec3> raw_normals;
std::vector<glm::vec3> m_vertices;
std::vector<glm::vec3> m_normals;
std::vector<unsigned int> v_elements;
std::vector<unsigned int> n_elements;
private:
// Disallow copy and move
Mesh(const Mesh& other);
Mesh(Mesh&& other);
Mesh& operator=(const Mesh& other);
Mesh& operator=(Mesh&& other);
};
#endif