[Orxonox-commit 1045] r5765 - in code/branches/tutorial: data/levels src/orxonox/controllers src/orxonox/worldentities

scheusso at orxonox.net scheusso at orxonox.net
Wed Sep 23 16:54:09 CEST 2009


Author: scheusso
Date: 2009-09-23 16:54:09 +0200 (Wed, 23 Sep 2009)
New Revision: 5765

Added:
   code/branches/tutorial/src/orxonox/controllers/DroneController.cc
   code/branches/tutorial/src/orxonox/controllers/DroneController.h
   code/branches/tutorial/src/orxonox/worldentities/Drone.cc
   code/branches/tutorial/src/orxonox/worldentities/Drone.h
Modified:
   code/branches/tutorial/data/levels/tutorial.oxw
   code/branches/tutorial/src/orxonox/controllers/
   code/branches/tutorial/src/orxonox/controllers/CMakeLists.txt
   code/branches/tutorial/src/orxonox/worldentities/
   code/branches/tutorial/src/orxonox/worldentities/CMakeLists.txt
Log:
this is the complete (and migrated) version of the tutorial branch fs09


Modified: code/branches/tutorial/data/levels/tutorial.oxw
===================================================================
--- code/branches/tutorial/data/levels/tutorial.oxw	2009-09-23 14:53:15 UTC (rev 5764)
+++ code/branches/tutorial/data/levels/tutorial.oxw	2009-09-23 14:54:09 UTC (rev 5765)
@@ -13,7 +13,7 @@
    skybox       = "Orxonox/skypanoramagen1"
   >
 
-<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
+<Drone name="meineDrohne" position="0,0,-10" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
   <attached>
     <Model scale="10" mesh="drone.mesh"/>
   </attached>


Property changes on: code/branches/tutorial/src/orxonox/controllers
___________________________________________________________________
Added: svn:mergeinfo
   + /code/branches/libraries/src/orxonox/controllers:5612-5692
/code/branches/libraries2/src/orxonox/controllers:5703-5737
/code/branches/resource2/src/orxonox/controllers:3372-5694
/code/branches/tutorial/src/orxonox/objects/controllers:2761-2765
code/branches/buildsystem/src/orxonox/controllers:1874-2276,2278-2400
code/branches/buildsystem2/src/orxonox/controllers:2506-2658
code/branches/buildsystem3/src/orxonox/controllers:2662-2708
code/branches/ceguilua/src/orxonox/controllers:1802-1808
code/branches/core3/src/orxonox/controllers:1572-1739
code/branches/core4/src/orxonox/controllers:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes/src/orxonox/controllers:2826-3031
code/branches/gcc43/src/orxonox/controllers:1580
code/branches/gui/src/orxonox/controllers:1635-1723,2795-2894
code/branches/input/src/orxonox/controllers:1629-1636
code/branches/lodfinal/src/orxonox/controllers:2372-2411
code/branches/map/src/orxonox/controllers:2801-3086,3089
code/branches/miniprojects/src/orxonox/controllers:2754-2824
code/branches/netp2/src/orxonox/controllers:2835-2988
code/branches/netp3/src/orxonox/controllers:2988-3082
code/branches/netp6/src/orxonox/controllers:3214-3302
code/branches/network/src/orxonox/controllers:2356
code/branches/network64/src/orxonox/controllers:2210-2355
code/branches/objecthierarchy/src/orxonox/controllers:1911-2085,2100,2110-2169
code/branches/objecthierarchy2/src/orxonox/controllers:2171-2479
code/branches/overlay/src/orxonox/controllers:2117-2385
code/branches/particles/src/orxonox/controllers:2829-3085
code/branches/pch/src/orxonox/controllers:3113-3194
code/branches/physics/src/orxonox/controllers:1912-2055,2107-2439
code/branches/physics_merge/src/orxonox/controllers:2436-2457
code/branches/pickups/src/orxonox/controllers:1926-2086,2127,2827-2915
code/branches/pickups2/src/orxonox/controllers:2107-2497,2915-3071
code/branches/presentation/src/orxonox/controllers:2369-2652,2654-2660
code/branches/questsystem/src/orxonox/controllers:1894-2088
code/branches/questsystem2/src/orxonox/controllers:2107-2259
code/branches/questsystem5/src/orxonox/controllers:2776-2905
code/branches/resource/src/orxonox/controllers:3327-3366
code/branches/script_trigger/src/orxonox/controllers:1295-1953,1955
code/branches/sound/src/orxonox/controllers:2829-3010
code/branches/weapon/src/orxonox/controllers:1925-2094
code/branches/weapon2/src/orxonox/controllers:2107-2488
code/branches/weapons/src/orxonox/controllers:2897-3051
code/branches/weaponsystem/src/orxonox/controllers:2742-2890

