xoreos  0.0.5
room.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 "src/common/error.h"
26 
28 
31 
32 #include "src/engines/jade/room.h"
33 
34 namespace Engines {
35 
36 namespace Jade {
37 
38 Room::Room(const Common::UString &resRef, uint32 id, float x, float y, float z, bool walkable) :
39  _resRef(resRef), _walkable(walkable) {
40 
41  load(resRef, id, x, y, z);
42 }
43 
45  unload();
46 }
47 
49  return _resRef;
50 }
51 
52 bool Room::isWalkable() const {
53  return _walkable;
54 }
55 
56 void Room::load(const Common::UString &resRef, uint32 id, float x, float y, float z) {
57  if (resRef == "****")
58  return;
59 
60  indexOptionalArchive(resRef + "-a.rim", 1100 + id, &_resources);
61 
62  _model.reset(loadModelObject(resRef));
63  if (!_model)
64  throw Common::Exception("Can't load room model \"%s\"", resRef.c_str());
65 
66  _model->setPosition(x, y, z);
67 }
68 
69 void Room::unload() {
70  _model.reset();
71 
73 }
74 
75 void Room::show() {
76  if (_model)
77  _model->show();
78 }
79 
80 void Room::hide() {
81  if (_model)
82  _model->hide();
83 }
84 
85 } // End of namespace Jade
86 
87 } // End of namespace Engines
Generic Aurora engines resource utility functions.
A class holding an UTF-8 string.
Definition: ustring.h:48
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
bool indexOptionalArchive(const Common::UString &file, uint32 priority, const std::vector< byte > &password, Common::ChangeID *changeID)
Definition: resources.cpp:69
void deindexResources(Common::ChangeID &changeID)
Remove previously added resources from the ResourceManager.
Definition: resources.cpp:164
Common::ChangeID _resources
Definition: room.h:50
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
bool isWalkable() const
Definition: room.cpp:52
A 3D model of an object.
Room(const Common::UString &resRef, uint32 id, float x, float y, float z, bool walkable)
Definition: room.cpp:38
StackException Exception
Definition: error.h:59
void load(const Common::UString &resRef, uint32 id, float x, float y, float z)
Definition: room.cpp:56
A room within a Jade Empire area.
Common::ScopedPtr< Graphics::Aurora::Model > _model
Definition: room.h:54
uint32_t uint32
Definition: types.h:204
const Common::UString & getResRef() const
Definition: room.cpp:48
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
Definition: model.cpp:47
const Common::UString & _resRef
Definition: room.h:52
bool _walkable
Definition: room.h:56
Generic Aurora engines model functions.