diff options
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/plugins/import/imp_vrml2/imp_vrml2.c')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/plugins/import/imp_vrml2/imp_vrml2.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_vrml2/imp_vrml2.c b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_vrml2/imp_vrml2.c new file mode 100644 index 0000000..f295175 --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/plugins/import/imp_vrml2/imp_vrml2.c | |||
@@ -0,0 +1,82 @@ | |||
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 | /* | ||
24 | * an experiment to parse VRML without flex, version 2 is tried as a starter, | ||
25 | * v1 and Inventor stuff will be added if successful. | ||
26 | */ | ||
27 | |||
28 | #include <stdlib.h> | ||
29 | #include <string.h> | ||
30 | #include <locale.h> | ||
31 | |||
32 | #include <g3d/types.h> | ||
33 | #include <g3d/stream.h> | ||
34 | |||
35 | #include "imp_vrml2.h" | ||
36 | #include "imp_vrml_read.h" | ||
37 | |||
38 | EAPI | ||
39 | gboolean plugin_load_model_from_stream(G3DContext *context, G3DStream *stream, | ||
40 | G3DModel *model, gpointer user_data) | ||
41 | { | ||
42 | gchar buf[128]; | ||
43 | gboolean retval; | ||
44 | VrmlReader *reader; | ||
45 | |||
46 | setlocale(LC_NUMERIC, "C"); | ||
47 | |||
48 | buf[127] = '\0'; | ||
49 | g3d_stream_read_line(stream, buf, 127); | ||
50 | if(strncmp(buf, "#VRML V2.0 utf8", 15) != 0) { | ||
51 | g_warning("%s is not a valid VRML 2.0 UTF-8 stream", stream->uri); | ||
52 | return FALSE; | ||
53 | } | ||
54 | |||
55 | reader = g_new0(VrmlReader, 1); | ||
56 | reader->max_bufsize = 2048; | ||
57 | reader->buffer = g_new0(gchar, reader->max_bufsize); | ||
58 | reader->bufp = reader->buffer; | ||
59 | reader->line = 2; | ||
60 | reader->stream = stream; | ||
61 | reader->model = model; | ||
62 | |||
63 | retval = vrml_read_global(reader); | ||
64 | |||
65 | g_free(reader); | ||
66 | |||
67 | return retval; | ||
68 | } | ||
69 | |||
70 | EAPI | ||
71 | gchar *plugin_description(void) | ||
72 | { | ||
73 | return g_strdup("VRML v2 models."); | ||
74 | } | ||
75 | |||
76 | EAPI | ||
77 | gchar **plugin_extensions(void) | ||
78 | { | ||
79 | return g_strsplit("wrl", ":", 0); | ||
80 | } | ||
81 | |||
82 | /*****************************************************************************/ | ||