From cb3716ffb584fe0f593b6f1669a8efdba1305104 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 29 Mar 2016 02:16:55 +1000 Subject: Added my version of libg3d and friends. --- .../mimesh/libg3d-0.0.8/doc/api/html/ch01.html | 55 + .../mimesh/libg3d-0.0.8/doc/api/html/ch02.html | 58 + .../mimesh/libg3d-0.0.8/doc/api/html/home.png | Bin 0 -> 654 bytes .../mimesh/libg3d-0.0.8/doc/api/html/index.html | 85 ++ .../mimesh/libg3d-0.0.8/doc/api/html/index.sgml | 242 +++ .../mimesh/libg3d-0.0.8/doc/api/html/left.png | Bin 0 -> 459 bytes .../libg3d-0.0.8/doc/api/html/libg3d-context.html | 531 +++++++ .../libg3d-0.0.8/doc/api/html/libg3d-face.html | 255 ++++ .../libg3d-0.0.8/doc/api/html/libg3d-iff.html | 872 +++++++++++ .../libg3d-0.0.8/doc/api/html/libg3d-material.html | 174 +++ .../libg3d-0.0.8/doc/api/html/libg3d-matrix.html | 450 ++++++ .../libg3d-0.0.8/doc/api/html/libg3d-model.html | 438 ++++++ .../libg3d-0.0.8/doc/api/html/libg3d-object.html | 466 ++++++ .../libg3d-0.0.8/doc/api/html/libg3d-plugins.html | 727 +++++++++ .../doc/api/html/libg3d-primitive.html | 508 +++++++ .../libg3d-0.0.8/doc/api/html/libg3d-quat.html | 346 +++++ .../libg3d-0.0.8/doc/api/html/libg3d-read.html | 373 +++++ .../libg3d-0.0.8/doc/api/html/libg3d-stream.html | 1535 ++++++++++++++++++++ .../libg3d-0.0.8/doc/api/html/libg3d-texture.html | 455 ++++++ .../libg3d-0.0.8/doc/api/html/libg3d-types.html | 109 ++ .../libg3d-0.0.8/doc/api/html/libg3d-vector.html | 266 ++++ .../libg3d-0.0.8/doc/api/html/libg3d.devhelp | 204 +++ .../libg3d-0.0.8/doc/api/html/libg3d.devhelp2 | 204 +++ .../mimesh/libg3d-0.0.8/doc/api/html/right.png | Bin 0 -> 472 bytes .../mimesh/libg3d-0.0.8/doc/api/html/style.css | 160 ++ src/others/mimesh/libg3d-0.0.8/doc/api/html/up.png | Bin 0 -> 406 bytes 26 files changed, 8513 insertions(+) create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/ch01.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/ch02.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/home.png create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/index.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/index.sgml create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/left.png create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-context.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-face.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-iff.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-material.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-matrix.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-model.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-object.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-plugins.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-primitive.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-quat.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-read.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-stream.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-texture.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-types.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d-vector.html create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d.devhelp create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/libg3d.devhelp2 create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/right.png create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/style.css create mode 100644 src/others/mimesh/libg3d-0.0.8/doc/api/html/up.png (limited to 'src/others/mimesh/libg3d-0.0.8/doc/api/html') diff --git a/src/others/mimesh/libg3d-0.0.8/doc/api/html/ch01.html b/src/others/mimesh/libg3d-0.0.8/doc/api/html/ch01.html new file mode 100644 index 0000000..4df5d39 --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/doc/api/html/ch01.html @@ -0,0 +1,55 @@ + + +
+ ++ | + | + | libg3d Reference Manual | ++ |
---|
+ | + | + | libg3d Reference Manual | ++ |
---|
libg3d Reference Manual |
---|
+ for libg3d 0.0.7 + The latest version of this documentation can be found on-line at + http://automagically.de/libg3d/. +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/g3d.h> + + G3DContext; +G3DContext* g3d_context_new (void); +void g3d_context_free (G3DContext *context); +gboolean (*G3DSetBgColorFunc) (G3DFloat r, + G3DFloat g, + G3DFloat b, + G3DFloat a, + gpointer user_data); +gboolean (*G3DUpdateInterfaceFunc) (gpointer user_data); +gboolean (*G3DUpdateProgressBarFunc) (G3DFloat percentage, + gboolean show, + gpointer user_data); +gboolean g3d_context_update_interface (G3DContext *context); +void g3d_context_set_update_interface_func + (G3DContext *context, + G3DUpdateInterfaceFunc func, + gpointer user_data); +gboolean g3d_context_update_progress_bar (G3DContext *context, + G3DFloat percentage, + gboolean visibility); +void g3d_context_set_update_progress_bar_func + (G3DContext *context, + G3DUpdateProgressBarFunc func, + gpointer user_data); +gboolean g3d_context_set_bgcolor (G3DContext *context, + G3DFloat r, + G3DFloat g, + G3DFloat b, + G3DFloat a); +void g3d_context_set_set_bgcolor_func (G3DContext *context, + G3DSetBgColorFunc func, + gpointer user_data); ++
+All state information is saved in the context. It also serves as an +interface to the application.
++ +
+G3DContext* g3d_context_new (void);+
+Create a new context. This initializes the library (and also the +plugin system so this has not to be done seperately).
++ +
+Returns : |
+a valid context, or NULL on failure. + | +
void g3d_context_free (G3DContext *context);+
+Cleans up the context and the plugin system and frees all reserved +memory.
++ +
+
|
+the context to free + | +
gboolean (*G3DSetBgColorFunc) (G3DFloat r, + G3DFloat g, + G3DFloat b, + G3DFloat a, + gpointer user_data);+
+Background color setting callback.
++ +
+
|
+red component + | +
|
+green component + | +
|
+blue component + | +
|
+alpha component + | +
|
+ opaque data as given to g3d_context_set_set_bgcolor_func()
+ |
+
Returns : |
+TRUE on success, FALSE else. + | +
gboolean (*G3DUpdateInterfaceFunc) (gpointer user_data);+
+Interface updating callback.
++ +
+
|
+ opaque data as given to g3d_context_set_update_interface_func()
+ |
+
Returns : |
+TRUE on success, FALSE else. + | +
gboolean (*G3DUpdateProgressBarFunc) (G3DFloat percentage, + gboolean show, + gpointer user_data);+
+Progress updating callback.
++ +
+
|
+progress of plugin operation + | +
|
+TRUE if the progress bar should be visible, FALSE else + | +
|
+ opaque data as given to
+g3d_context_set_update_progress_bar_func()
+ |
+
Returns : |
+TRUE on success, FALSE else. + | +
gboolean g3d_context_update_interface (G3DContext *context);+
+Try to update the interface. This will call a function registered with
+g3d_context_set_update_interface_func
.
+ +
+
|
+a valid context + | +
Returns : |
+TRUE on success, FALSE else + | +
void g3d_context_set_update_interface_func + (G3DContext *context, + G3DUpdateInterfaceFunc func, + gpointer user_data);+
+Registers a callback function for updating the interface.
++ +
+
|
+a valid context + | +
|
+the callback function + | +
|
+user-defined opaque pointer + | +
gboolean g3d_context_update_progress_bar (G3DContext *context, + G3DFloat percentage, + gboolean visibility);+
+Try to update the progress bar.
++ +
+
|
+a valid context + | +
|
+the percentage to set on the progress bar + | +
|
+show or hide the progress bar + | +
Returns : |
+TRUE on success, FALSE else + | +
void g3d_context_set_update_progress_bar_func + (G3DContext *context, + G3DUpdateProgressBarFunc func, + gpointer user_data);+
+Registers a callback function for updating the progress bar.
++ +
+
|
+a valid context + | +
|
+the callback function + | +
|
+user-defined opaque pointer + | +
gboolean g3d_context_set_bgcolor (G3DContext *context, + G3DFloat r, + G3DFloat g, + G3DFloat b, + G3DFloat a);+
+Try to set the background color. This will call a function registered
+with g3d_context_set_set_bgcolor_func
.
+ +
+
|
+a valid context + | +
|
+red component (range: 0.0 .. 1.0) + | +
|
+green component (range: 0.0 .. 1.0) + | +
|
+green component (range: 0.0 .. 1.0) + | +
|
+alpha component + | +
Returns : |
+TRUE on success, FALSE else + | +
void g3d_context_set_set_bgcolor_func (G3DContext *context, + G3DSetBgColorFunc func, + gpointer user_data);+
+Registers a callback function for setting the background color.
++ +
+
|
+a valid context + | +
|
+the callback function + | +
|
+user-defined opaque pointer + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/face.h> + +#define G3D_FLAG_MAT_TWOSIDE +#define G3D_FLAG_FAC_NORMALS +#define G3D_FLAG_FAC_TEXMAP + G3DFace; +gboolean g3d_face_get_normal (G3DFace *face, + G3DObject *object, + G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz); +void g3d_face_free (G3DFace *face); ++
#define G3D_FLAG_MAT_TWOSIDE (1L << 0) ++
+Faces using this material should be rendered two-sided as the direction +is unknown.
++ +
+#define G3D_FLAG_FAC_NORMALS (1L << 0) ++
+The face has custom normals.
++ +
+#define G3D_FLAG_FAC_TEXMAP (1L << 1) ++
+The face has a texture map and texture coordinates.
++ +
+typedef struct { + guint32 vertex_count; + guint32 *vertex_indices; + + G3DMaterial *material; + + guint32 flags; + + G3DVector *normals; + + G3DImage *tex_image; + guint32 tex_vertex_count; + G3DVector *tex_vertex_data; +} G3DFace; ++
+An object representing a surface.
++ +
+guint32 |
+number of vertices + | +
guint32 * |
+indices of vertices in G3DObject + | +
G3DMaterial * |
+material to use for surface + | +
guint32 |
+flags + | +
G3DVector * |
+optional normal array (one vector - 3 G3DVector values - for each + vertex) + | +
G3DImage * |
+optional texture image + | +
guint32 |
+number of texture vertices, should be 0 or match + vertex_count + | +
G3DVector * |
+array of texture vertices + | +
gboolean g3d_face_get_normal (G3DFace *face, + G3DObject *object, + G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz);+
+calculates the normal of a face.
++ +
+
|
+face to calculate normal of + | +
|
+object containing vertices of face + | +
|
+x component of resulting normal + | +
|
+y component of resulting normal + | +
|
+z component of resulting normal + | +
Returns : |
+TRUE on success, FALSE else + | +
void g3d_face_free (G3DFace *face);+
+Frees all memory allocated for this face.
++ +
+
|
+the face to free + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/iff.h> + +#define G3D_IFF_PAD1 +#define G3D_IFF_PAD2 +#define G3D_IFF_PAD4 +#define G3D_IFF_PAD8 +#define G3D_IFF_LE +#define G3D_IFF_LEN16 +#define G3D_IFF_SUBCHUNK_LEN16 +#define G3D_IFF_MKID (a,b,c,d) +gboolean g3d_iff_check (G3DStream *stream, + guint32 *id, + gsize *len); +gsize g3d_iff_read_chunk (G3DStream *stream, + guint32 *id, + gsize *len, + guint32 flags); +gpointer g3d_iff_handle_chunk (G3DIffGlobal *global, + G3DIffLocal *plocal, + G3DIffChunkInfo *chunks, + guint32 flags); +gboolean g3d_iff_chunk_matches (guint32 id, + gchar *tid); +gboolean g3d_iff_read_ctnr (G3DIffGlobal *global, + G3DIffLocal *local, + G3DIffChunkInfo *chunks, + guint32 flags); +gchar* g3d_iff_id_to_text (guint32 id); +FILE* g3d_iff_open (const gchar *filename, + guint32 *id, + guint32 *len); +int g3d_iff_readchunk (FILE *f, + guint32 *id, + guint32 *len, + guint32 flags); +gboolean (*G3DIffChunkCallback) (G3DIffGlobal *global, + G3DIffLocal *local); +#define g3d_iff_chunk_callback + G3DIffChunkInfo; +#define g3d_iff_chunk_info + G3DIffGlobal; +#define g3d_iff_gdata + G3DIffLocal; +#define g3d_iff_ldata ++
+These are helper functions to read data from the Interchange File Format +(IFF).
++ +
+#define G3D_IFF_LE 0x40 /* little endian */ ++
+The file has little-endian data.
++ +
+#define G3D_IFF_SUBCHUNK_LEN16 0x10 ++
+All chunks except the toplevel ones have 16-bit sizes.
++ +
+#define G3D_IFF_MKID(a,b,c,d)+
+Generate an IFF chunk identifier from character representation, e.g. +G3D_IFF_MKID('F','O','R','M').
++ +
+
|
+first byte + | +
|
+second byte + | +
|
+third byte + | +
|
+fourth byte + | +
gboolean g3d_iff_check (G3DStream *stream, + guint32 *id, + gsize *len);+
+Checks a stream for a valid IFF signature and reads the top level container.
++ +
+
|
+stream containing IFF file to check + | +
|
+top level ID (out) + | +
|
+length of top level container (out) + | +
Returns : |
+TRUE on success (valid IFF), FALSE else + | +
gsize g3d_iff_read_chunk (G3DStream *stream, + guint32 *id, + gsize *len, + guint32 flags);+
+Reads one chunk header from an IFF file.
++ +
+
|
+stream to read from + | +
|
+ID of chunk (out) + | +
|
+length of chunk (excluding header) (out) + | +
|
+flags + | +
Returns : |
+real length of chunk including header and possible padding byte + | +
gpointer g3d_iff_handle_chunk (G3DIffGlobal *global, + G3DIffLocal *plocal, + G3DIffChunkInfo *chunks, + guint32 flags);+
+Handle an IFF chunk based on chunk description.
++ +
+
|
+global data + | +
|
+local data of parent chunk, must not be NULL + | +
|
+chunk description list + | +
|
+IFF flags + | +
Returns : |
+level object for siblings, may be NULL. + | +
gboolean g3d_iff_chunk_matches (guint32 id, + gchar *tid);+
+Check whether id
and tid
match.
+ +
+
|
+IFF identifier + | +
|
+textual representation of identifier + | +
Returns : |
+TRUE on match, FALSE else. + | +
gboolean g3d_iff_read_ctnr (G3DIffGlobal *global, + G3DIffLocal *local, + G3DIffChunkInfo *chunks, + guint32 flags);+
+Read subchunks in current chunk and handle them appropriately.
++ +
+
|
+global data + | +
|
+local data of current chunk, must not be NULL + | +
|
+chunk description list + | +
|
+IFF flags + | +
Returns : |
+TRUE on success, FALSE else. + | +
gchar* g3d_iff_id_to_text (guint32 id);+
+Get the text representation of an IFF chunk identifier.
++ +
+
|
+an IFF identifier + | +
Returns : |
+a newly allocated string containing the text identifier. + | +
FILE* g3d_iff_open (const gchar *filename, + guint32 *id, + guint32 *len);+
+Opens an IFF file, checks it and reads its top level container.
++ +
+
|
+file name of IFF file + | +
|
+top level ID (out) + | +
|
+length of top level container (out) + | +
Returns : |
+the file pointer of open file or NULL in case of an error + | +
int g3d_iff_readchunk (FILE *f, + guint32 *id, + guint32 *len, + guint32 flags);+
+Reads one chunk header from an IFF file.
++ +
+
|
+the open IFF file pointer + | +
|
+ID of chunk (out) + | +
|
+length of chunk (excluding header) (out) + | +
|
+flags + | +
Returns : |
+real length of chunk including header and possible padding byte + | +
gboolean (*G3DIffChunkCallback) (G3DIffGlobal *global, + G3DIffLocal *local);+
+IFF callback function prototype.
++ +
+
|
+the global data + | +
|
+the local data + | +
Returns : |
+TRUE on success, FALSE else. + | +
#define g3d_iff_chunk_callback G3DIffChunkCallback ++
+IFF chunk callback (deprecated).
++ +
+typedef struct { + gchar *id; + gchar *description; + gboolean container; + G3DIffChunkCallback callback; +} G3DIffChunkInfo; ++
+A chunk type description.
++ +
+gchar * |
+identifier of chunk + | +
gchar * |
+human-readable description of chunk type + | +
gboolean |
+TRUE if this chunk contains sub-chunks + | +
G3DIffChunkCallback |
+function to be called if such a chunk is found + | +
#define g3d_iff_chunk_info G3DIffChunkInfo ++
+IFF chunk description (deprecated).
++ +
+typedef struct { + G3DContext *context; + G3DModel *model; + G3DStream *stream; + guint32 flags; + gpointer user_data; + FILE *f; + long int max_fpos; +} G3DIffGlobal; ++
+The plugin-global data to be given to IFF callback functions.
++ +
+G3DContext * |
+a valid context + | +
G3DModel * |
+a model + | +
G3DStream * |
+the stream to read model from + | +
guint32 |
+IFF flags + | +
gpointer |
+to be used by plugin + | +
FILE * |
+file to read model from (DEPRECATED) + | +
long int |
+maximum file position (DEPRECATED) + | +
typedef struct { + guint32 id; + guint32 parent_id; + gpointer object; + gint32 level; + gpointer level_object; + gint32 nb; + gboolean finalize; +} G3DIffLocal; ++
+The function-local data for IFF callback functions.
++ +
+guint32 |
+chunk identifier + | +
guint32 |
+parent chunk identifier + | +
gpointer |
+an object set by parent callbacks, may be NULL + | +
gint32 |
+level of chunk + | +
gpointer |
+object shared by callbacks on the same level, may be NULL + | +
gint32 |
+number of bytes remaining in chunk, has to be decremented after +correctly after reading from stream + | +
gboolean |
+ for container chunks the callback function is called before
+and after processing possible sub-chunks, the second time finalize is set
+to TRUE
+ |
+
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/material.h> + + G3DMaterial; +G3DMaterial* g3d_material_new (void); +void g3d_material_free (G3DMaterial *material); ++
+A material contains all color, shading and texture information for a +G3DFace.
++ +
+typedef struct { + gchar *name; + G3DFloat r, g, b, a; + G3DFloat shininess; + G3DFloat specular[4]; + guint32 flags; + + G3DImage *tex_image; +} G3DMaterial; ++
+A material object.
++ +
+gchar * |
+name of material + | +
G3DFloat |
+red component of color + | +
G3DFloat |
+green component of color + | +
G3DFloat |
+blue component of color + | +
G3DFloat |
+alpha component of color + | +
G3DFloat |
+shiny color + | +
G3DFloat |
+specular color + | +
guint32 |
+flags + | +
G3DImage * |
+texture image (optional, may be NULL) + | +
G3DMaterial* g3d_material_new (void);+
+Generates a new material with a default color.
++ +
+Returns : |
+the new material or NULL on error + | +
void g3d_material_free (G3DMaterial *material);+
+Frees all memory allocated for that material.
++ +
+
|
+the material to free + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/matrix.h> + +typedef G3DMatrix; +gboolean g3d_matrix_identity (G3DMatrix *matrix); +gboolean g3d_matrix_multiply (G3DMatrix *m1, + G3DMatrix *m2, + G3DMatrix *rm); +gboolean g3d_matrix_translate (G3DFloat x, + G3DFloat y, + G3DFloat z, + G3DMatrix *rm); +gboolean g3d_matrix_rotate (G3DFloat angle, + G3DFloat ax, + G3DFloat ay, + G3DFloat az, + G3DMatrix *rm); +gboolean g3d_matrix_rotate_xyz (G3DFloat rx, + G3DFloat ry, + G3DFloat rz, + G3DMatrix *rm); +gboolean g3d_matrix_scale (G3DFloat x, + G3DFloat y, + G3DFloat z, + G3DMatrix *rm); +gboolean g3d_matrix_transpose (G3DMatrix *matrix); +G3DFloat g3d_matrix_determinant (G3DMatrix *matrix); +gboolean g3d_matrix_dump (G3DMatrix *matrix); ++
+Matrices in libg3d have the following layout: +
++G3DMatrix matrix[16]: +
++matrix[col * 4 + row] = f;
++ +
+gboolean g3d_matrix_identity (G3DMatrix *matrix);+
+Sets the given matrix to the identity matrix.
++ +
+
|
+4x4 matrix (float[16]) + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_multiply (G3DMatrix *m1, + G3DMatrix *m2, + G3DMatrix *rm);+
+Multiplies the matrixes.
++ +
+
|
+first matrix + | +
|
+second matrix + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_translate (G3DFloat x, + G3DFloat y, + G3DFloat z, + G3DMatrix *rm);+
+Adds a translation to the the matrix.
++ +
+
|
+x translation + | +
|
+y translation + | +
|
+z translation + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_rotate (G3DFloat angle, + G3DFloat ax, + G3DFloat ay, + G3DFloat az, + G3DMatrix *rm);+
+Adds a rotation to the matrix.
++ +
+
|
+rotation angle + | +
|
+x component of rotation axis + | +
|
+y component of rotation axis + | +
|
+z component of rotation axis + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_rotate_xyz (G3DFloat rx, + G3DFloat ry, + G3DFloat rz, + G3DMatrix *rm);+
+Adds a rotation around the 3 coordinate system axes to the matrix.
++ +
+
|
+rotation around x axis + | +
|
+rotation around y axis + | +
|
+rotation around z axis + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_scale (G3DFloat x, + G3DFloat y, + G3DFloat z, + G3DMatrix *rm);+
+Adds a scaling to the matrix.
++ +
+
|
+x factor + | +
|
+y factor + | +
|
+z factor + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_matrix_transpose (G3DMatrix *matrix);+
+Transposes the matrix.
++ +
+
|
+the matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
G3DFloat g3d_matrix_determinant (G3DMatrix *matrix);+
+Calculate the determinant of the matrix (FIXME: not verified).
++ +
+
|
+the matrix + | +
Returns : |
+the determinant. + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/g3d.h> + +#define G3D_MODEL_CENTER +#define G3D_MODEL_NOCHECK +#define G3D_MODEL_OPTIMIZE +#define G3D_MODEL_SCALE + G3DModel; +G3DModel* g3d_model_new (void); +G3DModel* g3d_model_load (G3DContext *context, + const gchar *filename); +G3DModel* g3d_model_load_full (G3DContext *context, + const gchar *filename, + guint32 flags); +gboolean g3d_model_check (G3DModel *model); +gboolean g3d_model_center (G3DModel *model); +gboolean g3d_model_transform (G3DModel *model, + G3DMatrix *matrix); +void g3d_model_clear (G3DModel *model); +void g3d_model_free (G3DModel *model); +G3DObject* g3d_model_get_object_by_name (G3DModel *model, + const gchar *name); ++
+A model is a group of objects. All information loaded from a file by libg3d +is found in this model.
++ +
+#define G3D_MODEL_CENTER (1 << 1) ++
+The model should be centered around the (0,0,0).
++ +
+#define G3D_MODEL_NOCHECK (1 << 3) ++
+The common checks should be disabled. The checks include: +
++ +
+#define G3D_MODEL_OPTIMIZE (1 << 2) ++
+The model material/object/face lists should be serialized to some private +arrays (deprecated).
++ +
+#define G3D_MODEL_SCALE (1 << 0) ++
+The model should be scaled to a maximum extension of +/- 10.0.
++ +
+typedef struct { + gchar *filename; + GSList *materials; + GSList *objects; +} G3DModel; ++
+A 3D model.
++ +
+gchar * |
+file name or URI of loaded model, may be set by application + | +
GSList * |
+list of materials (G3DMaterial) + | +
GSList * |
+list of objects (G3DObject) + | +
G3DModel* g3d_model_new (void);+
+This functions allocates and initializes a new G3DModel.
++ +
+Returns : |
+a newly allocated G3DModel + | +
G3DModel* g3d_model_load (G3DContext *context, + const gchar *filename);+
+Loads a model from a file. The model is checked, centered, resized, +optimized.
++ +
+
|
+a valid context + | +
|
+the file name of the model to load + | +
Returns : |
+the loaded model or NULL in case of an error + | +
G3DModel* g3d_model_load_full (G3DContext *context, + const gchar *filename, + guint32 flags);+
+Loads a model from a file. Depending on flags
the model is checked,
+centered, resized, optimized.
+ +
+
|
+a valid context + | +
|
+the file name of the model to load + | +
|
+object manipulation flags + | +
Returns : |
+the loaded model or NULL in case of an error. + | +
gboolean g3d_model_check (G3DModel *model);+
+Checks whether a model returned by plugin is valid.
++ +
+
|
+the model to check + | +
Returns : |
+TRUE on success, FALSE on error + | +
gboolean g3d_model_center (G3DModel *model);+
+Translates all object coordinates that the object center is at (0, 0, 0)
++ +
+
|
+the model to center + | +
Returns : |
+TRUE on success, FALSE on error + | +
gboolean g3d_model_transform (G3DModel *model, + G3DMatrix *matrix);+
+Transform all toplevel objects in model with matrix.
++ +
+
|
+the model + | +
|
+transformation matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
void g3d_model_clear (G3DModel *model);+
+Removes all objects from a model.
++ +
+
|
+the model to clear + | +
void g3d_model_free (G3DModel *model);+
+Frees all memory allocated for the model including all objects, materials +and textures.
++ +
+
|
+the model to free + | +
G3DObject* g3d_model_get_object_by_name (G3DModel *model, + const gchar *name);+
+Searches the object tree for an object with the given name.
++ +
+
|
+the model containing all objects + | +
|
+the name of the requested object + | +
Returns : |
+the requested object or NULL if non was found + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/object.h> + + G3DObject; + G3DTransformation; +void g3d_object_free (G3DObject *object); +gdouble g3d_object_radius (G3DObject *object); +gboolean g3d_object_scale (G3DObject *object, + G3DFloat scale); +gboolean g3d_object_transform (G3DObject *object, + G3DMatrix *matrix); +gboolean g3d_object_transform_normals (G3DObject *object, + G3DMatrix *matrix); +G3DObject* g3d_object_duplicate (G3DObject *object); +gboolean g3d_object_optimize (G3DObject *object); +gboolean g3d_object_smooth (G3DObject *object); +gboolean g3d_object_merge (G3DObject *o1, + G3DObject *o2); ++
+Objects are parts of a model. In most file formats vertices and faces are +grouped in some way into objects. Objects can be hierarchical, so what a +model contains is basically an object tree.
++ +
+typedef struct { + gchar *name; + + GSList *materials; + GSList *faces; + GSList *objects; + + /* transformation, may be NULL */ + G3DTransformation *transformation; + + /* don't render this object */ + gboolean hide; + + /* vertices */ + guint32 vertex_count; + G3DVector *vertex_data; +} G3DObject; ++
+A three-dimensional object.
++ +
+gchar * |
+name of object + | +
GSList * |
+list of materials + | +
GSList * |
+list of faces + | +
GSList * |
+list of sub-objects + | +
G3DTransformation * |
+optional transformation + | +
gboolean |
+flag to disable object rendering + | +
guint32 |
+number of vertices + | +
G3DVector * |
+vertex vector data + | +
typedef struct { + G3DMatrix matrix[16]; + guint32 flags; +} G3DTransformation; ++
+A three-dimensional matrix transformation object.
++ +
+ +void g3d_object_free (G3DObject *object);+
+Frees all memory allocated for that object.
++ +
+
|
+the object to free + | +
gdouble g3d_object_radius (G3DObject *object);+
+Calculates the radius of the object. This is the maximum from the +center to a vertex.
++ +
+
|
+the object to measure + | +
Returns : |
+the radius of the given object + | +
gboolean g3d_object_scale (G3DObject *object, + G3DFloat scale);+
+Resizes the object by the factor scale
.
+ +
+
|
+the object to scale + | +
|
+scale factor + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_object_transform (G3DObject *object, + G3DMatrix *matrix);+
+Multiplies all vertices of the object with the transformation matrix.
++ +
+
|
+the object to transform + | +
|
+the transformation matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_object_transform_normals (G3DObject *object, + G3DMatrix *matrix);+
+Multiplies all normals of the object with the transformation matrix.
++ +
+
|
+the object to transform + | +
|
+the transformation matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
G3DObject* g3d_object_duplicate (G3DObject *object);+
+Duplicates an object with all vertices, faces and materials.
++ +
+
|
+the object to duplicate + | +
Returns : |
+the new clone object + | +
gboolean g3d_object_optimize (G3DObject *object);+
+Puts all vertex and face information into special arrays for faster +rendering. It is deprecated and should not be used.
++ +
+
|
+the object to optimize + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_object_smooth (G3DObject *object);+
+FIXME: unimplemented.
++ +
+
|
+the object to smooth + | +
Returns : |
+TRUE on success, FALSE else + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/plugins.h> + +enum G3DPluginType; +gpointer (*G3DPluginInitFunc) (G3DContext *context); +void (*G3DPluginCleanupFunc) (gpointer user_data); +gboolean (*G3DPluginLoadModelFunc) (G3DContext *context, + const gchar *filename, + G3DModel *model, + gpointer user_data); +gboolean (*G3DPluginLoadModelFromStreamFunc) (G3DContext *context, + G3DStream *stream, + G3DModel *model, + gpointer user_data); +gboolean (*G3DPluginLoadImageFunc) (G3DContext *context, + const gchar *filename, + G3DImage *image, + gpointer user_data); +gboolean (*G3DPluginLoadImageStreamFunc) (G3DContext *context, + G3DStream *stream, + G3DImage *image, + gpointer user_data); +gchar* (*G3DPluginGetDescFunc) (G3DContext *context); +gchar** (*G3DPluginGetExtFunc) (G3DContext *context); + G3DPlugin; +gboolean g3d_plugins_init (G3DContext *context); +void g3d_plugins_cleanup (G3DContext *context); +gboolean g3d_plugins_load_model (G3DContext *context, + const gchar *filename, + G3DModel *model); +gboolean g3d_plugins_load_model_from_stream (G3DContext *context, + G3DStream *stream, + G3DModel *model); +gboolean g3d_plugins_load_image (G3DContext *context, + const gchar *filename, + G3DImage *image); +gboolean g3d_plugins_load_image_from_stream (G3DContext *context, + G3DStream *stream, + G3DImage *image); +gchar** g3d_plugins_get_image_extensions (G3DContext *context); ++
+Direct interaction with the plugin system is normally not needed when using +libg3d. It may be required when writing a plugin which should load a +G3DImage or a G3DModel with another plugin.
++ +
+typedef enum { + G3D_PLUGIN_UNKNOWN = 0x00, + G3D_PLUGIN_IMPORT, + G3D_PLUGIN_IMAGE +} G3DPluginType; ++
+Type of plugin.
++ +
+ +gpointer (*G3DPluginInitFunc) (G3DContext *context);+
+Prototype for plugin_init()
.
+ +
+
|
+the context + | +
Returns : |
+opaque plugin data. + | +
void (*G3DPluginCleanupFunc) (gpointer user_data);+
+Prototype for plugin_cleanup()
.
+ +
+
|
+opaque plugin data + | +
gboolean (*G3DPluginLoadModelFunc) (G3DContext *context, + const gchar *filename, + G3DModel *model, + gpointer user_data);+
+Prototype for plugin_load_model()
.
+ +
+
|
+the context + | +
|
+file name of model + | +
|
+the model structure to fill + | +
|
+opaque plugin data + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean (*G3DPluginLoadModelFromStreamFunc) (G3DContext *context, + G3DStream *stream, + G3DModel *model, + gpointer user_data);+
+Prototype for plugin_load_model_from_stream()
.
+ +
+
|
+the context + | +
|
+the stream to load from + | +
|
+the model structure to fill + | +
|
+opaque plugin data + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean (*G3DPluginLoadImageFunc) (G3DContext *context, + const gchar *filename, + G3DImage *image, + gpointer user_data);+
+Prototype for plugin_load_image()
.
+ +
+
|
+the context + | +
|
+file name of image + | +
|
+image structure to fill + | +
|
+opaque plugin data + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean (*G3DPluginLoadImageStreamFunc) (G3DContext *context, + G3DStream *stream, + G3DImage *image, + gpointer user_data);+
+Prototype for plugin_load_image_from_stream()
.
+ +
+
|
+the context + | +
|
+the stream to load from + | +
|
+image structure to fill + | +
|
+opaque plugin data + | +
Returns : |
+TRUE on success, FALSE else. + | +
gchar* (*G3DPluginGetDescFunc) (G3DContext *context);+
+Prototype for plugin_description()
.
+ +
+
|
+the context + | +
Returns : |
+a newly-allocated string containing the description of the plugin. + | +
gchar** (*G3DPluginGetExtFunc) (G3DContext *context);+
+Prototype for plugin_extensions()
.
+ +
+
|
+the context + | +
Returns : |
+ NULL-terminated list of file extensions supported by this plugin.
+Free with g_strfreev() .
+ |
+
gboolean g3d_plugins_init (G3DContext *context);+
+Initializes the plugin system. This is implicitly done when using
+g3d_context_new()
.
+ +
+
|
+a valid G3DContext + | +
Returns : |
+TRUE on success, FALSE else. + | +
void g3d_plugins_cleanup (G3DContext *context);+
+Clean up the plugin system. Usually done by g3d_context_free()
.
+ +
+
|
+a valid context + | +
gboolean g3d_plugins_load_model (G3DContext *context, + const gchar *filename, + G3DModel *model);+
+Try to load a model from file using import plugins.
++ +
+
|
+a valid context + | +
|
+file name of model to load + | +
|
+model structure to fill + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean g3d_plugins_load_model_from_stream (G3DContext *context, + G3DStream *stream, + G3DModel *model);+
+Try to load a model from stream using import plugins.
++ +
+
|
+a valid context + | +
|
+stream to load model from + | +
|
+model structure to fill + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean g3d_plugins_load_image (G3DContext *context, + const gchar *filename, + G3DImage *image);+
+Try to load an image from file using import plugins.
++ +
+
|
+a valid context + | +
|
+file name of image to load + | +
|
+image structure to fill + | +
Returns : |
+TRUE on success, FALSE else. + | +
gboolean g3d_plugins_load_image_from_stream (G3DContext *context, + G3DStream *stream, + G3DImage *image);+
+Try to load an image from stream using import plugins.
++ +
+
|
+a valid context + | +
|
+stream to load image from + | +
|
+image structure to fill + | +
Returns : |
+TRUE on success, FALSE else. + | +
gchar** g3d_plugins_get_image_extensions (G3DContext *context);+
+Get the supported image type extensions.
++ +
+
|
+a valid context + | +
Returns : |
+ NULL-terminated list of image file extensions supported by this
+plugin. Free with g_strfreev() .
+ |
+
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/primitive.h> + +G3DObject* g3d_primitive_cube (G3DFloat width, + G3DFloat height, + G3DFloat depth, + G3DMaterial *material); +G3DObject* g3d_primitive_box (G3DFloat width, + G3DFloat height, + G3DFloat depth, + G3DMaterial *material); +G3DObject* g3d_primitive_box_strip_2d (guint32 vcnt, + gdouble *vdata, + gdouble height, + gdouble width, + G3DMaterial *material); +G3DObject* g3d_primitive_mesh (guint32 m, + guint32 n, + gboolean wrap_m, + gboolean wrap_n, + G3DMaterial *material); +G3DObject* g3d_primitive_cylinder (G3DFloat radius, + G3DFloat height, + guint32 sides, + gboolean top, + gboolean bottom, + G3DMaterial *material); +G3DObject* g3d_primitive_tube (G3DFloat r_in, + G3DFloat r_out, + G3DFloat height, + guint32 sides, + gboolean top, + gboolean bottom, + G3DMaterial *material); +G3DObject* g3d_primitive_sphere (G3DFloat radius, + guint32 vseg, + guint32 hseg, + G3DMaterial *material); ++
+Primitives are objects containing basic 3D geometrical structures. A +variety of them can be created using these functions.
++ +
+G3DObject* g3d_primitive_cube (G3DFloat width, + G3DFloat height, + G3DFloat depth, + G3DMaterial *material);+
+Generates an object containing a box. It is deprecated and now a wrapper for
+g3d_primitive_box()
.
+ +
+
|
+the width of the box + | +
|
+the height of the box + | +
|
+the depth of the box + | +
|
+the material to use for all faces + | +
Returns : |
+the box object + | +
G3DObject* g3d_primitive_box (G3DFloat width, + G3DFloat height, + G3DFloat depth, + G3DMaterial *material);+
+Generates an object containing a box.
++ +
+
|
+the width of the box + | +
|
+the height of the box + | +
|
+the depth of the box + | +
|
+the material to use for all faces + | +
Returns : |
+the box object + | +
G3DObject* g3d_primitive_box_strip_2d (guint32 vcnt, + gdouble *vdata, + gdouble height, + gdouble width, + G3DMaterial *material);+
+Generates a strip of box segments defined by corner center points +using two-dimensional data (x/z plane).
++ +
+
|
+number of control points + | +
|
+2-dimensional control point data (2 * vcnt * gdouble) + | +
|
+height of resulting strip (y component) + | +
|
+width of strip (corner diameter) + | +
|
+material to use for faces + | +
Returns : |
+strip object + | +
G3DObject* g3d_primitive_mesh (guint32 m, + guint32 n, + gboolean wrap_m, + gboolean wrap_n, + G3DMaterial *material);+
+Generate a mesh consisting of m * n vertices. The vertex data is +initialized with (0.0, 0.0, 0.0) and has to be set to something +useful.
++ +
+
|
+number of vertices in m direction + | +
|
+number of vertices in n direction + | +
|
+wrap around in m direction + | +
|
+wrap around in n direction + | +
|
+material to use for faces + | +
Returns : |
+mesh object + | +
G3DObject* g3d_primitive_cylinder (G3DFloat radius, + G3DFloat height, + guint32 sides, + gboolean top, + gboolean bottom, + G3DMaterial *material);+
+Generates an object containing a cylinder.
++ +
+
|
+the radius of the cylinder + | +
|
+the height of the side faces + | +
|
+number of side faces (number of circle segments) + | +
|
+add top faces + | +
|
+add bottom faces + | +
|
+material to use for faces + | +
Returns : |
+cylinder object + | +
G3DObject* g3d_primitive_tube (G3DFloat r_in, + G3DFloat r_out, + G3DFloat height, + guint32 sides, + gboolean top, + gboolean bottom, + G3DMaterial *material);+
+Generates an object containing a tube (a cylinder with a hole).
++ +
+
|
+inner radius + | +
|
+outer radius + | +
|
+the height of the side faces + | +
|
+number of side faces (number of circle segments) + | +
|
+add top faces + | +
|
+add bottom faces + | +
|
+material to use for faces + | +
Returns : |
+tube object + | +
G3DObject* g3d_primitive_sphere (G3DFloat radius, + guint32 vseg, + guint32 hseg, + G3DMaterial *material);+
+Generates an object containing a sphere.
++ +
+
|
+radius + | +
|
+number of vertical segments + | +
|
+number of horizontal segments + | +
|
+material to use for faces + | +
Returns : |
+sphere object + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/quat.h> + +typedef G3DQuat; +gboolean g3d_quat_add (G3DQuat *qr, + G3DQuat *q1, + G3DQuat *q2); +gboolean g3d_quat_normalize (G3DQuat *q); +gboolean g3d_quat_rotate (G3DQuat *q, + G3DVector *axis, + G3DFloat angle); +gboolean g3d_quat_to_matrix (G3DQuat *q, + G3DMatrix *matrix); +gboolean g3d_quat_to_rotation_xyz (G3DQuat *q, + G3DFloat *rx, + G3DFloat *ry, + G3DFloat *rz); +gboolean g3d_quat_trackball (G3DQuat *q, + G3DFloat x1, + G3DFloat y1, + G3DFloat x2, + G3DFloat y2, + G3DFloat r); ++
gboolean g3d_quat_add (G3DQuat *qr, + G3DQuat *q1, + G3DQuat *q2);+
+Add two quats.
++ +
+
|
+result quat + | +
|
+first quat + | +
|
+second quat + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_quat_normalize (G3DQuat *q);+
+normalize the quaternion to a length of 1.0.
++ +
+
|
+a quaternion + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_quat_rotate (G3DQuat *q, + G3DVector *axis, + G3DFloat angle);+
+Encode a rotation around an axis into quaternion.
++ +
+
|
+resulting quat + | +
|
+rotation axis + | +
|
+rotation angle + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_quat_to_matrix (G3DQuat *q, + G3DMatrix *matrix);+
+Convert a quaternion to a transformation matrix.
++ +
+
|
+source quat + | +
|
+resulting matrix + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_quat_to_rotation_xyz (G3DQuat *q, + G3DFloat *rx, + G3DFloat *ry, + G3DFloat *rz);+
+Calculate the rotation around the three coordinate axes from a given +quaternion.
++ +
+
|
+a quaternion + | +
|
+rotation around x axis + | +
|
+rotation around y axis + | +
|
+rotation around z axis + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_quat_trackball (G3DQuat *q, + G3DFloat x1, + G3DFloat y1, + G3DFloat x2, + G3DFloat y2, + G3DFloat r);+
+Emulate a virtual trackball movement and return rotation as quaternion. +The x and y values of the starting and end point of the movement have +to be in the range -1.0 .. 1.0.
++ +
+
|
+resulting quaternion + | +
|
+x value of first point + | +
|
+y value of first point + | +
|
+x value of second point + | +
|
+y value of second point + | +
|
+radius of virtual trackball, usually 0.8 + | +
Returns : |
+TRUE on success, FALSE else + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/read.h> + +gint32 g3d_read_int8 (FILE *f); +gint32 g3d_read_int16_be (FILE *f); +gint32 g3d_read_int16_le (FILE *f); +gint32 g3d_read_int32_be (FILE *f); +gint32 g3d_read_int32_le (FILE *f); +G3DFloat g3d_read_float_be (FILE *f); +G3DFloat g3d_read_float_le (FILE *f); +G3DDouble g3d_read_double_be (FILE *f); +G3DDouble g3d_read_double_le (FILE *f); +gint32 g3d_read_cstr (FILE *f, + gchar *buffer, + gint32 max_len); ++
+The g3d_read_* family of functions is deprecated in favour of the G3DStream +interface.
++ +
+gint32 g3d_read_int8 (FILE *f);+
+Read a 1 byte signed integer from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_read_int16_be (FILE *f);+
+Read a 2 byte big-endian signed integer from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_read_int16_le (FILE *f);+
+Read a 2 byte little-endian signed integer from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_read_int32_be (FILE *f);+
+Read a 4 byte big-endian signed integer from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_read_int32_le (FILE *f);+
+Read a 4 byte little-endian signed integer from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DFloat g3d_read_float_be (FILE *f);+
+Read a 4 byte big-endian floating point number from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DFloat g3d_read_float_le (FILE *f);+
+Read a 4 byte little-endian floating point number from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DDouble g3d_read_double_be (FILE *f);+
+Read a 8 byte big-endian double-precision floating point number from file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DDouble g3d_read_double_le (FILE *f);+
+Read a 8 byte little-endian double-precision floating point number from +file.
++ +
+
|
+the file to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_read_cstr (FILE *f, + gchar *buffer, + gint32 max_len);+
+Read a zero-terminated string from file.
++ +
+
|
+the file to read from + | +
|
+the buffer to store line in + | +
|
+maximum length of string including termination character + | +
Returns : |
+number of bytes read from file. + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/stream.h> + + G3DStream; +G3DStream* g3d_stream_open_file (const gchar *filename, + const gchar *mode); +G3DStream* g3d_stream_open_structured_file (const gchar *filename, + const gchar *subfile); +G3DStream* g3d_stream_open_structured_file_from_stream + (G3DStream *stream, + const gchar *subfile); +G3DStream* g3d_stream_open_zip (const gchar *filename, + const gchar *subfile); +G3DStream* g3d_stream_open_zip_from_stream (G3DStream *stream, + const gchar *subfile); +G3DStream* g3d_stream_open_gzip_from_stream (G3DStream *stream); +G3DStream* g3d_stream_from_buffer (guint8 *buffer, + gsize size, + const gchar *title, + gboolean free_buffer); +G3DStream* g3d_stream_zlib_inflate_stream (G3DStream *stream, + gsize cmp_size); +G3DStream* g3d_stream_new_custom (guint32 flags, + const gchar *uri, + G3DStreamReadFunc readfunc, + G3DStreamReadLineFunc readlinefunc, + G3DStreamSeekFunc seekfunc, + G3DStreamTellFunc tellfunc, + G3DStreamSizeFunc sizefunc, + G3DStreamEofFunc eoffunc, + G3DStreamCloseFunc closefunc, + gpointer data); +gint g3d_stream_close (G3DStream *stream); +gint g3d_stream_skip (G3DStream *stream, + goffset offset); +gint g3d_stream_seek (G3DStream *stream, + goffset offset, + GSeekType whence); +goffset g3d_stream_tell (G3DStream *stream); +goffset g3d_stream_size (G3DStream *stream); +gboolean g3d_stream_eof (G3DStream *stream); +gboolean g3d_stream_is_seekable (G3DStream *stream); +gchar* g3d_stream_get_uri (G3DStream *stream); +guint32 g3d_stream_line (G3DStream *stream); +gsize g3d_stream_read (G3DStream *stream, + gpointer ptr, + gsize size); +gchar* g3d_stream_read_line (G3DStream *stream, + gchar *buf, + gsize size); +gint32 g3d_stream_read_int8 (G3DStream *stream); +gint32 g3d_stream_read_int16_be (G3DStream *stream); +gint32 g3d_stream_read_int16_le (G3DStream *stream); +gint32 g3d_stream_read_int32_be (G3DStream *stream); +gint32 g3d_stream_read_int32_le (G3DStream *stream); +G3DFloat g3d_stream_read_float_be (G3DStream *stream); +G3DFloat g3d_stream_read_float_le (G3DStream *stream); +G3DDouble g3d_stream_read_double_be (G3DStream *stream); +G3DDouble g3d_stream_read_double_le (G3DStream *stream); +gint32 g3d_stream_read_cstr (G3DStream *stream, + gchar *buffer, + gint32 max_len); +gint (*G3DStreamCloseFunc) (gpointer data); +gboolean (*G3DStreamEofFunc) (gpointer data); +gsize (*G3DStreamReadFunc) (gpointer ptr, + gsize size, + gpointer data); +gchar* (*G3DStreamReadLineFunc) (gchar *buf, + gsize size, + gpointer data); +gint (*G3DStreamSeekFunc) (gpointer data, + goffset offset, + GSeekType whence); +goffset (*G3DStreamSizeFunc) (gpointer data); +goffset (*G3DStreamTellFunc) (gpointer data); ++
+A stream is an abstraction for data input. It enables plugins to read +data from a file, a memory buffer, a container file or some other medium.
++ +
+G3DStream* g3d_stream_open_file (const gchar *filename, + const gchar *mode);+
+Opens a file with the C stdio routines.
++ +
+
|
+the name of the file to open + | +
|
+ the mode to open the file, as given to fopen()
+ |
+
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_open_structured_file (const gchar *filename, + const gchar *subfile);+
+Open a file within a Structured File as G3DStream.
++ +
+
|
+name of container file + | +
|
+name of (contained) sub-file + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_open_structured_file_from_stream + (G3DStream *stream, + const gchar *subfile);+
+Open a file within a Structured File which is opened as a stream. At the
+moment this only works for streams opened by g3d_stream_open_file()
as
+the file is directly opened again.
+ +
+
|
+stream of container file + | +
|
+name of (contained) sub-file + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_open_zip (const gchar *filename, + const gchar *subfile);+
+Open a file within a Zip archive.
++ +
+
|
+name of container file + | +
|
+name of (contained) sub-file + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_open_zip_from_stream (G3DStream *stream, + const gchar *subfile);+
+Open a file within a Zip archive which is opened as a stream. At the
+moment this only works for streams opened by g3d_stream_open_file()
as
+the file is directly opened again.
+ +
+
|
+stream of container file + | +
|
+name of (contained) sub-file + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_open_gzip_from_stream (G3DStream *stream);+
+Reads data from a gzip-compressed stream.
++ +
+
|
+stream to read from + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_from_buffer (guint8 *buffer, + gsize size, + const gchar *title, + gboolean free_buffer);+
+Use a buffer in memory as G3DStream.
++ +
+
|
+memory buffer to use + | +
|
+size of buffer + | +
|
+optional title of stream, may be NULL + | +
|
+ whether to free the memory with g_free() on g3d_stream_close()
+ |
+
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
G3DStream* g3d_stream_zlib_inflate_stream (G3DStream *stream, + gsize cmp_size);+
+Opens a new stream to decompress zlib-deflated parts of a stream.
++ +
+
|
+a parent stream + | +
|
+the compressed size of the deflated part + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error + | +
G3DStream* g3d_stream_new_custom (guint32 flags, + const gchar *uri, + G3DStreamReadFunc readfunc, + G3DStreamReadLineFunc readlinefunc, + G3DStreamSeekFunc seekfunc, + G3DStreamTellFunc tellfunc, + G3DStreamSizeFunc sizefunc, + G3DStreamEofFunc eoffunc, + G3DStreamCloseFunc closefunc, + gpointer data);+
+Creates a new G3DStream with custom callback functions.
++ +
+
|
+stream capability flags + | +
|
+URI of new stream, must not be NULL + | +
|
+read callback function + | +
|
+ read line callback function, may be NULL in which case
+line reading is emulated with g3d_stream_read()
+ |
+
|
+seek callback function + | +
|
+tell callback function + | +
|
+size callback function + | +
|
+end-of-file callback function + | +
|
+close callback function + | +
|
+opaque data for all callback functions + | +
Returns : |
+a newly allocated G3DStream or NULL in case of an error. + | +
gint g3d_stream_close (G3DStream *stream);+
+Closes an open stream.
++ +
+
|
+the stream + | +
Returns : |
+0 on success. + | +
gint g3d_stream_skip (G3DStream *stream, + goffset offset);+
+Skip a number of bytes (>= 0) in stream even if it does not support +seeking.
++ +
+
|
+stream to skip bytes from + | +
|
+number of bytes to skip + | +
Returns : |
+0 on success, -1 else + | +
gint g3d_stream_seek (G3DStream *stream, + goffset offset, + GSeekType whence);+
+Moves around the current position in the stream.
++ +
+
|
+stream to seek in + | +
|
+number of bytes to seek + | +
|
+seek type + | +
Returns : |
+0 on success, -1 else + | +
goffset g3d_stream_tell (G3DStream *stream);+
+Tells the current position in the stream.
++ +
+
|
+stream to get position from + | +
Returns : |
+current stream position + | +
goffset g3d_stream_size (G3DStream *stream);+
+Get the size in bytes of a stream.
++ +
+
|
+stream to get size from + | +
Returns : |
+size of stream in bytes + | +
gboolean g3d_stream_eof (G3DStream *stream);+
+Checks whether the stream has reached its end.
++ +
+
|
+the stream + | +
Returns : |
+TRUE if no more data can be read, FALSE else. + | +
gboolean g3d_stream_is_seekable (G3DStream *stream);+
+Get information whether it is possible to seek in a stream.
++ +
+
|
+the stream + | +
Returns : |
+TRUE if seekable, FALSE else + | +
gchar* g3d_stream_get_uri (G3DStream *stream);+
+Get the URI of a stream
++ +
+
|
+the stream + | +
Returns : |
+a non-NULL, zero-terminated string containing the URI of the +string. This return value should not be freed. + | +
guint32 g3d_stream_line (G3DStream *stream);+
+Get the current line number from stream. This only works if line are
+consequently read with g3d_stream_read_line()
, so it's only applicable
+for text streams.
+ +
+
|
+stream to get line from + | +
Returns : |
+current line number, may be 0 + | +
gsize g3d_stream_read (G3DStream *stream, + gpointer ptr, + gsize size);+
+Reads a number of bytes from the stream.
++ +
+
|
+the stream to read from + | +
|
+pointer to memory storage + | +
|
+number of bytes to read + | +
Returns : |
+number of bytes successfully read. + | +
gchar* g3d_stream_read_line (G3DStream *stream, + gchar *buf, + gsize size);+
+Read a line (terminated by a newline character or end of file) from a +stream.
++ +
+
|
+stream to read a line from + | +
|
+an allocated buffer to be filled + | +
|
+maximum length of line including terminating zero + | +
Returns : |
+the read line or NULL in case of an error. + | +
gint32 g3d_stream_read_int8 (G3DStream *stream);+
+Read a 1 byte signed integer from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_stream_read_int16_be (G3DStream *stream);+
+Read a 2 byte big-endian signed integer from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_stream_read_int16_le (G3DStream *stream);+
+Read a 2 byte little-endian signed integer from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_stream_read_int32_be (G3DStream *stream);+
+Read a 4 byte big-endian signed integer from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_stream_read_int32_le (G3DStream *stream);+
+Read a 4 byte little-endian signed integer from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DFloat g3d_stream_read_float_be (G3DStream *stream);+
+Read a 4 byte big-endian floating point number from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DFloat g3d_stream_read_float_le (G3DStream *stream);+
+Read a 4 byte little-endian floating point number from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DDouble g3d_stream_read_double_be (G3DStream *stream);+
+Read a 8 byte big-endian double-precision floating point number from file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
G3DDouble g3d_stream_read_double_le (G3DStream *stream);+
+Read a 8 byte little-endian double-precision floating point number from +file.
++ +
+
|
+the stream to read from + | +
Returns : |
+The read value, 0 in case of error + | +
gint32 g3d_stream_read_cstr (G3DStream *stream, + gchar *buffer, + gint32 max_len);+
+Read a string (terminated by '\0') from stream
++ +
+
|
+the stream to read from + | +
|
+the buffer to fill + | +
|
+maximum number to read from stream + | +
Returns : |
+number of bytes read from stream + | +
gint (*G3DStreamCloseFunc) (gpointer data);+
+Callback function for g3d_stream_close()
.
+ +
+
|
+opaque stream data + | +
Returns : |
+0 on success, -1 else. + | +
gboolean (*G3DStreamEofFunc) (gpointer data);+
+Callback function for g3d_stream_eof()
.
+ +
+
|
+opaque stream data + | +
Returns : |
+TRUE on stream end-of-file, FALSE else. + | +
gsize (*G3DStreamReadFunc) (gpointer ptr, + gsize size, + gpointer data);+
+Callback function for g3d_stream_read()
.
+ +
+
|
+buffer to read bytes into + | +
|
+number of bytes to read + | +
|
+opaque stream data + | +
Returns : |
+number of bytes actually read. + | +
gchar* (*G3DStreamReadLineFunc) (gchar *buf, + gsize size, + gpointer data);+
+Callback function for g3d_stream_read_line()
.
+ +
+
|
+buffer to read bytes into + | +
|
+maximum size of buffer + | +
|
+opaque stream data + | +
Returns : |
+The line buffer or NULL in case of an error. + | +
gint (*G3DStreamSeekFunc) (gpointer data, + goffset offset, + GSeekType whence);+
+Callback function for g3d_stream_seek()
.
+ +
+
|
+opaque stream data + | +
|
+seek offset + | +
|
+seek type + | +
Returns : |
+0 on success, -1 else. + | +
goffset (*G3DStreamSizeFunc) (gpointer data);+
+Callback function for g3d_stream_size()
.
+ +
+
|
+opaque stream data + | +
Returns : |
+size of stream. + | +
goffset (*G3DStreamTellFunc) (gpointer data);+
+Callback function for g3d_stream_tell()
.
+ +
+
|
+opaque stream data + | +
Returns : |
+current stream position. + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/texture.h> + +#define G3D_FLAG_IMG_GREYSCALE +enum G3DTexEnv; + G3DImage; +G3DImage* g3d_texture_load_cached (G3DContext *context, + G3DModel *model, + const gchar *filename); +G3DImage* g3d_texture_load_from_stream (G3DContext *context, + G3DModel *model, + G3DStream *stream); +G3DImage* g3d_texture_load (G3DContext *context, + const gchar *filename); +void g3d_texture_free (G3DImage *texture); +gboolean g3d_texture_prepare (G3DImage *texture); +gboolean g3d_texture_flip_y (G3DImage *texture); +G3DImage* g3d_texture_merge_alpha (G3DImage *image, + G3DImage *aimage); ++
+A texture is an image used in materials. Here are some helper functions, +mostly for cached loading of a G3DImage.
++ +
+#define G3D_FLAG_IMG_GREYSCALE (1L << 1) ++
+The image just uses the red channel for grey value
++ +
+typedef enum { + G3D_TEXENV_UNSPECIFIED = 0, + G3D_TEXENV_BLEND, + G3D_TEXENV_DECAL, + G3D_TEXENV_MODULATE, + G3D_TEXENV_REPLACE +} G3DTexEnv; ++
+Specify how the texture should interact with other material properties.
++ +
+ +typedef struct { + gchar *name; + guint32 width; + guint32 height; + guint8 depth; + guint32 flags; + guint8 *pixeldata; + + guint32 tex_id; + G3DTexEnv tex_env; + G3DFloat tex_scale_u; + G3DFloat tex_scale_v; +} G3DImage; ++
+Object containing a two-dimensional pixel image.
++ +
+gchar * |
+name of image + | +
guint32 |
+width of image in pixels + | +
guint32 |
+height of image in pixels + | +
guint8 |
+depth of image in bits + | +
guint32 |
+flags + | +
guint8 * |
+the binary image data + | +
guint32 |
+the OpenGL texture id, should be unique model-wide + | +
G3DTexEnv |
+texture environment flags + | +
G3DFloat |
+factor scaling texture width, should be 1.0 for most cases + | +
G3DFloat |
+factor scaling texture height, should be 1.0 for most cases + | +
G3DImage* g3d_texture_load_cached (G3DContext *context, + G3DModel *model, + const gchar *filename);+
+Loads a texture image from file and attaches it to a hash table in the +model. On a second try to load this texture it is returned from cache.
++ +
+
|
+a valid context + | +
|
+a valid model + | +
|
+the file name of the texture to load + | +
Returns : |
+the texture image + | +
G3DImage* g3d_texture_load_from_stream (G3DContext *context, + G3DModel *model, + G3DStream *stream);+
+Load a texture image from a stream. The file type is determined by the
+extension of the stream URI, so it should be valid. If model
is not NULL
+the texture image is cached (or retrieved from cache if available).
+ +
+
|
+a valid context + | +
|
+a valid model or NULL + | +
|
+an open stream + | +
Returns : |
+the texture image or NULL in case of an error. + | +
G3DImage* g3d_texture_load (G3DContext *context, + const gchar *filename);+
+Load a texture from a file. The type of file is determined by the file +extension.
++ +
+
|
+a valid context + | +
|
+the file name of the texture + | +
Returns : |
+the texture image or NULL in case of an error. + | +
void g3d_texture_free (G3DImage *texture);+
+Frees all memory used by this texture image.
++ +
+
|
+a texture image + | +
gboolean g3d_texture_prepare (G3DImage *texture);+
+Resizes the image to dimensions which are a power of 2 to be +usable as an OpenGL texture. +(FIXME: unimplemented)
++ +
+
|
+a texture image + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_texture_flip_y (G3DImage *texture);+
+Mirror the image along the x axis - all y coordinates are inverted.
++ +
+
|
+a texture image + | +
Returns : |
+TRUE on success, FALSE on error. + | +
G3DImage* g3d_texture_merge_alpha (G3DImage *image, + G3DImage *aimage);+
+Merges alpha information from aimage
into output image. If image
is NULL a
+new image is created, else image
is returned with alpha from aimage
.
+ +
+
|
+a texture image or NULL + | +
|
+an image with alpha information + | +
Returns : |
+a texture image or NULL in case of an error. + | +
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/types.h> + +typedef G3DSingle; +typedef G3DDouble; +typedef G3DFloat; +#define G3D_FLOAT_IS_DOUBLE ++
+ | + | + | libg3d Reference Manual | ++ |
---|---|---|---|---|
+ +#include <g3d/vector.h> + +typedef G3DVector; +gboolean g3d_vector_normal (G3DFloat ax, + G3DFloat ay, + G3DFloat az, + G3DFloat bx, + G3DFloat by, + G3DFloat bz, + G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz); +gboolean g3d_vector_unify (G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz); +gboolean g3d_vector_transform (G3DFloat *x, + G3DFloat *y, + G3DFloat *z, + G3DMatrix *matrix); ++
+A vector is a one-dimensional array of floating point data. +
++Declare it as statically as: +
++G3DVector vector[3]; +
++or allocate it dynamically with: +
++G3DVector *vector = g3d_vector_new(3, 1);
++ +
+gboolean g3d_vector_normal (G3DFloat ax, + G3DFloat ay, + G3DFloat az, + G3DFloat bx, + G3DFloat by, + G3DFloat bz, + G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz);+
+calculate the normal from a plane defined by two vectors
++ +
+
|
+x component first vector + | +
|
+y component first vector + | +
|
+z component first vector + | +
|
+x component second vector + | +
|
+y component second vector + | +
|
+z component second vector + | +
|
+x component resulting normal + | +
|
+y component resulting normal + | +
|
+z component resulting normal + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_vector_unify (G3DFloat *nx, + G3DFloat *ny, + G3DFloat *nz);+
+Transforms the given vector to the unit vector.
++ +
+
|
+x component of vector + | +
|
+y component of vector + | +
|
+z component of vector + | +
Returns : |
+TRUE on success, FALSE else + | +
gboolean g3d_vector_transform (G3DFloat *x, + G3DFloat *y, + G3DFloat *z, + G3DMatrix *matrix);+
+Transforms the given vector corresponding to the given matrix
++ +
+
|
+x component of vector + | +
|
+y component of vector + | +
|
+z component of vector + | +
|
+transformation matrix (4x4) + | +
Returns : |
+TRUE on success, FALSE else + | +