Orxonox  0.0.5 Codename: Arcturus
Engine.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
29 #ifndef _Engine_H__
30 #define _Engine_H__
31 
32 #include "OrxonoxPrereqs.h"
33 
34 #include "util/OrxAssert.h"
35 
36 #include "Item.h"
37 
38 namespace orxonox
39 {
40 
55  class _OrxonoxExport Engine : public Item
56  {
57  public:
58  Engine(Context* context);
59  virtual ~Engine();
60 
61  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
62  void setConfigValues();
63 
64  virtual void run(float dt); // Run the engine for a given time interval.
65 
66  virtual void addToSpaceShip(SpaceShip* ship); // Adds the Engine to the input SpaceShip.
71  inline SpaceShip* getShip() const
72  { return this->ship_; }
73 
78  inline void setRelativePosition(const Vector3 &position)
79  { this->relativePosition_ = position; }
84  inline const Vector3& getRelativePosition() const
85  { return this->relativePosition_; }
86 
91  //TODO: Better OrxVerify()?
92  inline void setMaxSpeedFront(float speed)
93  { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedFront_ = speed; }
98  inline void setMaxSpeedBack(float speed)
99  { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedBack_ = speed; }
104  inline void setMaxSpeedLeftRight(float speed)
105  { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedLeftRight_ = speed; }
110  inline void setMaxSpeedUpDown(float speed)
111  { OrxAssert(speed >= 0.0f, "The input speed must be non-negative."); this->maxSpeedUpDown_ = speed; }
112 
117  inline float getMaxSpeedFront() const
118  { return this->maxSpeedFront_; }
123  inline float getMaxSpeedBack() const
124  { return this->maxSpeedBack_; }
129  inline float getMaxSpeedLeftRight() const
130  { return this->maxSpeedLeftRight_; }
135  inline float getMaxSpeedUpDown() const
136  { return this->maxSpeedUpDown_; }
137 
142  inline void setAccelerationFront(float acceleration)
143  { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationFront_ = acceleration; }
148  inline void setAccelerationBrake(float acceleration)
149  { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationBrake_ = acceleration; }
154  inline void setAccelerationBack(float acceleration)
155  { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationBack_ = acceleration; }
160  inline void setAccelerationLeftRight(float acceleration)
161  { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationLeftRight_ = acceleration; }
166  inline void setAccelerationUpDown(float acceleration)
167  { OrxAssert(acceleration >= 0.0f, "The input acceleration must be non-negative."); this->accelerationUpDown_ = acceleration; }
168 
173  inline float getAccelerationFront() const
174  { return this->accelerationFront_; }
179  inline float getAccelerationBrake() const
180  { return this->accelerationBrake_; }
185  inline float getAccelerationBack() const
186  { return this->accelerationBack_; }
191  inline float getAccelerationLeftRight() const
192  { return this->accelerationLeftRight_; }
197  inline float getAccelerationUpDown() const
198  { return this->accelerationUpDown_; }
199 
204  inline void setBoostFactor(float factor)
205  { OrxAssert(factor > 0.0f, "The input factor must be positive."); this->boostFactor_ = factor; }
210  inline float getBoostFactor() const
211  { return this->boostFactor_; }
212 
217  inline void addSpeedAdd(float speed)
218  { this->speedAdd_ += speed; }
223  inline void addSpeedMultiply(float factor)
224  { OrxAssert(factor >= 0.0f, "The factor must be non-negative."); this->speedMultiply_ *= factor; }
225 
230  inline float getSpeedAdd(void)
231  { return this->speedAdd_; }
236  inline float getSpeedMultiply(void)
237  { return this->speedMultiply_; }
238 
243  inline void setEngineTemplate(const std::string& temp)
244  { this->engineTemplate_ = temp; this->loadEngineTemplate(); }
249  inline const std::string& getEngineTemplate() const
250  { return this->engineTemplate_; }
251 
252  protected:
253  void loadEngineTemplate(); // Load the engine template.
254 
255  virtual const Vector3& getSteering() const; // Get the steering direction imposed upon the Engine.
256 
257  private:
258  void registerVariables();
259  void networkcallback_shipID();
260 
262 
264  unsigned int shipID_;
266 
267  float boostFactor_;
268 
269  float speedAdd_;
271 
276 
282 
283  };
284 }
285 
286 #endif /* _Engine_H__ */
void setAccelerationFront(float acceleration)
Set the forward acceleration produced by the Engine.
Definition: Engine.h:142
void setEngineTemplate(const std::string &temp)
Set the engine template, that specifies the parameters for the Engine.
Definition: Engine.h:243
void setAccelerationBrake(float acceleration)
Set the breaking acceleration produced by the Engine.
Definition: Engine.h:148
void setAccelerationLeftRight(float acceleration)
Set the left-right acceleration produced by the Engine.
Definition: Engine.h:160
float getAccelerationLeftRight() const
Get the left-right acceleration produced by the Engine.
Definition: Engine.h:191
void setAccelerationBack(float acceleration)
Set the backward acceleration produced by the Engine.
Definition: Engine.h:154
void setMaxSpeedFront(float speed)
Set the maximal forward speed of the Engine.
Definition: Engine.h:92
std::string engineTemplate_
The template that specifies the Engine&#39;s parameters.
Definition: Engine.h:261
float accelerationUpDown_
Up-down acceleration produced by the Engine.
Definition: Engine.h:281
::std::string string
Definition: gtest-port.h:756
const std::string & getEngineTemplate() const
Get the engine template, that specifies the parameters for the Engine.
Definition: Engine.h:249
float getBoostFactor() const
Get the boost factor of the Engine.
Definition: Engine.h:210
float getMaxSpeedFront() const
Get the maximal forward speed of the Engine.
Definition: Engine.h:117
void setMaxSpeedLeftRight(float speed)
Set the maximal left-right speed of the Engine.
Definition: Engine.h:104
float maxSpeedBack_
The maximal backward speed.
Definition: Engine.h:273
float accelerationBrake_
Breaking acceleration produced by the Engine.
Definition: Engine.h:278
float getMaxSpeedLeftRight() const
Get the maximal left-right speed of the Engine.
Definition: Engine.h:129
unsigned int shipID_
Object ID of the SpaceShip the Engine is mounted on.
Definition: Engine.h:264
void setAccelerationUpDown(float acceleration)
Set the up-down acceleration produced by the Engine.
Definition: Engine.h:166
float getMaxSpeedUpDown() const
Get the maximal up-down speed of the Engine.
Definition: Engine.h:135
void setRelativePosition(const Vector3 &position)
Set the relative position of the Engine.
Definition: Engine.h:78
SpaceShip * ship_
A pointer to the SpaceShip the Engine is mounted on.
Definition: Engine.h:263
float getSpeedMultiply(void)
Get the forward speed multiplication factor.
Definition: Engine.h:236
float accelerationFront_
Forward acceleration produced by the Engine.
Definition: Engine.h:277
float getAccelerationUpDown() const
Get the up-down acceleration produced by the Engine.
Definition: Engine.h:197
void setMaxSpeedUpDown(float speed)
Set the maximal up-down speed of the Engine.
Definition: Engine.h:110
float getSpeedAdd(void)
Get the additional forward speed.
Definition: Engine.h:230
#define OrxAssert(condition, errorMessage)
Run time assertion like assert(), but with an embedded message.
Definition: OrxAssert.h:54
Vector3 relativePosition_
The relative position of the Engine with respect to the SpaceShip it is mounted on.
Definition: Engine.h:265
xmlelement
Definition: Super.h:519
The SpaceShip is the principal entity through which the player interacts with the game...
Definition: SpaceShip.h:90
float maxSpeedFront_
The maximal forward speed.
Definition: Engine.h:272
void setBoostFactor(float factor)
Set the factor by which boosting increases the forward acceleration of the Engine.
Definition: Engine.h:204
const Vector3 & getRelativePosition() const
Get the relative position of the Engine.
Definition: Engine.h:84
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Definition: Item.h:39
Mode
Definition: CorePrereqs.h:102
float maxSpeedLeftRight_
The maximal left-right speed.
Definition: Engine.h:274
Shared library macros, enums, constants and forward declarations for the orxonox library ...
float speedMultiply_
Forward speed multiplication factor. Is not bounded by the maximal forward speed. ...
Definition: Engine.h:270
float accelerationLeftRight_
Left-right acceleration produced by the Engine.
Definition: Engine.h:280
Definition: Context.h:45
float getAccelerationBrake() const
Get the breaking acceleration produced by the Engine.
Definition: Engine.h:179
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
float getAccelerationFront() const
Get the forward acceleration produced by the Engine.
Definition: Engine.h:173
SpaceShip * getShip() const
Get the SpaceShip this Engine is mounted on.
Definition: Engine.h:71
float getAccelerationBack() const
Get the backward acceleration produced by the Engine.
Definition: Engine.h:185
float accelerationBack_
Backward acceleration produced by the Engine.
Definition: Engine.h:279
The Engine class provides propulsion to the SpaceShip.
Definition: Engine.h:55
float maxSpeedUpDown_
The maximal up-down speed.
Definition: Engine.h:275
void addSpeedAdd(float speed)
Add to the additional forward speed factor.
Definition: Engine.h:217
void addSpeedMultiply(float factor)
Add to the forward speed multiplication factor.
Definition: Engine.h:223
float boostFactor_
The factor by which boosting increases the forward acceleration.
Definition: Engine.h:267
void setMaxSpeedBack(float speed)
Set the maximal backward speed of the Engine.
Definition: Engine.h:98
float getMaxSpeedBack() const
Get the maximal backward speed of the Engine.
Definition: Engine.h:123
float speedAdd_
Additional forward speed. Is not bounded by the maximal forward speed.
Definition: Engine.h:269
Declaration of custom assertion facilities