Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/wiimote/src/orxonox/controllers/AutonomousDroneController.cc @ 9917

Last change on this file since 9917 was 9711, checked in by georgr, 11 years ago

Mouse remote controlled from AutonomousDroneController. More info on console

File size: 3.5 KB
RevLine 
[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#include "AutonomousDroneController.h"
30#include "worldentities/AutonomousDrone.h"
31#include "util/Math.h"
32#include <core/input/InputManager.h>
33#include <core/input/InputHandler.h>
34#include <core/input/InputState.h>
35
36namespace orxonox
37{
38
39    /**
40    @brief
41        Constructor.
42    @param context
43        The context of this object.
44    */
45        RegisterClass(AutonomousDroneController);
46
47        float time=0;
48    AutonomousDroneController::AutonomousDroneController(Context* context) : Controller(context)
49    {
50        //TODO: Place your code here:
51        // Make sure to register the object and create the factory.
52        RegisterObject(AutonomousDroneController);
53        // This checks that our context really is a drone
54        // and saves the pointer to the drone for the controlling commands
55        /* NOTE from Sandro: This is currently broken */
56        //AutonomousDrone* drone = dynamic_cast<AutonomousDrone*>(context);
57        //assert(drone != NULL);
58        //this->setControllableEntity(drone);
59    }
60
61    /**
62    @brief
63        Destructor.
64    */
65    AutonomousDroneController::~AutonomousDroneController()
66    {
67
68    }
69
70    /**
71    @brief
72        The controlling happens here. This method defines what the controller has to do each tick.
73    @param dt
74        The duration of the tick.
75    */
76    void AutonomousDroneController::tick(float dt)
77    {
78        /* NOTE: Ugly hack by Sandro to make the tutorial work for the moment.
79         * This will be reverted once the framework update is complete
80         */
81        //AutonomousDrone *myDrone = static_cast<AutonomousDrone*>(this->getControllableEntity());
82        ObjectList<AutonomousDrone>::iterator it = ObjectList<AutonomousDrone>::begin();
83
84        //TODO: Place your code here:
85        // Steering commands
86        // You can use the commands provided by the AutonomousDrone to steer it:
87        // - moveFrontBack, moveRightLeft, moveUpDown
88        // - rotatePitch, rotateYaw, rotateRoll
89        // You will see, that the AutonomousDrone has two variants for each of these commands, one with a vector as input and one with just a float. Use the one with just the float as input.
90        // Apply them to myDrone (e.g. myDrone->rotateYaw(..) )
91        time+=dt;
92        it->moveUpDown(sin(time*5)*600*dt);
93        it->rotateYaw(300*dt);
94        it->setPrimaryThrust(150);
95        it->moveFrontBack(1200*dt);
96                IntVector2 abs(10,50);
97                IntVector2 rel(50, 20);
98                IntVector2 clippingSize(1680, 1050);
99                InputManager * myIM = &(InputManager::getInstance());
100                InputState * gameState = myIM->getState("game");
101                gameState->mouseMoved(abs, rel, clippingSize);
102                orxout()<<"I'm a huge faggot";
103    }
104
105
106
107}
Note: See TracBrowser for help on using the repository browser.