| 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 | *      Oli Scheuss | 
|---|
| 24 | *   Co-authors: | 
|---|
| 25 | *      ... | 
|---|
| 26 | * | 
|---|
| 27 | */ | 
|---|
| 28 |  | 
|---|
| 29 | #ifndef _Drone_H__ | 
|---|
| 30 | #define _Drone_H__ | 
|---|
| 31 |  | 
|---|
| 32 | #include "OrxonoxPrereqs.h" | 
|---|
| 33 | #include "worldentities/pawns/Pawn.h" | 
|---|
| 34 | #include "controllers/DroneController.h" | 
|---|
| 35 |  | 
|---|
| 36 | namespace orxonox | 
|---|
| 37 | { | 
|---|
| 38 |  | 
|---|
| 39 | /** | 
|---|
| 40 | @brief | 
|---|
| 41 | Drone, that is made to move upon a specified pattern. | 
|---|
| 42 | This class was constructed for the PPS tutorial. | 
|---|
| 43 | @author | 
|---|
| 44 | Oli Scheuss | 
|---|
| 45 | */ | 
|---|
| 46 | class _OrxonoxExport Drone : public Pawn | 
|---|
| 47 | { | 
|---|
| 48 | public: | 
|---|
| 49 | Drone(Context* context); | 
|---|
| 50 | virtual ~Drone(); | 
|---|
| 51 |  | 
|---|
| 52 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Drone through XML. | 
|---|
| 53 | virtual void tick(float dt); //!< Defines which actions the Drone has to take in each tick. | 
|---|
| 54 |  | 
|---|
| 55 |  | 
|---|
| 56 | virtual void moveFrontBack(const Vector2& value); | 
|---|
| 57 | virtual void moveRightLeft(const Vector2& value); | 
|---|
| 58 | virtual void moveUpDown(const Vector2& value); | 
|---|
| 59 |  | 
|---|
| 60 | virtual void rotateYaw(const Vector2& value); | 
|---|
| 61 | virtual void rotatePitch(const Vector2& value); | 
|---|
| 62 | virtual void rotateRoll(const Vector2& value); | 
|---|
| 63 |  | 
|---|
| 64 | /** | 
|---|
| 65 | @brief Moves the Drone in the Front/Back-direction by the specifed amount. | 
|---|
| 66 | @param value  The amount by which the drone is to be moved. | 
|---|
| 67 | */ | 
|---|
| 68 | inline void moveFrontBack(float value) | 
|---|
| 69 | { this->moveFrontBack(Vector2(value, 0)); } | 
|---|
| 70 | /** | 
|---|
| 71 | @brief Moves the Drone in the Right/Left-direction by the specifed amount. | 
|---|
| 72 | @param value  The amount by which the drone is to be moved. | 
|---|
| 73 | */ | 
|---|
| 74 | inline void moveRightLeft(float value) | 
|---|
| 75 | { this->moveRightLeft(Vector2(value, 0)); } | 
|---|
| 76 | /** | 
|---|
| 77 | @brief Moves the Drone in the Up/Down-direction by the specifed amount. | 
|---|
| 78 | @param value  The amount by which the drone is to be moved. | 
|---|
| 79 | */ | 
|---|
| 80 | inline void moveUpDown(float value) | 
|---|
| 81 | { this->moveUpDown(Vector2(value, 0)); } | 
|---|
| 82 |  | 
|---|
| 83 | /** | 
|---|
| 84 | @brief Rotates the Drone around the y-axis by the specifed amount. | 
|---|
| 85 | @param value  The amount by which the drone is to be rotated. | 
|---|
| 86 | */ | 
|---|
| 87 | inline void rotateYaw(float value) | 
|---|
| 88 | { this->rotateYaw(Vector2(value, 0)); } | 
|---|
| 89 | /** | 
|---|
| 90 | @brief Rotates the Drone around the x-axis by the specifed amount. | 
|---|
| 91 | @param value  The amount by which the drone is to be rotated. | 
|---|
| 92 | */ | 
|---|
| 93 | inline void rotatePitch(float value) | 
|---|
| 94 | { this->rotatePitch(Vector2(value, 0)); } | 
|---|
| 95 | /** | 
|---|
| 96 | @brief Rotates the Drone around the z-axis by the specifed amount. | 
|---|
| 97 | @param value  The amount by which the drone is to be rotated. | 
|---|
| 98 | */ | 
|---|
| 99 | inline void rotateRoll(float value) | 
|---|
| 100 | { this->rotateRoll(Vector2(value, 0)); } | 
|---|
| 101 |  | 
|---|
| 102 | /** | 
|---|
| 103 | @brief Sets the primary thrust to the input amount. | 
|---|
| 104 | @param thrust The amount of thrust. | 
|---|
| 105 | */ | 
|---|
| 106 | inline void setPrimaryThrust( float thrust ) | 
|---|
| 107 | { this->primaryThrust_=thrust; } | 
|---|
| 108 | inline void setAuxilaryThrust( float thrust ) | 
|---|
| 109 | { this->auxilaryThrust_=thrust; } | 
|---|
| 110 | inline void setRotationThrust( float thrust ) | 
|---|
| 111 | { this->rotationThrust_=thrust; } | 
|---|
| 112 | inline void setMaxDistanceToOwner( float distance) | 
|---|
| 113 | { this->maxDistanceToOwner_=distance; } | 
|---|
| 114 | inline void setMinDistanceToOwner( float distance) | 
|---|
| 115 | { this->minDistanceToOwner_=distance; } | 
|---|
| 116 | inline void setMaxShootingRange( float distance) | 
|---|
| 117 | { this->maxShootingRange_=distance; } | 
|---|
| 118 |  | 
|---|
| 119 |  | 
|---|
| 120 | /** | 
|---|
| 121 | @brief Gets the primary thrust to the input amount. | 
|---|
| 122 | @return The amount of thrust. | 
|---|
| 123 | */ | 
|---|
| 124 | inline float getPrimaryThrust() | 
|---|
| 125 | { return this->primaryThrust_; } | 
|---|
| 126 | inline float getAuxilaryThrust() | 
|---|
| 127 | { return this->auxilaryThrust_; } | 
|---|
| 128 | inline float getRotationThrust() | 
|---|
| 129 | { return this->rotationThrust_; } | 
|---|
| 130 | inline float getMaxDistanceToOwner() | 
|---|
| 131 | { return this->maxDistanceToOwner_; } | 
|---|
| 132 | inline float getMinDistanceToOwner() | 
|---|
| 133 | { return this->minDistanceToOwner_; } | 
|---|
| 134 | inline float getMaxShootingRange() | 
|---|
| 135 | { return this->maxShootingRange_; } | 
|---|
| 136 |  | 
|---|
| 137 | private: | 
|---|
| 138 | DroneController *myController_; //!< The controller of the Drone. | 
|---|
| 139 |  | 
|---|
| 140 | btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Drone the next tick. | 
|---|
| 141 | btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Drone the next tick. | 
|---|
| 142 | float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward. | 
|---|
| 143 | float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations). | 
|---|
| 144 | float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only. | 
|---|
| 145 | float maxDistanceToOwner_; //Maximum Distance to owner | 
|---|
| 146 | float minDistanceToOwner_; //Minimum Distance to owner | 
|---|
| 147 | float maxShootingRange_; | 
|---|
| 148 | }; | 
|---|
| 149 |  | 
|---|
| 150 | } | 
|---|
| 151 |  | 
|---|
| 152 | #endif /* _Drone_H__ */ | 
|---|