Orxonox  0.0.5 Codename: Arcturus
Turret.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  * Marian Runo, Martin Mueller
24  * Co-authors:
25  * ...
26  *
27  */
28 
35 #ifndef _Turret_H__
36 #define _Turret_H__
37 
38 #include "objects/ObjectsPrereqs.h"
40 #include <OgreSceneQuery.h>
41 
42 namespace orxonox
43 {
58  class _ObjectsExport Turret : public Pawn
59  {
60  public:
61  Turret(Context* context);
62  virtual ~Turret();
63 
64  virtual void rotatePitch(const Vector2& value) override;
65  virtual void rotateYaw(const Vector2& value) override;
66  virtual void rotateRoll(const Vector2& value) override;
67  virtual float isInRange(const WorldEntity* target);
68  virtual void aimAtPosition(const Vector3 &position);
69 
70  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
71  virtual void tick(float dt) override;
72 
74  inline void setMaxAttackRadius(float radius)
75  { this->maxAttackRadius_ = radius; }
76 
78  inline void setMinAttackRadius(float radius)
79  { this->minAttackRadius_ = radius; }
80 
82  inline void setMaxPitch(float pitch)
83  { this->maxPitch_ = pitch; }
84 
86  inline void setMaxYaw(float yaw)
87  { this->maxYaw_ = yaw; }
88 
90  inline float getMaxAttackRadius() const
91  { return this->maxAttackRadius_; }
92 
94  inline float getMinAttackRadius() const
95  { return this->minAttackRadius_; }
96 
98  inline float getMaxPitch() const
99  { return this->maxPitch_; }
100 
102  inline float getMaxYaw() const
103  { return this->maxYaw_; }
104 
105  inline void setRotationThrust(float rotationthrust)
106  { this->rotationThrust_ = rotationthrust; }
107 
108  inline float getRotationThrust()
109  { return this->rotationThrust_; }
110 
111  protected:
112  Vector3 startDir_;
113  Vector3 localZ_;
114  Vector3 localY_;
115  Vector3 localX_;
116  Quaternion rotation_;
117 
118  private:
119  bool once_;
120 
121  Vector3 localZStart_;
122  Vector3 localYStart_;
123  Vector3 localXStart_;
126  Ogre::Real maxPitch_;
127  Ogre::Real maxYaw_;
129  Ogre::RaySceneQuery* rayTest_;
130 
131  };
132 }
133 
134 #endif
#define _ObjectsExport
Definition: ObjectsPrereqs.h:60
bool once_
Flag for executing code in the tick function only once.
Definition: Turret.h:119
float getMaxAttackRadius() const
Returns the maximum distance the turret is allowed to shoot.
Definition: Turret.h:90
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
Ogre::Real maxYaw_
The maxmium yaw the turret can have (on one side).
Definition: Turret.h:127
float getRotationThrust()
Definition: Turret.h:108
Vector3 localZ_
The local z-axis, includes for the parent&#39;s rotation and rotations done in xml.
Definition: Turret.h:113
void setMaxPitch(float pitch)
Sets the maximum pitch the turret can have (in both directions).
Definition: Turret.h:82
float rotationThrust_
The velocity the turret rotates with.
Definition: Turret.h:128
Ogre::Real maxPitch_
The maxmium pitch the turret can have (on one side).
Definition: Turret.h:126
Vector3 startDir_
The initial facing direction, in local coordinates.
Definition: Turret.h:112
The WorldEntity represents everything that can be put in a Scene at a certain location.
Definition: WorldEntity.h:72
void setRotationThrust(float rotationthrust)
Definition: Turret.h:105
xmlelement
Definition: Super.h:519
Quaternion rotation_
The rotation to be done by the turret.
Definition: Turret.h:116
Ogre::RaySceneQuery * rayTest_
Used to perform a raytest, currently unused.
Definition: Turret.h:129
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
void setMaxAttackRadius(float radius)
Sets the maximum distance the turret is allowed to shoot.
Definition: Turret.h:74
float getMaxPitch() const
Returns the maximum pitch the turret can have.
Definition: Turret.h:98
Mode
Definition: CorePrereqs.h:102
void setMinAttackRadius(float radius)
Sets the minimum distance the turret is allowed to shoot.
Definition: Turret.h:78
Definition: Context.h:45
Creates a turret with limited rotation.
Definition: Turret.h:58
Vector3 localXStart_
The local x-axis, without the parent&#39;s rotation.
Definition: Turret.h:123
Vector3 localZStart_
The local z-axis, without the parent&#39;s rotation.
Definition: Turret.h:121
Shared library macros, enums, constants and forward declarations for the objects module ...
float getMinAttackRadius() const
Returns the minimum distance the turret is allowed to shoot.
Definition: Turret.h:94
void setMaxYaw(float yaw)
Sets the maximum yaw the turret can have (in both directions).
Definition: Turret.h:86
float maxAttackRadius_
The maximum distance the turret is allowed to shoot.
Definition: Turret.h:124
Vector3 localX_
The local x-axis, includes for the parent&#39;s rotation and rotations done in xml.
Definition: Turret.h:115
float getMaxYaw() const
Returns the maximum yaw the turret can have.
Definition: Turret.h:102
Vector3 localYStart_
The local y-axis, without the parent&#39;s rotation.
Definition: Turret.h:122
Vector3 localY_
The local y-axis, includes for the parent&#39;s rotation and rotations done in xml.
Definition: Turret.h:114
float minAttackRadius_
The minimum distance the turret is allowed to shoot.
Definition: Turret.h:125