File: v3dmp.h

package info (click to toggle)
searchandrescue 0.8.2-10
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,656 kB
  • ctags: 6,111
  • sloc: ansic: 89,072; cpp: 7,691; sh: 90; makefile: 80
file content (272 lines) | stat: -rw-r--r-- 6,877 bytes parent folder | download | duplicates (7)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*
			    V3D Model Primitives

	Data types for basic V3D model primitives used to represent
	data and used for OpenGL style drawing.

	When adding new types, make sure you update V3DMPCreate() and
	V3DMPDup() to allocate the correct size of the data type structure
	and update V3DMPDestroy() to deallocate and members that may point
	to allocated resources. Externally, you may need to update other
	functions.

 */

#ifndef V3DMP_H
#define V3DMP_H

#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


/* General purpose vertex structure. */
typedef struct {

	double x, y, z, m;

} mp_vertex_struct;


/* Model primitives structure type codes. */
#define V3DMP_TYPE_COMMENT		1

#define V3DMP_TYPE_TRANSLATE		10
#define V3DMP_TYPE_UNTRANSLATE		11
#define V3DMP_TYPE_ROTATE		12
#define V3DMP_TYPE_UNROTATE		13

#define V3DMP_TYPE_POINT		20
#define V3DMP_TYPE_LINE			21
#define V3DMP_TYPE_LINE_STRIP		22
#define V3DMP_TYPE_LINE_LOOP		23
#define V3DMP_TYPE_TRIANGLE		24
#define V3DMP_TYPE_TRIANGLE_STRIP	25
#define V3DMP_TYPE_TRIANGLE_FAN		26
#define V3DMP_TYPE_QUAD			27
#define V3DMP_TYPE_QUAD_STRIP		28
#define V3DMP_TYPE_POLYGON		29

#define V3DMP_TYPE_COLOR		50
#define V3DMP_TYPE_TEXTURE_SELECT	51
#define V3DMP_TYPE_TEXTURE_ORIENT_XY	52
#define V3DMP_TYPE_TEXTURE_ORIENT_YZ	53
#define V3DMP_TYPE_TEXTURE_ORIENT_XZ	54
#define V3DMP_TYPE_TEXTURE_OFF		55
#define V3DMP_TYPE_HEIGHTFIELD_LOAD	56


/*
 *	Model primitive structures:
 */

/* Comment. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_COMMENT. */
	char **line;
	int total_lines;
} mp_comment_struct;


/* Translate. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_TRANSLATE. */
	double x, y, z;	/* In meters. */
} mp_translate_struct;
/* Untranslate. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_UNTRANSLATE. */
} mp_untranslate_struct;

/* Rotate. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_ROTATE. */
	double heading, bank, pitch;	/* In radians. */
} mp_rotate_struct;
/* Unrotate. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_UNROTATE. */
} mp_unrotate_struct;


/* Point. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_POINT. */
#define V3DMP_POINT_NVERTEX	1
	mp_vertex_struct v[V3DMP_POINT_NVERTEX];
	mp_vertex_struct n[V3DMP_POINT_NVERTEX];
	mp_vertex_struct tc[V3DMP_POINT_NVERTEX];
	double r;
} mp_point_struct;

/* Line. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_LINE. */
#define V3DMP_LINE_NVERTEX	2
	mp_vertex_struct v[V3DMP_LINE_NVERTEX];
	mp_vertex_struct n[V3DMP_LINE_NVERTEX];
	mp_vertex_struct tc[V3DMP_LINE_NVERTEX];
} mp_line_struct;

/* Line strip. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_LINE_STRIP. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_line_strip_struct;

/* Line loop. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_LINE_LOOP. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_line_loop_struct;

/* Triangle. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TRIANGLE. */
#define V3DMP_TRIANGLE_NVERTEX	3
	mp_vertex_struct v[V3DMP_TRIANGLE_NVERTEX];
	mp_vertex_struct n[V3DMP_TRIANGLE_NVERTEX];
	mp_vertex_struct tc[V3DMP_TRIANGLE_NVERTEX];
} mp_triangle_struct;

