[Orxonox-commit 3388] r8075 - code/branches/tutorial/src/orxonox/controllers

jonas at orxonox.net jonas at orxonox.net
Mon Mar 14 16:56:52 CET 2011


Author: jonas
Date: 2011-03-14 16:56:51 +0100 (Mon, 14 Mar 2011)
New Revision: 8075

Added:
   code/branches/tutorial/src/orxonox/controllers/AutonomousDroneController_jonas.cc
Log:
My steering fct

Copied: code/branches/tutorial/src/orxonox/controllers/AutonomousDroneController_jonas.cc (from rev 8074, code/branches/tutorial/src/orxonox/controllers/AutonomousDroneController.cc)
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/AutonomousDroneController_jonas.cc	                        (rev 0)
+++ code/branches/tutorial/src/orxonox/controllers/AutonomousDroneController_jonas.cc	2011-03-14 15:56:51 UTC (rev 8075)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oli Scheuss
+ *   Co-authors:
+ *      Damian 'Mozork' Frick
+ *
+ */
+
+#include "AutonomousDroneController.h"
+
+#include "worldentities/AutonomousDrone.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        Constructor.
+    @param creator
+        The creator of this object.
+    */
+    AutonomousDroneController::AutonomousDroneController(BaseObject* creator) : Controller(creator)
+    {
+        //TODO: Place your code here:
+        // Make sure to register the object in the factory.
+        // Do some kind of initialisation.
+RegisterObject(AutonomousDroneController);
+
+
+        // This checks that our creator really is a drone
+        // and saves the pointer to the drone for the controlling commands
+        AutonomousDrone* drone = dynamic_cast<AutonomousDrone*>(creator);
+        assert(drone != NULL);
+        this->setControllableEntity(drone);
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    AutonomousDroneController::~AutonomousDroneController()
+    {
+
+    }
+
+    /**
+    @brief
+        The controlling happens here. This method defines what the controller has to do each tick.
+    @param dt
+        The duration of the tick.
+    */
+    void AutonomousDroneController::tick(float dt)
+    {
+        AutonomousDrone *myDrone = static_cast<AutonomousDrone*>(this->getControllableEntity());
+        //TODO: Place your code here:
+        // Steering commands
+        // You can use the commands provided by the AutonomousDrone to steer it:
+        // - moveFrontBack, moveRightLeft, moveUpDown
+        // - rotatePitch, rotateYaw, rotateRoll
+        // Apply them to myDrone (e.g. myDrone->rotateYaw(..) )
+
+	myDrone->moveFrontBack(100);
+	myDrone->rotatePitch(0.7);
+    }
+}




More information about the Orxonox-commit mailing list