xoreos  0.0.5
situated.h
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 #ifndef ENGINES_KOTOR2_SITUATED_H
26 #define ENGINES_KOTOR2_SITUATED_H
27 
28 #include "glm/vec3.hpp"
29 
30 #include "src/common/scopedptr.h"
31 
32 #include "src/aurora/types.h"
33 
35 
37 
39 
40 namespace Engines {
41 
42 namespace KotOR2 {
43 
44 class Situated : public Object {
45 public:
46  ~Situated();
47 
48  // Basic visuals
49 
50  void show();
51  void hide();
52  bool isVisible() const;
53 
54  // Basic properties
55 
57  virtual bool isOpen() const = 0;
58 
59  bool isLocked() const;
60  virtual void setLocked(bool locked);
61 
63  Object *getLastOpenedBy() const;
65  Object *getLastClosedBy() const;
67  Object *getLastUsedBy () const;
68 
69  // Positioning
70 
72  void setPosition(float x, float y, float z);
74  void setOrientation(float x, float y, float z, float angle);
75 
76  // Walkmesh
77 
78  virtual bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const;
79  void setWalkmeshInvisible(bool invisible);
80 
81  void playAnimation(const Common::UString &anim,
82  bool restart = true,
83  float length = 0.0f,
84  float speed = 1.0f);
85 
86 protected:
88 
91 
92  bool _locked;
93 
99 
103 
105 
107 
108 
109  Situated(ObjectType type);
110 
112  void load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint = 0);
113 
115  virtual void loadObject(const Aurora::GFF3Struct &gff) = 0;
117  virtual void loadAppearance() = 0;
118 
119 
120 private:
121  void loadProperties(const Aurora::GFF3Struct &gff);
122  void loadPortrait(const Aurora::GFF3Struct &gff);
123  void loadSounds();
124 };
125 
126 } // End of namespace KotOR2
127 
128 } // End of namespace Engines
129 
130 #endif // ENGINES_KOTOR2_SITUATED_H
Object * getLastOpenedBy() const
Return the object that last opened this situated object.
Definition: situated.cpp:105
A class holding an UTF-8 string.
Definition: ustring.h:48
Object * getLastUsedBy() const
Return the object that last used this situated object.
Definition: situated.cpp:113
void loadProperties(const Aurora::GFF3Struct &gff)
Definition: situated.cpp:173
virtual void loadObject(const Aurora::GFF3Struct &gff)=0
Load object-specific properties.
Common::UString _soundClosed
The sound the object makes when closed.
Definition: situated.h:95
void setPosition(float x, float y, float z)
Set the situated object&#39;s position.
Definition: situated.cpp:68
void show()
Show the situated object&#39;s model.
Definition: situated.cpp:52
Common::UString _soundUsed
The sound the object makes when used.
Definition: situated.h:97
uint32 _appearanceID
The index within the situated appearance 2DA.
Definition: situated.h:89
Object * _lastOpenedBy
The object that last opened this situated object.
Definition: situated.h:100
void loadPortrait(const Aurora::GFF3Struct &gff)
Definition: situated.cpp:202
A simple scoped smart pointer template.
Object * _lastUsedBy
The object that last used this situated object.
Definition: situated.h:102
Common::UString _soundLocked
The sound the object makes when locked.
Definition: situated.h:98
An object in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
Basic Aurora graphics types.
Common::ScopedPtr< Graphics::Aurora::Model > _model
The situated object&#39;s model.
Definition: situated.h:104
Situated(ObjectType type)
Definition: situated.cpp:43
bool _locked
Is the situated object locked?
Definition: situated.h:92
bool isLocked() const
Is the situated object locked?
Definition: situated.cpp:97
uint32 _soundAppType
The index within the situated sounds 2DA.
Definition: situated.h:90
void hide()
Hide the situated object&#39;s model.
Definition: situated.cpp:58
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
Engines::KotOR::Walkmesh _walkmesh
Definition: situated.h:106
void load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint=0)
Load the situated object from an instance and its blueprint.
Definition: situated.cpp:117
void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: situated.cpp:92
virtual bool isOpen() const =0
Is the situated object open?
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:33
virtual void loadAppearance()=0
Load appearance-specific properties.
Common::UString _soundDestroyed
The sound the object makes when destroyed.
Definition: situated.h:96
A struct within a GFF3.
Definition: gff3file.h:164
KotOR walkmesh (BWM).
uint32_t uint32
Definition: types.h:204
void setWalkmeshInvisible(bool invisible)
Definition: situated.cpp:88
Common::UString _soundOpened
The sound the object makes when opened.
Definition: situated.h:94
virtual void setLocked(bool locked)
Lock/Unlock the situated object.
Definition: situated.cpp:101
Object * _lastClosedBy
The object that last closed this situated object.
Definition: situated.h:101
void setOrientation(float x, float y, float z, float angle)
Set the situated object&#39;s orientation.
Definition: situated.cpp:76
Common::UString _modelName
The model&#39;s resource name.
Definition: situated.h:87
bool isVisible() const
Is the situated object&#39;s model visible?
Definition: situated.cpp:64
Object * getLastClosedBy() const
Return the object that last closed this situated object.
Definition: situated.cpp:109
virtual bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const
Definition: situated.cpp:84