aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/mimesh/libg3d-0.0.8/include/g3d/types.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/include/g3d/types.h')
-rw-r--r--src/others/mimesh/libg3d-0.0.8/include/g3d/types.h478
1 files changed, 478 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/include/g3d/types.h b/src/others/mimesh/libg3d-0.0.8/include/g3d/types.h
new file mode 100644
index 0000000..a2403a0
--- /dev/null
+++ b/src/others/mimesh/libg3d-0.0.8/include/g3d/types.h
@@ -0,0 +1,478 @@
1/* $Id$ */
2
3/*
4 libg3d - 3D object loading library
5
6 Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23#ifndef __G3D_TYPES_H__
24#define __G3D_TYPES_H__
25
26#include <GL/gl.h>
27
28#include <glib.h>
29
30#ifdef USE_LIBMAGIC
31#include <magic.h>
32#endif
33
34#ifdef EAPI
35# undef EAPI
36#endif /* ifdef EAPI */
37
38#ifdef _WIN32
39# ifdef EFL_EET_BUILD
40# ifdef DLL_EXPORT
41# define EAPI __declspec(dllexport)
42# else /* ifdef DLL_EXPORT */
43# define EAPI
44# endif /* ! DLL_EXPORT */
45# else /* ifdef EFL_EET_BUILD */
46# define EAPI __declspec(dllimport)
47# endif /* ! EFL_EET_BUILD */
48#else /* ifdef _WIN32 */
49# ifdef __GNUC__
50# if __GNUC__ >= 4
51# define EAPI __attribute__ ((visibility("default")))
52# else /* if __GNUC__ >= 4 */
53# define EAPI
54# endif /* if __GNUC__ >= 4 */
55# else /* ifdef __GNUC__ */
56# define EAPI
57# endif /* ifdef __GNUC__ */
58#endif /* ! _WIN32 */
59
60
61#ifdef __cplusplus
62extern "C" {
63#endif /* ifdef __cplusplus */
64
65/**
66 * SECTION:types
67 * @short_description: some defined types for libg3d
68 * @include: g3d/g3d.h
69 */
70/* goffset is defined since glib 2.14 */
71#ifndef G_MAXOFFSET
72typedef gint64 goffset;
73#endif
74
75/* supposed to trick gtk-doc not to ignore these functions - not really... */
76#define _G3D_STATIC_INLINE static inline
77
78/*****************************************************************************
79 * basic types
80 *****************************************************************************/
81
82/**
83 * SECTION:types
84 * @short_description: Basic types
85 * @include: g3d/types.h
86 *
87 * Some basic type abstractions used in libg3d.
88 */
89
90/**
91 * G3DFloat:
92 *
93 * Default floating point type. If used consistently in the library (not the
94 * case at the moment) this type can be switched between single and double
95 * precision at compile-time.
96 */
97/**
98 * G3D_FLOAT_IS_DOUBLE
99 *
100 * A flag indicating type of #G3DFloat. It is TRUE if #G3DFloat is double and
101 * FALSE if #G3DFloat is single precision.
102 */
103#if 1
104#define G3D_FLOAT_IS_DOUBLE TRUE
105#define G3D_SCANF_FLOAT "%lf"
106typedef gdouble G3DFloat;
107#else
108#define G3D_FLOAT_IS_DOUBLE FALSE
109#define G3D_SCANF_FLOAT "%f"
110typedef gfloat G3DFloat;
111#endif
112/**
113 * G3DSingle:
114 *
115 * Single-precision floating point number.
116 */
117typedef gfloat G3DSingle;
118/**
119 * G3DDouble:
120 *
121 * Double-precision floating point number.
122 */
123typedef gdouble G3DDouble;
124/**
125 * G3DVector
126 *
127 * Vector element type.
128 */
129typedef G3DFloat G3DVector;
130/**
131 * G3DMatrix:
132 *
133 * Matrix element type.
134 */
135typedef G3DFloat G3DMatrix;
136/**
137 * G3DQuat
138 *
139 * Quaternion element type.
140 */
141typedef G3DFloat G3DQuat;
142
143/*****************************************************************************
144 * G3DImage
145 *****************************************************************************/
146
147/**
148 * G3D_FLAG_IMG_GREYSCALE:
149 *
150 * The image just uses the red channel for grey value
151 */
152#define G3D_FLAG_IMG_GREYSCALE (1L << 1)
153
154/**
155 * G3DTexEnv:
156 * @G3D_TEXENV_UNSPECIFIED: unspecified, application decides
157 * @G3D_TEXENV_BLEND: use blending
158 * @G3D_TEXENV_DECAL: use as decal
159 * @G3D_TEXENV_MODULATE: use modulate
160 * @G3D_TEXENV_REPLACE: replace color
161 *
162 * Specify how the texture should interact with other material properties.
163 */
164typedef enum {
165 G3D_TEXENV_UNSPECIFIED = 0,
166 G3D_TEXENV_BLEND,
167 G3D_TEXENV_DECAL,
168 G3D_TEXENV_MODULATE,
169 G3D_TEXENV_REPLACE
170} G3DTexEnv;
171
172/**
173 * G3DImage:
174 * @name: name of image
175 * @width: width of image in pixels
176 * @height: height of image in pixels
177 * @depth: depth of image in bits
178 * @flags: flags
179 * @pixeldata: the binary image data
180 * @tex_id: the OpenGL texture id, should be unique model-wide
181 * @tex_env: texture environment flags
182 * @tex_scale_u: factor scaling texture width, should be 1.0 for most cases
183 * @tex_scale_v: factor scaling texture height, should be 1.0 for most cases
184 *
185 * Object containing a two-dimensional pixel image.
186 */
187typedef struct {
188 gchar *name;
189 guint32 width;
190 guint32 height;
191 guint8 depth;
192 guint32 flags;
193 guint8 *pixeldata;
194
195 guint32 tex_id;
196 G3DTexEnv tex_env;
197 G3DFloat tex_scale_u;
198 G3DFloat tex_scale_v;
199} G3DImage;
200
201/*****************************************************************************
202 * G3DMaterial
203 *****************************************************************************/
204
205/**
206 * G3D_FLAG_MAT_TWOSIDE:
207 *
208 * Faces using this material should be rendered two-sided as the direction
209 * is unknown.
210 */
211#define G3D_FLAG_MAT_TWOSIDE (1L << 0)
212
213/**
214 * G3DMaterial:
215 * @name: name of material
216 * @r: red component of color
217 * @g: green component of color
218 * @b: blue component of color
219 * @a: alpha component of color
220 * @shininess: shiny color
221 * @specular: specular color
222 * @flags: flags
223 * @tex_image: texture image (optional, may be NULL)
224 *
225 * A material object.
226 */
227
228typedef struct {
229 gchar *name;
230 G3DFloat r, g, b, a;
231 GLfloat shininess;
232 GLfloat specular[4];
233 guint32 flags;
234
235 G3DImage *tex_image;
236} G3DMaterial;
237
238/*****************************************************************************
239 * G3DFace
240 *****************************************************************************/
241
242/**
243 * G3D_FLAG_FAC_NORMALS:
244 *
245 * The face has custom normals.
246 */
247#define G3D_FLAG_FAC_NORMALS (1L << 0)
248/**
249 * G3D_FLAG_FAC_TEXMAP:
250 *
251 * The face has a texture map and texture coordinates.
252 */
253#define G3D_FLAG_FAC_TEXMAP (1L << 1)
254
255/**
256 * G3DFace:
257 * @vertex_count: number of vertices
258 * @vertex_indices: indices of vertices in #G3DObject
259 * @material: material to use for surface
260 * @flags: flags
261 * @normals: optional normal array (one vector - 3 #G3DVector values - for each
262 * vertex)
263 * @tex_image: optional texture image
264 * @tex_vertex_count: number of texture vertices, should be 0 or match
265 * vertex_count
266 * @tex_vertex_data: array of texture vertices
267 *
268 * An object representing a surface.
269 */
270typedef struct {
271 guint32 vertex_count;
272 guint32 *vertex_indices;
273
274 G3DMaterial *material;
275
276 guint32 flags;
277
278 G3DVector *normals;
279
280 G3DImage *tex_image;
281 guint32 tex_vertex_count;
282 G3DVector *tex_vertex_data;
283} G3DFace;
284
285/*****************************************************************************
286 * G3DTransformation
287 *****************************************************************************/
288
289/**
290 * G3DTransformation:
291 * @matrix: the transformation matrix
292 * @flags: flags
293 *
294 * A three-dimensional matrix transformation object.
295 */
296typedef struct {
297 G3DMatrix matrix[16];
298 guint32 flags;
299} G3DTransformation;
300
301
302/*****************************************************************************
303 * G3DObject
304 *****************************************************************************/
305
306/**
307 * G3DObject:
308 * @name: name of object
309 * @materials: list of materials
310 * @faces: list of faces
311 * @objects: list of sub-objects
312 * @transformation: optional transformation
313 * @hide: flag to disable object rendering
314 * @vertex_count: number of vertices
315 * @vertex_data: vertex vector data
316 *
317 * A three-dimensional object.
318 */
319typedef struct {
320 gchar *name;
321
322 GSList *materials;
323 GSList *faces;
324 GSList *objects;
325
326 /* transformation, may be NULL */
327 G3DTransformation *transformation;
328
329 /* don't render this object */
330 gboolean hide;
331
332 /* vertices */
333 guint32 vertex_count;
334 G3DVector *vertex_data;
335
336 /*< private >*/
337 /* FIXME: texture stuff: temporary storage, should be in G3DFace items */
338 guint32 tex_vertex_count;
339 G3DVector *tex_vertex_data;
340 G3DImage *tex_image;
341
342 /*< private >*/
343 /* some fields to speed up rendering, should not be used by plugins */
344 /* FIXME: remove from API (replace with user_data pointer?) */
345 G3DVector *_normals;
346 G3DMaterial **_materials;
347 guint32 _num_faces;
348 guint32 *_indices;
349 guint32 *_flags;
350 guint32 *_tex_images;
351 G3DVector *_tex_coords;
352} G3DObject;
353
354/*****************************************************************************
355 * G3DContext
356 *****************************************************************************/
357
358/**
359 * G3DSetBgColorFunc:
360 * @r: red component
361 * @g: green component
362 * @b: blue component
363 * @a: alpha component
364 * @user_data: opaque data as given to g3d_context_set_set_bgcolor_func()
365 *
366 * Background color setting callback.
367 *
368 * Returns: TRUE on success, FALSE else.
369 */
370typedef gboolean (* G3DSetBgColorFunc)(G3DFloat r, G3DFloat g, G3DFloat b,
371 G3DFloat a, gpointer user_data);
372
373/**
374 * G3DUpdateInterfaceFunc:
375 * @user_data: opaque data as given to g3d_context_set_update_interface_func()
376 *
377 * Interface updating callback.
378 *
379 * Returns: TRUE on success, FALSE else.
380 */
381typedef gboolean (* G3DUpdateInterfaceFunc)(gpointer user_data);
382
383/**
384 * G3DUpdateProgressBarFunc:
385 * @percentage: progress of plugin operation
386 * @show: #TRUE if the progress bar should be visible, #FALSE else
387 * @user_data: opaque data as given to
388 * g3d_context_set_update_progress_bar_func()
389 *
390 * Progress updating callback.
391 *
392 * Returns: TRUE on success, FALSE else.
393 */
394typedef gboolean (* G3DUpdateProgressBarFunc)(G3DFloat percentage,
395 gboolean show, gpointer user_data);
396
397/*< private >*/
398#ifdef USE_LIBMAGIC
399#define MAGIC_PTR_TYPE magic_t
400#else
401#define MAGIC_PTR_TYPE void *
402#endif
403/*< public >*/
404
405/**
406 * G3DContext:
407 *
408 * Internal stuff for libg3d.
409 */
410typedef struct {
411 /*< private >*/
412 GSList *plugins;
413 MAGIC_PTR_TYPE magic_cookie;
414
415 GHashTable *exts_import;
416 GHashTable *exts_image;
417
418 G3DSetBgColorFunc set_bgcolor_func;
419 gpointer set_bgcolor_data;
420 G3DUpdateInterfaceFunc update_interface_func;
421 gpointer update_interface_data;
422 G3DUpdateProgressBarFunc update_progress_bar_func;
423 gpointer update_progress_bar_data;
424
425 GHashTable *modelCache;
426} G3DContext;
427
428/*****************************************************************************
429 * G3DPlugin: real definition in g3d/plugins.h
430 *****************************************************************************/
431
432typedef struct _G3DPlugin G3DPlugin;
433
434/*****************************************************************************
435 * G3DStream
436 *****************************************************************************/
437
438/* declared in stream.h */
439typedef struct _G3DStream G3DStream;
440
441/*****************************************************************************
442 * G3DModel
443 *****************************************************************************/
444
445/**
446 * G3DModel:
447 * @filename: file name or URI of loaded model, may be set by application
448 * @materials: list of materials (#G3DMaterial)
449 * @objects: list of objects (#G3DObject)
450 *
451 * A 3D model.
452 */
453typedef struct {
454 gchar *filename;
455 /*< private >*/
456 G3DContext *context;
457
458 /*< public >*/
459 GSList *materials;
460 GSList *objects;
461
462 /*< private >*/
463 GHashTable *tex_images;
464
465 /* the plugin used to load the model, may be NULL */
466 G3DPlugin *plugin;
467 /* The stream used to load the model, may be NULL */
468 G3DStream *stream;
469
470 int refCount;
471} G3DModel;
472
473#ifdef __cplusplus
474}
475#endif /* ifdef __cplusplus */
476
477#endif /* __G3D_TYPES_H__ */
478