xoreos  0.0.5
model.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <cassert>
26 
27 #include "src/common/ustring.h"
28 #include "src/common/error.h"
29 
32 
33 namespace Engines {
34 
36 
38  kModelLoader = loader;
39 }
40 
42  delete kModelLoader;
43 
44  kModelLoader = 0;
45 }
46 
48  const Common::UString &texture) {
49  assert(kModelLoader);
50 
51  Graphics::Aurora::Model *model = 0;
52 
53  try {
54 
55  if (!resref.empty())
56  model = kModelLoader->load(resref, Graphics::Aurora::kModelTypeObject, texture);
57 
58  } catch (...) {
59  Common::exceptionDispatcherWarning("Failed to load object model \"%s\"", resref.c_str());
60  }
61 
62  return model;
63 }
64 
66  assert(kModelLoader);
67 
68  Graphics::Aurora::Model *model = 0;
69 
70  try {
71 
72  if (!resref.empty())
74 
75  } catch (...) {
76  Common::exceptionDispatcherWarning("Failed to load GUI model \"%s\"", resref.c_str());
77  }
78 
79  return model;
80 }
81 
83  assert(kModelLoader);
84 
85  kModelLoader->free(model);
86 }
87 
88 } // End of namespace Engines
virtual Graphics::Aurora::Model * load(const Common::UString &resref, Graphics::Aurora::ModelType type, const Common::UString &texture)=0
An element of the front GUI.
Definition: types.h:53
A class holding an UTF-8 string.
Definition: ustring.h:48
A real object in the game world.
Definition: types.h:52
virtual void free(Graphics::Aurora::Model *&model)
Definition: modelloader.cpp:34
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
Definition: error.cpp:158
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
void freeModel(Graphics::Aurora::Model *&model)
Definition: model.cpp:82
An abstract Aurora model loader.
void unregisterModelLoader()
Definition: model.cpp:41
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
static ModelLoader * kModelLoader
Definition: model.cpp:35
Unicode string handling.
void registerModelLoader(ModelLoader *loader)
Definition: model.cpp:37
Graphics::Aurora::Model * loadModelGUI(const Common::UString &resref)
Definition: model.cpp:65
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
Definition: model.cpp:47
Generic Aurora engines model functions.