-
Notifications
You must be signed in to change notification settings - Fork 3
/
3DModel.h
66 lines (58 loc) · 1.3 KB
/
3DModel.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
#ifndef __3DMODEL_H__
#define __3DMODEL_H__
#include "BoundingBox.h"
#include <string>
#include <vector>
#include "GLSLProgram.h"
#include "rply.h"
struct Vertex
{
float x;
float y;
float z;
};
struct Mesh
{
unsigned int id0;
unsigned int id1;
unsigned int id2;
};
///
/// Class C3DModel.
///
/// A class for loading and displaying and object using Open Asset Import Librery
///
///
class C3DModel
{
private:
CBoundingBox m_bbox;
static std::vector<Vertex> m_vVertex;
static std::vector<Mesh> m_vMesh;
unsigned int m_uVBO;
unsigned int m_uVBOIndex;
int m_iNPoints;
int m_iNTriangles;
GLuint m_uVAO; //for the model
static Vertex m_tempVertex;
static Mesh m_tempMesh;
static int m_iTempIndex;
protected:
static int vertex_cb(p_ply_argument argument);
static int face_cb(p_ply_argument argument);
static std::vector<Vertex> Helper(){ std::vector<Vertex> a; a.reserve(1); return a; }
public:
C3DModel();
~C3DModel();
///Method to load an 3Dmodel
bool load(const std::string & sFilename);
//delete all buffers
void deleteBuffers();
///Draw the object using the VAO
void drawObject();
///Get the center of the object
inline glm::vec3 getCenter(){return m_bbox.getCenter();}
///Get the lenght of the diagonal of bounding box
inline float getDiagonal(){return m_bbox.getDiagonal();}
};
#endif