diff options
Diffstat (limited to 'src/others/mimesh/g3dviewer-0.2.99.4/src/model.c')
-rw-r--r-- | src/others/mimesh/g3dviewer-0.2.99.4/src/model.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/others/mimesh/g3dviewer-0.2.99.4/src/model.c b/src/others/mimesh/g3dviewer-0.2.99.4/src/model.c new file mode 100644 index 0000000..560affe --- /dev/null +++ b/src/others/mimesh/g3dviewer-0.2.99.4/src/model.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* $Id: model.c 54 2006-06-05 11:33:11Z mmmaddd $ */ | ||
2 | |||
3 | /* | ||
4 | G3DViewer - 3D object viewer | ||
5 | |||
6 | Copyright (C) 2005, 2006 Markus Dahms <mad@automagically.de> | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program 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 | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <g3d/g3d.h> | ||
24 | |||
25 | #include "main.h" | ||
26 | #include "texture.h" | ||
27 | #include "gui_glade.h" | ||
28 | #include "gui_infowin.h" | ||
29 | #include "gui_log.h" | ||
30 | |||
31 | gboolean model_load(G3DViewer *viewer) | ||
32 | { | ||
33 | G3DModel *model; | ||
34 | gchar *title; | ||
35 | gboolean retval = FALSE; | ||
36 | |||
37 | /* free old model */ | ||
38 | model = viewer->model; | ||
39 | viewer->model = NULL; | ||
40 | if(model) | ||
41 | g3d_model_free(model); | ||
42 | |||
43 | /* clean log */ | ||
44 | gui_log_clean(viewer); | ||
45 | |||
46 | model = g3d_model_load(viewer->g3dcontext, viewer->filename); | ||
47 | if(model) | ||
48 | { | ||
49 | viewer->model = model; | ||
50 | texture_load_all_textures(viewer->model); | ||
51 | title = g_strdup_printf(_("%s successfully loaded."), | ||
52 | viewer->filename ? viewer->filename : _("unnamed model")); | ||
53 | gui_glade_status(viewer, title); | ||
54 | g_free(title); | ||
55 | retval = TRUE; | ||
56 | } | ||
57 | |||
58 | #if DEBUG > 3 | ||
59 | g_printerr("[model] model pointer: %p\n", model); | ||
60 | #endif | ||
61 | |||
62 | /* update model information */ | ||
63 | gui_infowin_update(viewer); | ||
64 | |||
65 | /* update window title */ | ||
66 | title = g_strdup_printf("g3dviewer%s%s", | ||
67 | viewer->model ? " - " : "", | ||
68 | viewer->filename ? viewer->filename : ""); | ||
69 | gtk_window_set_title(GTK_WINDOW(viewer->interface.window), title); | ||
70 | g_free(title); | ||
71 | |||
72 | return retval; | ||
73 | } | ||