blob: 25a5c8f66d2d4d529d3de502d451b015157732df (
plain)
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
|
#ifndef OBJ_H
#define OBJ_H
/* external variables */
char obj_last_fname[31];
typedef struct
{
float x, y, z;
} ObjVertex;
typedef ObjVertex ObjNormal;
typedef struct
{
float u, v;
} ObjTexCoord;
typedef struct
{
int Vertex[4];
int Normal[4];
int TexCoord[4];
} ObjFace;
typedef struct
{
float Ns;
float Ni;
float d;
float Tr;
ObjVertex Tf;
int illum;
ObjVertex Ka;
ObjVertex Kd;
ObjVertex Ks;
ObjVertex Ke;
char *map_Ka;
char *map_Kd;
} ObjMtl;
typedef struct
{
char *mtllib;
char *objectName;
char *groupName;
char *usemtl;
ObjMtl *mtl;
int nVertex, nNormal, nTexCoord, nFace;
ObjVertex *VertexArray;
ObjNormal *NormalArray;
ObjTexCoord *TexCoordArray;
ObjFace *FaceArray;
} ObjModel;
/* function prototypes */
ObjModel *ObjLoadModel(char *, size_t);
/* read a file into argument 2, and return amount of bytes read */
size_t ObjLoadFile(char *, char **);
void ObjList(ObjModel *);
/* once we load an .obj file, we can extract path up to last '/' to load a
* mtl or texture that resides in the same folder */
char *ObjGetPath(char *);
void ObjFree(ObjModel *);
#endif
|