xoreos  0.0.5
trigger.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/aurora/resman.h"
26 #include "src/aurora/gff3file.h"
27 
29 
31 
32 namespace Engines {
33 
34 namespace KotOR {
35 
37  : ::Engines::Trigger(),
39  load(gff);
40  prepare();
41 }
42 
43 void Trigger::show() {
44  Renderable::show();
45 }
46 
47 void Trigger::hide() {
48  Renderable::hide();
49 }
50 
52 }
53 
54 bool Trigger::isVisible() const {
55  return Renderable::isVisible();
56 }
57 
59  Common::UString temp = gff.getString("TemplateResRef");
60 
62  if (!temp.empty())
63  utt.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTT, MKTAG('U', 'T', 'T', ' ')));
64 
65  loadBlueprint(utt->getTopLevel());
66 
67  if (!utt)
68  warning("Trigger \"%s\" has no blueprint", temp.c_str());
69 
70  float x, y, z;
71  x = (float)gff.getDouble("XPosition");
72  y = (float)gff.getDouble("YPosition");
73  z = (float)gff.getDouble("ZPosition");
74  glm::vec3 position(x, y, z);
75  setPosition(x, y, z);
76 
77  x = (float)gff.getDouble("XOrientation");
78  y = (float)gff.getDouble("YOrientation");
79  z = (float)gff.getDouble("ZOrientation");
80  glm::vec3 orientation(x, y, z);
81 
82  const Aurora::GFF3List &geometry = gff.getList("Geometry");
83  for (Aurora::GFF3List::const_iterator p = geometry.begin();
84  p != geometry.end();
85  ++p) {
86  x = (float)(*p)->getDouble("PointX");
87  y = (float)(*p)->getDouble("PointY");
88  z = (float)(*p)->getDouble("PointZ");
89  _geometry.push_back(position + glm::vec3(x, y, z));
90  }
91 }
92 
94  Object::_tag = gff.getString("Tag");
95 
96  _name = gff.getString("LocalizedName");
97 
98  readScripts(gff);
99 }
100 
101 } // End of namespace KotOR
102 
103 } // End of namespace Engines
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
void hide()
Hide the object&#39;s model(s).
Definition: trigger.cpp:47
void hideSoft()
Hide the object&#39;s model(s) if applicable.
Definition: trigger.cpp:51
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
Trigger template (user), GFF.
Definition: types.h:97
Aurora::GFF3File * loadOptionalGFF3(const Common::UString &gff3, Aurora::FileType type, uint32 id, bool repairNWNPremium)
Load a GFF3, but return 0 instead of throwing on error.
Definition: util.cpp:150
void show()
Show the object&#39;s model(s).
Definition: trigger.cpp:43
bool isVisible() const
Is the object&#39;s model(s) visible?
Definition: trigger.cpp:54
Trigger in a Star Wars: Knights of the Old Republic area.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
Common::UString _name
The object&#39;s display name.
Definition: object.h:142
double getDouble(const Common::UString &field, double def=0.0) const
Definition: gff3file.cpp:514
void load(const Aurora::GFF3Struct &gff)
Definition: trigger.cpp:58
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
void warning(const char *s,...)
Definition: util.cpp:33
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:152
A struct within a GFF3.
Definition: gff3file.h:164
Common::UString _tag
Definition: object.h:56
std::vector< glm::vec3 > _geometry
Definition: trigger.h:50
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
Generic Aurora engines utility functions.
void readScripts(const Aurora::GFF3Struct &gff, bool clear=true)
Definition: container.cpp:134
The global resource manager for Aurora resources.
void loadBlueprint(const Aurora::GFF3Struct &gff)
Definition: trigger.cpp:93