Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12380 was 11099, checked in by muemart, 9 years ago

Fix loads of doxygen warnings and other documentation issues

  • Property svn:eol-style set to native
File size: 5.8 KB
Line 
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
29/**
30    @file Turret.h
31    @brief Definition of the Turret class.
32    @ingroup Objects
33*/
34
35#ifndef _Turret_H__
36#define _Turret_H__
37
38#include "objects/ObjectsPrereqs.h"
39#include "worldentities/pawns/Pawn.h"
40#include <OgreSceneQuery.h>
41
42namespace orxonox
43{
44    /**
45    @brief
46        Creates a turret with limited rotation. The point of this class is to be able to attach
47        a turret to a spaceship or a spacestation which is more or less completely autonomous in
48        it's behaviour.
49
50        This class also contains a custom local coordinate system, which gets initially rotated through xml, and
51        afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation
52        of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...)
53       
54
55    @note
56        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
57    */
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
73            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
74            inline void setMaxAttackRadius(float radius)
75                { this->maxAttackRadius_ = radius; }
76
77            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
78            inline void setMinAttackRadius(float radius)
79                { this->minAttackRadius_ = radius; }
80
81            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
82            inline void setMaxPitch(float pitch)
83                { this->maxPitch_ = pitch; }
84
85            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
86            inline void setMaxYaw(float yaw)
87                { this->maxYaw_ = yaw; }
88
89            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
90            inline float getMaxAttackRadius() const
91                { return this->maxAttackRadius_; }               
92
93            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
94            inline float getMinAttackRadius() const
95                { return this->minAttackRadius_; }   
96
97            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
98            inline float getMaxPitch() const
99                { return this->maxPitch_; }
100
101            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
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_; //!< The initial facing direction, in local coordinates.
113            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
114            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
115            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.     
116            Quaternion rotation_; //!< The rotation to be done by the turret.
117
118        private:
119            bool once_; //!< Flag for executing code in the tick function only once.
120
121            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
122            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
123            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
124            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
125            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
126            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
127            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
128            float rotationThrust_;  //!< The velocity the turret rotates with.
129            Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange
130
131    };
132}
133
134#endif
Note: See TracBrowser for help on using the repository browser.