diff options
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/plugins/import/imp_acf/imp_acf_detect.c')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/plugins/import/imp_acf/imp_acf_detect.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_acf/imp_acf_detect.c b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_acf/imp_acf_detect.c new file mode 100644 index 0000000..6f8070d --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_acf/imp_acf_detect.c | |||
@@ -0,0 +1,77 @@ | |||
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 "imp_acf_detect.h" | ||
24 | #include "imp_acf_def_acf603.h" | ||
25 | #include "imp_acf_def_acf625.h" | ||
26 | #include "imp_acf_def_acf630.h" | ||
27 | #include "imp_acf_def_acf640.h" | ||
28 | #include "imp_acf_def_acf651.h" | ||
29 | #include "imp_acf_def_acf700.h" | ||
30 | #include "imp_acf_def_acf740.h" | ||
31 | |||
32 | typedef struct { | ||
33 | goffset size; | ||
34 | guint32 vmajor; | ||
35 | guint32 vminor; | ||
36 | const AcfDef *def; | ||
37 | } AcfDetectInfo; | ||
38 | |||
39 | static AcfDetectInfo acf_detect_info[] = { | ||
40 | { 433337, 6, 3, acf_def_acf603 }, | ||
41 | { 433693, 6, 25, acf_def_acf625 }, | ||
42 | { 453981, 6, 30, acf_def_acf630 }, | ||
43 | { 454977, 6, 40, acf_def_acf640 }, | ||
44 | { 454985, 6, 51, acf_def_acf651 }, | ||
45 | { 646626, 7, 0, acf_def_acf700 }, | ||
46 | { 647101, 7, 40, acf_def_acf740 }, | ||
47 | { 0, 0, 0, NULL } | ||
48 | }; | ||
49 | |||
50 | const AcfDef *acf_detect_version(AcfGlobalData *global) | ||
51 | { | ||
52 | gint32 i; | ||
53 | |||
54 | for(i = 0; acf_detect_info[i].size > 0; i ++) { | ||
55 | if(g3d_stream_size(global->stream) == acf_detect_info[i].size) { | ||
56 | #if DEBUG > 0 | ||
57 | g_debug("ACF: version %d.%02d detected", | ||
58 | acf_detect_info[i].vmajor, acf_detect_info[i].vminor); | ||
59 | #endif | ||
60 | return acf_detect_info[i].def; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | for(i = 0; acf_detect_info[i].size > 0; i ++) | ||
65 | if(acf_detect_info[i].size > g3d_stream_size(global->stream)) { | ||
66 | #if DEBUG > 0 | ||
67 | g_debug("ACF: falling back to version %d.%02d", | ||
68 | acf_detect_info[i].vmajor, acf_detect_info[i].vminor); | ||
69 | #endif | ||
70 | return acf_detect_info[i].def; | ||
71 | } | ||
72 | |||
73 | /* FIXME: return 7.40 for models newer than that */ | ||
74 | |||
75 | g_warning("ACF: could not detect version"); | ||
76 | return NULL; | ||
77 | } | ||