This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model_OBJ.h
91 lines (71 loc) · 1.8 KB
/
Model_OBJ.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
83
84
85
86
87
88
89
90
91
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <queue>
#include <map>
#include <GL/glut.h>
#include "lib/SOIL.h"
#define MAX_MTL 20
#define MAX_OBJ 100
using namespace std;
/************************************************************************
Material
************************************************************************/
typedef struct {
string name;
float Ns;
float Ka[3];
float Kd[3];
float Ks[3];
float Ni;
float d;
int illum;
bool hasTexture;
string texture;
} material;
/************************************************************************
Object
************************************************************************/
typedef struct {
material* material;
float* faces_triangles;
float* texts_coords;
float* norm_vectors;
long total_triangles_floats;
} object;
/************************************************************************
Texture
************************************************************************/
typedef struct {
unsigned char* image;
int width;
int height;
} texture;
/************************************************************************
Model
************************************************************************/
class Model_OBJ
{
private:
material materials[MAX_MTL];
object objects[MAX_OBJ];
map<string, texture>* textures;
string name;
float* vertexBuffer;
float* vtBuffer;
float* vnBuffer;
bool hasTexture;
long total_vertices_floats;
long total_textures_coords_floats;
long total_normal_vectors_floats;
int total_objects;
int total_materials;
public:
Model_OBJ();
Model_OBJ(char* objFile, bool hasTexture, map<string, texture>* textures);
~Model_OBJ();
int loadMTL(char *filename);
void loadOBJ(char *filename, bool hasTexture);
void draw();
};