Modified: code/branches/tutorial/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/CMakeLists.txt	2009-09-23 14:53:15 UTC (rev 5764)
+++ code/branches/tutorial/src/orxonox/controllers/CMakeLists.txt	2009-09-23 14:54:09 UTC (rev 5765)
@@ -3,6 +3,7 @@
   HumanController.cc
   ArtificialController.cc
   AIController.cc
+  DroneController.cc
   ScriptController.cc
   WaypointController.cc
   WaypointPatrolController.cc

Copied: code/branches/tutorial/src/orxonox/controllers/DroneController.cc (from rev 2765, code/branches/tutorial/src/orxonox/objects/controllers/DroneController.cc)
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/DroneController.cc	                        (rev 0)
+++ code/branches/tutorial/src/orxonox/controllers/DroneController.cc	2009-09-23 14:54:09 UTC (rev 5765)
@@ -0,0 +1,66 @@
+/*
+ *   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 "DroneController.h"
+#include "worldentities/Drone.h"
+#include "util/Math.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());
+        if(totaltime<100)
+        {
+            myDrone->moveFrontBack( -sqrt(dt) );
+            myDrone->rotatePitch(-dt);
+        }
+    }
+}

Copied: code/branches/tutorial/src/orxonox/controllers/DroneController.h (from rev 2765, code/branches/tutorial/src/orxonox/objects/controllers/DroneController.h)
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/DroneController.h	                        (rev 0)
+++ code/branches/tutorial/src/orxonox/controllers/DroneController.h	2009-09-23 14:54:09 UTC (rev 5765)
@@ -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 "tools/interfaces/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__ */


Property changes on: code/branches/tutorial/src/orxonox/worldentities
___________________________________________________________________
Added: svn:mergeinfo
   + /code/branches/libraries/src/orxonox/worldentities:5612-5692
/code/branches/libraries2/src/orxonox/worldentities:5703-5737
/code/branches/resource2/src/orxonox/worldentities:3372-5694
/code/branches/tutorial/src/orxonox/objects/worldentities:2761-2765
code/branches/buildsystem/src/orxonox/worldentities:1874-2276,2278-2400
code/branches/buildsystem2/src/orxonox/worldentities:2506-2658
code/branches/buildsystem3/src/orxonox/worldentities:2662-2708
code/branches/ceguilua/src/orxonox/worldentities:1802-1808
code/branches/core3/src/orxonox/worldentities:1572-1739
code/branches/core4/src/orxonox/worldentities:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes/src/orxonox/worldentities:2826-3031
code/branches/gcc43/src/orxonox/worldentities:1580
code/branches/gui/src/orxonox/worldentities:1635-1723,2795-2894
code/branches/input/src/orxonox/worldentities:1629-1636
code/branches/lodfinal/src/orxonox/worldentities:2372-2411
code/branches/map/src/orxonox/worldentities:2801-3086,3089
code/branches/miniprojects/src/orxonox/worldentities:2754-2824
code/branches/netp2/src/orxonox/worldentities:2835-2988
code/branches/netp3/src/orxonox/worldentities:2988-3082
code/branches/netp6/src/orxonox/worldentities:3214-3302
code/branches/network/src/orxonox/worldentities:2356
code/branches/network64/src/orxonox/worldentities:2210-2355
code/branches/objecthierarchy/src/orxonox/worldentities:1911-2085,2100,2110-2169
code/branches/objecthierarchy2/src/orxonox/worldentities:2171-2479
code/branches/overlay/src/orxonox/worldentities:2117-2385
code/branches/particles/src/orxonox/worldentities:2829-3085
code/branches/pch/src/orxonox/worldentities:3113-3194
code/branches/physics/src/orxonox/worldentities:1912-2055,2107-2439
code/branches/physics_merge/src/orxonox/worldentities:2436-2457
code/branches/pickups/src/orxonox/worldentities:1926-2086,2127,2827-2915
code/branches/pickups2/src/orxonox/worldentities:2107-2497,2915-3071
code/branches/presentation/src/orxonox/worldentities:2369-2652,2654-2660
code/branches/questsystem/src/orxonox/worldentities:1894-2088
code/branches/questsystem2/src/orxonox/worldentities:2107-2259
code/branches/questsystem5/src/orxonox/worldentities:2776-2905
code/branches/resource/src/orxonox/worldentities:3327-3366
code/branches/script_trigger/src/orxonox/worldentities:1295-1953,1955
code/branches/sound/src/orxonox/worldentities:2829-3010
code/branches/weapon/src/orxonox/worldentities:1925-2094
code/branches/weapon2/src/orxonox/worldentities:2107-2488
code/branches/weapons/src/orxonox/worldentities:2897-3051
code/branches/weaponsystem/src/orxonox/worldentities:2742-2890

