Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h @ 12234

Last change on this file since 12234 was 12028, checked in by merholzl, 6 years ago

added scriptable controller

File size: 7.6 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 *      Oli Scheuss
24 *   Co-authors:
25 *      Damian 'Mozork' Frick
26 *
27 */
28
29#ifndef _ScriptableControllerDrone_H__
30#define _ScriptableControllerDrone_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "core/XMLPort.h"
35//#include "controllers/AutonomousDroneController.h"
36
37#include "Pawn.h"
38
39namespace 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 ScriptableControllerDrone : public Pawn
49    {
50        public:
51            ScriptableControllerDrone(Context* context);
52            virtual ~ScriptableControllerDrone();
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
70
71            inline void moveFrontBack(float value)
72            { this->moveFrontBack(Vector2(value, 0)); }
73            /**
74            @brief Moves the Drone in the Right/Left-direction by the specifed amount.
75            @param value  The amount by which the drone is to be moved.
76            */
77            inline void moveRightLeft(float value)
78            { this->moveRightLeft(Vector2(value, 0)); }
79            /**
80            @brief Moves the Drone in the Up/Down-direction by the specifed amount.
81            @param value  The amount by which the drone is to be moved.
82            */
83            inline void moveUpDown(float value)
84            { this->moveUpDown(Vector2(value, 0)); }
85
86            /**
87            @brief Rotates the Drone around the y-axis by the specifed amount.
88            @param value  The amount by which the drone is to be rotated.
89            */
90            inline void rotateYaw(float value)
91            { this->rotateYaw(Vector2(value, 0)); }
92            /**
93            @brief Rotates the Drone around the x-axis by the specifed amount.
94            @param value  The amount by which the drone is to be rotated.
95            */
96            inline void rotatePitch(float value)
97            { this->rotatePitch(Vector2(value, 0)); }
98            /**
99            @brief Rotates the Drone around the z-axis by the specifed amount.
100            @param value  The amount by which the drone is to be rotated.
101            */
102            inline void rotateRoll(float value)
103            { this->rotateRoll(Vector2(value, 0)); }
104
105            /**
106            @brief Sets the primary thrust to the input amount.
107            @param thrust The amount of thrust.
108            */
109            inline void setPrimaryThrust( float thrust )
110                { this->primaryThrust_ = thrust; }
111            //TODO: Place your set-functions here.
112            // Hint: auxiliary thrust, rotation thrust.
113
114
115             /**
116            @brief Sets the auxiliary thrust to the input amount.
117            @param thrust The amount of thrust.
118            */
119            inline void setAuxiliaryThrust( float thrust )
120                { this->auxiliaryThrust_ = thrust; }
121
122             /**
123            @brief Sets the rotation thrust to the input amount.
124            @param thrust The amount of thrust.
125            */
126            inline void setRotationThrust( float thrust )
127                { this->rotationThrust_ = thrust; }
128
129             /**
130            @brief Sets the rotation thrust to the input amount.
131            @param thrust The amount of thrust.
132            */
133            inline void setMass( float mass )
134                { this->mass_ = mass; }
135
136             /**
137            @brief Sets the rotation thrust to the input amount.
138            @param thrust The amount of thrust.
139            */
140            inline void setLinearDamping( float damping )
141                { this->linearDamping_ = damping; }
142
143             /**
144            @brief Sets the rotation thrust to the input amount.
145            @param thrust The amount of thrust.
146            */
147            inline void setAngularDamping( float damping )
148                { this->angularDamping_ = damping; }
149           
150           
151           
152            /**
153            @brief Gets the primary thrust to the input amount.
154            @return The amount of thrust.
155            */
156            inline float getPrimaryThrust()
157                { return this->primaryThrust_; }
158            //TODO: Place your get-functions here.
159
160            /**
161            @brief Gets the primary thrust to the input amount.
162            @return The amount of thrust.
163            */
164            inline float getAuxiliaryThrust()
165                { return this->auxiliaryThrust_; }
166
167             /**
168            @brief Gets the primary thrust to the input amount.
169            @return The amount of thrust.
170            */
171            inline float getRotationThrust()
172                { return this->rotationThrust_; }
173
174             /**
175            @brief Gets the primary thrust to the input amount.
176            @return The amount of thrust.
177            */
178            inline float getMass()
179                { return this->mass_; }
180
181             /**
182            @brief Gets the primary thrust to the input amount.
183            @return The amount of thrust.
184            */
185            inline float getLinearDamping()
186                { return this->linearDamping_; }
187
188             /**
189            @brief Gets the primary thrust to the input amount.
190            @return The amount of thrust.
191            */
192            inline float getAngularDamping()
193                { return this->angularDamping_; }
194
195           
196
197        private:
198            //AutonomousDroneController *myController_; //!< The controller of the AutonomousDrone.
199
200            btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the AutonomousDrone the next tick.
201            btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the AutonomousDrone the next tick.
202            float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
203            float auxiliaryThrust_; //!< The amount of auxiliary thrust. Used for all other movements (except for rotations).
204            float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.s
205            float mass_;
206            float linearDamping_;
207            float angularDamping_;
208    };
209
210}
211
212#endif // _AutonomousDrone_H__
Note: See TracBrowser for help on using the repository browser.