-
Notifications
You must be signed in to change notification settings - Fork 0
/
objloader.h
61 lines (47 loc) · 1.46 KB
/
objloader.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
#ifndef OBJLOAD
#define OBJLOAD
/*****************************************************************************************
*Loads obj file - limited to vertices, faces, normals, texture maps
*loads to object structure as defined in .h file
******************************************************************************************/
#define MAX_VERTICES 8000 // Max number of vertices (for each object)
#define MAX_POLYGONS 8000 // Max number of polygons (for each object)
#define MAX_NORMALS 8000 // Max number of polygons (for each object)
// Our vertex type
typedef struct{
float x,y,z;
}vertex_type;
// Our normal type
typedef struct{
float i,j,k;
}normcoord_type;
// The polygon (triangle), 3 numbers that aim 3 vertices
typedef struct{
int v[3],t[3],n[3];
}polygon_type;
// The mapcoord type, 2 texture coordinates for each vertex
typedef struct{
float u,v;
}mapcoord_type;
// The object type
class object_type{
public:
int id_texture;
object_type(){}
~object_type(){}
int objloader(char *p_filename);
int objdatadisplay();
void render();
private:
char name[20];
int vertices_qty;
int polygons_qty;
int mapcoord_qty;
int normcoord_qty;
vertex_type vertex[MAX_VERTICES];
mapcoord_type mapcoord[MAX_VERTICES];
normcoord_type normcoord[MAX_NORMALS];
polygon_type polygon[MAX_POLYGONS];
};
#endif
/*************************************************************/