[Orxonox-commit 58] r2763 - in branches/tutorial/src/orxonox: gamestates objects/controllers objects/worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Sun Mar 8 22:14:26 CET 2009
Author: scheusso
Date: 2009-03-08 22:14:25 +0100 (Sun, 08 Mar 2009)
New Revision: 2763
Added:
branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
branches/tutorial/src/orxonox/objects/controllers/DroneController.h
branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
branches/tutorial/src/orxonox/objects/worldentities/Drone.h
Modified:
branches/tutorial/src/orxonox/gamestates/GSLevel.cc
branches/tutorial/src/orxonox/objects/controllers/CMakeLists.txt
branches/tutorial/src/orxonox/objects/worldentities/CMakeLists.txt
Log:
first efforts for a tutorial ^^
Modified: branches/tutorial/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- branches/tutorial/src/orxonox/gamestates/GSLevel.cc 2009-03-08 16:26:41 UTC (rev 2762)
+++ branches/tutorial/src/orxonox/gamestates/GSLevel.cc 2009-03-08 21:14:25 UTC (rev 2763)
@@ -48,7 +48,7 @@
namespace orxonox
{
- SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
+ SetCommandLineArgument(level, "tutorial.oxw").shortcut("l");
GSLevel::GSLevel()
// : GameState<GSGraphics>(name)
Modified: branches/tutorial/src/orxonox/objects/controllers/CMakeLists.txt
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/CMakeLists.txt 2009-03-08 16:26:41 UTC (rev 2762)
+++ branches/tutorial/src/orxonox/objects/controllers/CMakeLists.txt 2009-03-08 21:14:25 UTC (rev 2763)
@@ -3,5 +3,6 @@
HumanController.cc
ArtificialController.cc
AIController.cc
+ DroneController.cc
ScriptController.cc
)
Added: branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/DroneController.cc (rev 0)
+++ branches/tutorial/src/orxonox/objects/controllers/DroneController.cc 2009-03-08 21:14:25 UTC (rev 2763)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DroneController.h"
+#include "objects/worldentities/Drone.h"
+
+
+namespace orxonox
+{
+ DroneController::DroneController(BaseObject* creator) : Controller(creator)
+ {
+ // Place your code here:
+ // - make sure to register the object in the factory
+ // - do any kind of initialisation
+ RegisterObject(DroneController);
+
+ // this checks that our creator really is a drone
+ // and saves the pointer to the drone for the controlling commands
+ assert(dynamic_cast<Drone*>(creator)!=0);
+ this->setControllableEntity(dynamic_cast<Drone*>(creator));
+ }
+
+ DroneController::~DroneController()
+ {
+ }
+
+ void DroneController::tick(float dt)
+ {
+ // Place your code here:
+ // - steering commands
+ static float totaltime = 0;
+ totaltime += dt;
+ Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
+ myDrone->rotateRoll(1000);
+ myDrone->moveFrontBack( 1000 );
+ }
+}
Added: branches/tutorial/src/orxonox/objects/controllers/DroneController.h
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/DroneController.h (rev 0)
+++ branches/tutorial/src/orxonox/objects/controllers/DroneController.h 2009-03-08 21:14:25 UTC (rev 2763)
@@ -0,0 +1,53 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DroneController_H__
+#define _DroneController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Controller.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport DroneController : public Controller, public Tickable
+ {
+ public:
+ DroneController(BaseObject* creator);
+ virtual ~DroneController();
+
+ virtual void tick(float dt);
+
+ protected:
+
+ private:
+ };
+}
+
+#endif /* _DroneController_H__ */
Modified: branches/tutorial/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/CMakeLists.txt 2009-03-08 16:26:41 UTC (rev 2762)
+++ branches/tutorial/src/orxonox/objects/worldentities/CMakeLists.txt 2009-03-08 21:14:25 UTC (rev 2763)
@@ -8,6 +8,7 @@
Backlight.cc
Billboard.cc
BlinkingBillboard.cc
+ Drone.cc
ExplosionChunk.cc
FadingBillboard.cc
Light.cc
Added: branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.cc (rev 0)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.cc 2009-03-08 21:14:25 UTC (rev 2763)
@@ -0,0 +1,117 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Drone.h"
+
+#include "core/XMLPort.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ // put your code in here:
+ // create the factory for the drone
+ CreateFactory(Drone);
+
+ Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
+ {
+ //put your code in here:
+ // - register the drone class to the core
+ // - create a new controller and pass our this pointer to it as creator
+ RegisterObject(Drone);
+
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);this->rotationThrust_ = 0;
+ this->steering_ = Vector3::ZERO;
+
+ this->setCollisionType(WorldEntity::Dynamic);
+
+ myController = new DroneController(static_cast<BaseObject*>(this));
+ }
+
+ Drone::~Drone()
+ {
+ if( this->myController )
+ delete this->myController;
+ }
+
+ void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // this calls the XMLPort function of the parent class
+ SUPER(Drone, XMLPort, xmlelement, mode);
+
+ XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode);
+ }
+
+ void Drone::tick(float dt)
+ {
+ SUPER(Drone, tick, dt);
+
+ //if (this->hasLocalController())
+ //{
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ //}
+ }
+
+
+ void Drone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ this->steering_.z = -value.x;
+ }
+
+ void Drone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ this->steering_.x = value.x;
+ }
+
+ void Drone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ this->steering_.y = value.x;
+ }
+
+ void Drone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ void Drone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ void Drone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+}
Added: branches/tutorial/src/orxonox/objects/worldentities/Drone.h
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.h (rev 0)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.h 2009-03-08 21:14:25 UTC (rev 2763)
@@ -0,0 +1,82 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Drone_H__
+#define _Drone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "objects/worldentities/ControllableEntity.h"
+#include "objects/controllers/DroneController.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Drone : public ControllableEntity
+ {
+ public:
+ Drone(BaseObject* creator);
+ virtual ~Drone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+ virtual void moveUpDown(const Vector2& value);
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ private:
+ DroneController *myController;
+
+ Vector3 steering_;
+ btVector3 localLinearAcceleration_;
+ btVector3 localAngularAcceleration_;
+ float rotationThrust_;
+ };
+
+}
+
+#endif /* _Drone_H__ */
More information about the Orxonox-commit
mailing list