-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObjModel.h
75 lines (63 loc) · 1.61 KB
/
ObjModel.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
#ifndef OBJMODEL_H
#define OBJMODEL_H
#include <vector>
#include <glm/glm.hpp>
#include <assimp/scene.h>
/**
* @brief Vertex representation structure
*/
struct Vertex {
glm::vec3 position; /// xyz coordinates
glm::vec3 normal; /// Normal vector
glm::vec2 uv; /// uv coordinates
};
/**
* @brief Class to represent Mesh information
*/
class Mesh {
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
unsigned int vao{0}, vbo{0}, ebo{0};
public:
/**
* @brief Constructor for the Mesh class
* @param vertices List of vertices of the model
* @param indices Indices of the faces
*/
Mesh(const std::vector<Vertex> &vertices, const std::vector<unsigned int> &indices);
void draw();
};
/**
* @brief Class defined to define the object model
*/
class ObjModel {
std::vector<Mesh> meshes;
/**
* @brief Parse and load the .obj file using ASSIMP.
* @param path
*/
void load(const char* path);
/**
* @brief Method to process a single node
* @param node Pointer to the node
* @param scene Pointer to the scene
*/
void processNode(aiNode* node, const aiScene* scene);
/**
* @brief Method to process a mesh
* @param mesh Pointer to the mesh
* @param scene Pointer to the scene
*/
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
public:
/**
* @brief Constructor for the ObjModel class
* @param path The path to the object to be loaded
*/
explicit ObjModel(const char* path);
/**
* @brief Draws all meshes of the model
*/
void draw();
};
#endif