-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.h
67 lines (48 loc) · 1.25 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
#ifndef MESH_H
#define MESH_H
#include <iostream>
#include <GL/glew.h>
#include "Mathlib.h"
#include <vector>
#include "BoundingBox.h"
#include "ResourceBase.h"
class VertexBufferObject;
// -------------------------------
// Objet 3D
// chargement à partir de modèles .obj
// -------------------------------
class Mesh : public ResourceBase
{
public:
virtual bool Load(const std::string& name);
virtual void Destroy();
void Draw();
void Draw(GLuint group);
inline GLuint getGroupCount() const {return (GLuint)m_tGroup.size();}
inline BoundingBox& getBoundingBox() {return m_BBox;}
static void EnableComputeNormals(bool b) {s_bComputeNormals=b;}
Mesh();
~Mesh() {Destroy();}
private:
bool LoadOBJ(const std::string& filename);
bool ComputeVBO();
void ComputeNormals();
void ComputeTangents();
void ComputeBoundingBox();
private:
struct sFace {
GLuint ind[3];
};
struct sGroup {
std::string strName;
long nMaterial;
std::vector<sFace> tFace;
};
private:
std::vector<sGroup> m_tGroup;
BoundingBox m_BBox;
// VBO
VertexBufferObject* m_pVBO;
static bool s_bComputeNormals; // Etat pour le chargement : génération ou non des normales à la main
};
#endif