Modified: code/branches/tutorial/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/tutorial/src/orxonox/worldentities/CMakeLists.txt	2009-09-23 14:53:15 UTC (rev 5764)
+++ code/branches/tutorial/src/orxonox/worldentities/CMakeLists.txt	2009-09-23 14:54:09 UTC (rev 5765)
@@ -6,6 +6,7 @@
   ControllableEntity.cc
 
   BigExplosion.cc
+  Drone.cc
   ExplosionChunk.cc
   CameraPosition.cc
   SpawnPoint.cc

Copied: code/branches/tutorial/src/orxonox/worldentities/Drone.cc (from rev 2765, code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc)
===================================================================
--- code/branches/tutorial/src/orxonox/worldentities/Drone.cc	                        (rev 0)
+++ code/branches/tutorial/src/orxonox/worldentities/Drone.cc	2009-09-23 14:54:09 UTC (rev 5765)
@@ -0,0 +1,133 @@
+/*
+ *   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 "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
+        this->myController_ = 0;
+        RegisterObject(Drone);
+        
+        this->localLinearAcceleration_.setValue(0, 0, 0);
+        this->localAngularAcceleration_.setValue(0, 0, 0);
+        this->primaryThrust_  = 100;
+        this->auxilaryThrust_ = 100;
+        this->rotationThrust_ = 10;
+        this->steering_ = Vector3::ZERO;
+
+	std::cout << "sdfasdfasdf====================";
+        
+        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, "primaryThrust",  primaryThrust_,  xmlelement, mode);
+        XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
+        XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode);
+    }
+
+    void Drone::tick(float dt)
+    {
+        SUPER(Drone, tick, dt);
+        
+        //if (this->hasLocalController())
+        //{
+            this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+            this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+            if (this->localLinearAcceleration_.z() > 0)
+              this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+            else
+              this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+            this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+            this->localLinearAcceleration_.setValue(0, 0, 0);
+        
+            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);
+    }
+    
+}

Copied: code/branches/tutorial/src/orxonox/worldentities/Drone.h (from rev 2765, code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h)
===================================================================
--- code/branches/tutorial/src/orxonox/worldentities/Drone.h	                        (rev 0)
+++ code/branches/tutorial/src/orxonox/worldentities/Drone.h	2009-09-23 14:54:09 UTC (rev 5765)
@@ -0,0 +1,84 @@
+/*
+ *   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 "worldentities/ControllableEntity.h"
+#include "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 primaryThrust_;
+            float auxilaryThrust_;
+            float rotationThrust_;
+    };
+
+}
+
+#endif /* _Drone_H__ */




More information about the Orxonox-commit mailing list