diff options
Diffstat (limited to '')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh.c b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh.c new file mode 100644 index 0000000..c763dab --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh.c | |||
@@ -0,0 +1,88 @@ | |||
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 | #include <stdio.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | #include <glib.h> | ||
27 | |||
28 | #include <g3d/iff.h> | ||
29 | #include <g3d/stream.h> | ||
30 | |||
31 | #include "imp_rbh_chunks.h" | ||
32 | |||
33 | EAPI | ||
34 | gboolean plugin_load_model_from_stream(G3DContext *context, G3DStream *stream, | ||
35 | G3DModel *model, gpointer user_data) | ||
36 | { | ||
37 | G3DIffGlobal *global; | ||
38 | G3DIffLocal *local; | ||
39 | guint32 id, len; | ||
40 | |||
41 | id = g3d_stream_read_int32_be(stream); | ||
42 | len = g3d_stream_read_int32_le(stream); | ||
43 | |||
44 | if(id != G3D_IFF_MKID('P', 'I', 'F', 'F')) | ||
45 | { | ||
46 | g_warning("%s is not a PIFF file", stream->uri); | ||
47 | return FALSE; | ||
48 | } | ||
49 | |||
50 | id = g3d_stream_read_int32_be(stream); | ||
51 | len -= 4; | ||
52 | if(id != G3D_IFF_MKID('R', 'B', 'H', 'F')) | ||
53 | { | ||
54 | g_warning("%s is not a RBHF file", stream->uri); | ||
55 | return FALSE; | ||
56 | } | ||
57 | |||
58 | local = g_new0(G3DIffLocal, 1); | ||
59 | global = g_new0(G3DIffGlobal, 1); | ||
60 | |||
61 | global->context = context; | ||
62 | global->model = model; | ||
63 | global->stream = stream; | ||
64 | |||
65 | local->parent_id = id; | ||
66 | local->nb = len; | ||
67 | |||
68 | g3d_iff_read_ctnr(global, local, rbh_chunks, G3D_IFF_LE | G3D_IFF_PAD2); | ||
69 | |||
70 | g_free(local); | ||
71 | g_free(global); | ||
72 | |||
73 | return TRUE; | ||
74 | |||
75 | } | ||
76 | |||
77 | EAPI | ||
78 | gchar *plugin_description(void) | ||
79 | { | ||
80 | return g_strdup("Discworld Noir models."); | ||
81 | } | ||
82 | |||
83 | EAPI | ||
84 | gchar **plugin_extensions(void) | ||
85 | { | ||
86 | return g_strsplit("rbh", ":", 0); | ||
87 | } | ||
88 | |||