summaryrefslogtreecommitdiff
path: root/obj.h
blob: 19bfdcbcb00edd2e2f57950271e598efa1e6bdda (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* vertex types */
enum {
	OBJVGeometric,
	OBJVTexture,
	OBJVNormal,
	OBJVParametric,
	OBJNVERT
};
/* element types */
enum {
	OBJEPoint,
	OBJELine,
	OBJEFace,
	OBJECurve,
	OBJECurve2,
	OBJESurface
};
/* grouping types */
enum {
	OBJGGlobal,
	OBJGSmoothing,
	OBJGMerging
};
/* object hash table size */
enum {
	OBJHTSIZE = 17
};

typedef struct OBJVertex OBJVertex;
typedef struct OBJVertexArray OBJVertexArray;
typedef struct OBJElem OBJElem;
//typedef struct OBJGroup OBJGroup;
typedef struct OBJObject OBJObject;
typedef struct OBJ OBJ;

#pragma varargck type "O" OBJ*

struct OBJVertex
{
	union {
		struct { double x, y, z, w; };	/* geometric */
		struct { double u, v, vv; };	/* texture and parametric */
		struct { double i, j, k; };	/* normal */
	};
};

struct OBJVertexArray
{
	OBJVertex *verts;
	int nvert;
};

struct OBJElem
{
	int *indices;
	int nindex;
	int type;
	OBJElem *next;
};

//struct OBJGroup
//{
//	char *name;
//	int type;
//	OBJElem *elem0;
//	OBJGroup *next;
//};
//struct OBJObject
//{
//	char *name;
//	OBJGroup *grptab[OBJHTSIZE];
//	OBJObject *next;
//};

struct OBJObject
{
	char *name;
	OBJElem *child;
	OBJObject *next;
};

struct OBJ
{
	OBJVertexArray vertdata[OBJNVERT];
	OBJObject *objtab[OBJHTSIZE];
};

OBJ *objparse(char*);
void objfree(OBJ*);

int OBJfmt(Fmt*);
void OBJfmtinstall(void);