-
Notifications
You must be signed in to change notification settings - Fork 1
/
OBJObject.h
82 lines (56 loc) · 1.28 KB
/
OBJObject.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
76
77
78
79
80
81
82
/*
* Header file for OBJ file loader/displayer.
*
* Author: James McCrae
*/
#ifndef _OBJObject
#define _OBJObject
#include <QtOpenGL>
#include <QtCore>
struct Face {
QVector <int> vi;
QVector <int> ni;
QVector <int> uvi;
int mati;
};
struct Texture {
Texture();
void MakeReady();
void Load();
void Unload();
QString canonical_path;
QImage image;
GLuint texindex;
bool gl_isloaded;
};
struct Material {
Material();
QString name;
GLfloat * kd;
GLfloat * ka;
QString map_kd;
Texture * tex;
};
class OBJObject : public QObject {
Q_OBJECT
public:
OBJObject();
~OBJObject();
bool load(QString path);
void draw();
QVector <QVector3D> & getVerts();
void setVerts(const QVector <QVector3D> verts);
private:
void loadMTL(QString path);
Texture * loadTexture(const QString & file);
Texture * CreateTextureObject(const QString & file);
QString m_basePath;
QVector <QVector3D> m_verts;
QVector <QVector3D> m_norms;
QVector <QVector2D> m_uvs;
QVector <Face> m_faces;
QVector <Material> m_mats;
QList <Texture> all_textures;
GLuint disp_list;
};
#endif