diff options
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh_callbacks.c')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh_callbacks.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh_callbacks.c b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh_callbacks.c new file mode 100644 index 0000000..04dca62 --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_rbh/imp_rbh_callbacks.c | |||
@@ -0,0 +1,116 @@ | |||
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 | #include <string.h> | ||
23 | |||
24 | #include <g3d/iff.h> | ||
25 | #include <g3d/stream.h> | ||
26 | #include <g3d/material.h> | ||
27 | #include <g3d/debug.h> | ||
28 | |||
29 | static gchar *padding = " "; | ||
30 | |||
31 | /* header */ | ||
32 | gboolean rbh_cb_RBHH(G3DIffGlobal *global, G3DIffLocal *local) | ||
33 | { | ||
34 | guint32 x0, x1, x2; | ||
35 | guint32 i, num; | ||
36 | |||
37 | num = local->nb / 12; | ||
38 | for(i = 0; i < num; i ++) | ||
39 | { | ||
40 | x0 = g3d_stream_read_int32_le(global->stream); | ||
41 | x1 = g3d_stream_read_int32_le(global->stream); | ||
42 | x2 = g3d_stream_read_int32_le(global->stream); | ||
43 | local->nb -= 12; | ||
44 | |||
45 | g_debug("\\%s[RBH][RBHH] %d: 0x%08x 0x%08x 0x%08x", | ||
46 | padding + (strlen(padding) - local->level), | ||
47 | i + 1, x0, x1, x2); | ||
48 | } | ||
49 | |||
50 | return TRUE; | ||
51 | } | ||
52 | |||
53 | /* body */ | ||
54 | gboolean rbh_cb_BODY(G3DIffGlobal *global, G3DIffLocal *local) | ||
55 | { | ||
56 | guint32 nverts, nfaces; | ||
57 | guint32 maxx = 0, x; | ||
58 | G3DObject *object; | ||
59 | G3DMaterial *material; | ||
60 | |||
61 | if(local->nb < 4) return TRUE; /* zero size BODY tags? */ | ||
62 | |||
63 | |||
64 | nverts = g3d_stream_read_int16_le(global->stream); | ||
65 | |||
66 | nfaces = g3d_stream_read_int16_le(global->stream); | ||
67 | local->nb -= 4; | ||
68 | |||
69 | g_debug( | ||
70 | "\\%s[RBH][BODY] %d verts, %d faces, %d bytes remaining (%d x 4 + %d)", | ||
71 | padding + (strlen(padding) - local->level), | ||
72 | nverts, nfaces, local->nb, | ||
73 | local->nb / 4, local->nb % 4); | ||
74 | |||
75 | if(nverts == 0) return TRUE; /* skip for now */ | ||
76 | |||
77 | object = g_new0(G3DObject, 1); | ||
78 | object->name = g_strdup("BODY"); | ||
79 | |||
80 | material = g3d_material_new(); | ||
81 | object->materials = g_slist_append(object->materials, material); | ||
82 | |||
83 | global->model->objects = g_slist_append(global->model->objects, object); | ||
84 | |||
85 | while(local->nb >= 4) | ||
86 | { | ||
87 | x = g3d_stream_read_int32_le(global->stream); | ||
88 | if(x > maxx) maxx = x; | ||
89 | local->nb -= 4; | ||
90 | } | ||
91 | |||
92 | g_debug("\\%s[RBH][BODY] max. value: %d", | ||
93 | padding + (strlen(padding) - local->level), | ||
94 | maxx); | ||
95 | |||
96 | return TRUE; | ||
97 | } | ||
98 | |||
99 | /* ?? */ | ||
100 | gboolean rbh_cb_RELC(G3DIffGlobal *global, G3DIffLocal *local) | ||
101 | { | ||
102 | guint32 maxx = 0, x; | ||
103 | |||
104 | while(local->nb >= 4) | ||
105 | { | ||
106 | x = g3d_stream_read_int32_le(global->stream); | ||
107 | if(x > maxx) maxx = x; | ||
108 | local->nb -= 4; | ||
109 | } | ||
110 | |||
111 | g_debug("\\%s[RBH][RELC] max. value: %d", | ||
112 | padding + (strlen(padding) - local->level), | ||
113 | maxx); | ||
114 | |||
115 | return TRUE; | ||
116 | } | ||