Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/objects/Turret.h @ 10867

Last change on this file since 10867 was 10622, checked in by landauf, 9 years ago

merged branch presentationFS15merge back to trunk

  • Property svn:eol-style set to native
File size: 5.8 KB
RevLine 
[9460]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:
[10216]23 *      Marian Runo, Martin Mueller
[9460]24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @brief Definition of the Turret class.
31    @ingroup Objects
32*/
33
34#ifndef _Turret_H__
35#define _Turret_H__
36
37#include "objects/ObjectsPrereqs.h"
[10216]38#include "worldentities/pawns/Pawn.h"
39#include <OgreSceneQuery.h>
[9460]40
41namespace orxonox
42{
[10216]43    /**
44    @brief
45        Creates a turret with limited rotation. The point of this class is to be able to attach
46        a turret to a spaceship or a spacestation which is more or less completely autonomous in
47        it's behaviour.
48
49        This class also contains a custom local coordinate system, which gets initially rotated through xml, and
50        afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation
51        of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...)
52       
53
54    @note
55        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
56    */
57    class _ObjectsExport Turret : public Pawn
[9460]58    {
59        public:
[9667]60            Turret(Context* context);
[9460]61            virtual ~Turret();
62
63            virtual void rotatePitch(const Vector2& value);
[10216]64            virtual void rotateYaw(const Vector2& value);
65            virtual void rotateRoll(const Vector2& value);
66            virtual float isInRange(const WorldEntity* target);
67            virtual void aimAtPosition(const Vector3 &position);
[9460]68
[9469]69            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[10216]70            virtual void tick(float dt);
[9460]71
[10216]72            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
73            inline void setMaxAttackRadius(float radius)
74                { this->maxAttackRadius_ = radius; }
[9460]75
[10216]76            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
77            inline void setMinAttackRadius(float radius)
78                { this->minAttackRadius_ = radius; }
79
80            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
81            inline void setMaxPitch(float pitch)
82                { this->maxPitch_ = pitch; }
83
84            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
85            inline void setMaxYaw(float yaw)
86                { this->maxYaw_ = yaw; }
87
88            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
89            inline float getMaxAttackRadius() const
90                { return this->maxAttackRadius_; }               
91
92            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
93            inline float getMinAttackRadius() const
94                { return this->minAttackRadius_; }   
95
96            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
97            inline float getMaxPitch() const
98                { return this->maxPitch_; }
99
100            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
101            inline float getMaxYaw() const
102                { return this->maxYaw_; }
103
[10622]104            inline void setRotationThrust(float rotationthrust)
105                { this->rotationThrust_ = rotationthrust; }
106
107            inline float getRotationThrust()
108                { return this->rotationThrust_; }
109
[9460]110        protected:
[10216]111            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
112            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
113            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
114            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.     
115            Quaternion rotation_; //!< The rotation to be done by the turret.
116
[9460]117        private:
[10216]118            bool once_; //!< Flag for executing code in the tick function only once.
[9460]119
[10216]120            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
121            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
122            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
123            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
124            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
125            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
126            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
127            float rotationThrust_;  //!< The velocity the turret rotates with.
128            Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange
129
[9460]130    };
131}
132
133#endif
Note: See TracBrowser for help on using the repository browser.