/* Triangle strip. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TRIANGLE_STRIP. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_triangle_strip_struct;

/* Triangle fan. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TRIANGLE_FAN. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_triangle_fan_struct;

/* Quad. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_QUAD. */
#define V3DMP_QUAD_NVERTEX	4
	mp_vertex_struct v[V3DMP_QUAD_NVERTEX];
	mp_vertex_struct n[V3DMP_QUAD_NVERTEX];
	mp_vertex_struct tc[V3DMP_QUAD_NVERTEX];
} mp_quad_struct;

/* Quad strip. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_QUAD_STRIP. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_quad_strip_struct;

/* Polygon. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_POLYGON. */
	mp_vertex_struct **v;
	mp_vertex_struct **n;
	mp_vertex_struct **tc;
	int total;
} mp_polygon_struct;


/* Color. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_COLOR. */
	double a, r, g, b;
	double ambient, diffuse, specular, shininess, emission;
} mp_color_struct;

/* Texture select by reference name. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TEXTURE_SELECT. */
	char *name;		/* Texture reference name. */
	void *client_data;	/* Client data (can be a number too). */
} mp_texture_select_struct;

/* Texture orient about xy plane. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_TEXTURE_ORIENT_XY. */
	double x, y;
	double dx, dy;	/* Goes -x to +x and -y to +y. */
} mp_texture_orient_xy_struct;

/* Texture orient about yz plane. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TEXTURE_ORIENT_YZ. */
	double y, z;
	double dy, dz;	/* Goes +y to -y and -z to +z. */
} mp_texture_orient_yz_struct;

/* Texture orient about xz plane. */
typedef struct {
	int type;       /* Must be V3DMP_TYPE_TEXTURE_ORIENT_XZ. */
	double x, z;
	double dx, dz;  /* Goes -x to +x and -z to +z. */
} mp_texture_orient_xz_struct;

/* Texture off (unselect). */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_TEXTURE_OFF. */
} mp_texture_off_struct;

/* Heightfield load. */
typedef struct {
	int type;	/* Must be V3DMP_TYPE_HEIGHTFIELD_LOAD. */
	char *path;
	void *gl_list;	/* GL list (can be NULL). */
	double *data;	/* Array of heightfield z points (can be NULL). */
	int x_points, y_points, total_points;
	double x_length, y_length, z_length;	/* Span. */
	double x, y, z;	/* Translation. */
	double heading, pitch, bank;	/* Rotation in radians. */
} mp_heightfield_load_struct;


extern void *V3DMPCreate(int type);
extern void *V3DMPDup(const void *p);
extern int V3DMPInsertVertex(
	void *p, int i,
	mp_vertex_struct **v_rtn, mp_vertex_struct **n_rtn,
	mp_vertex_struct **tc_rtn
);
extern void V3DMPDestroy(void *p);

#define V3DMPGetType(p)		(((p) != NULL) ? (*(int *)(p)) : 0)
extern void *V3DMPListGetPtr(void **list, int total, int i);
extern void *V3DMPListInsert(
	void ***list, int *total, int i,
	int type
);
extern void V3DMPListDelete(void ***list, int *total, int i);
extern void V3DMPListDeleteAll(void ***list, int *total);

extern mp_vertex_struct *V3DMPGetNormal(void *p, int i);
extern mp_vertex_struct *V3DMPGetVertex(void *p, int i);
extern mp_vertex_struct *V3DMPGetTexCoord(void *p, int i);
extern int V3DMPGetTotal(void *p);

extern int V3DMPUnitlizeNormal(void *p);
extern int V3DMPFlipWinding(
	void *p, int flip_normals, int flip_texcoords
);


#ifdef __cplusplus
}  
#endif /* __cplusplus */

#endif	/* V3DMP_H */