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