[Orxonox-commit 7399] r12016 - in code/branches/PresentationFS18: . data/levels data/levels/templates src/libraries/core src/libraries/tools src/orxonox src/orxonox/controllers src/orxonox/infos src/orxonox/items src/orxonox/worldentities src/orxonox/worldentities/pawns
patricwi at orxonox.net
patricwi at orxonox.net
Wed May 30 14:37:02 CEST 2018
Author: patricwi
Date: 2018-05-30 14:37:02 +0200 (Wed, 30 May 2018)
New Revision: 12016
Added:
code/branches/PresentationFS18/data/levels/ScriptableControllerTestMoveKillDrone.oxw
code/branches/PresentationFS18/data/levels/ScriptableControllerTestSpawn.oxw
code/branches/PresentationFS18/data/levels/scriptableControllerTest.oxw
code/branches/PresentationFS18/data/levels/scripts/
code/branches/PresentationFS18/data/levels/templates/ScriptableControllerDroneTemplate.oxt
code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.cc
code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.h
code/branches/PresentationFS18/src/orxonox/scriptablecontroller/
code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.cc
code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.h
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.cc
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h
Modified:
code/branches/PresentationFS18/
code/branches/PresentationFS18/data/levels/scriptController.oxw
code/branches/PresentationFS18/src/libraries/core/BaseObject.cc
code/branches/PresentationFS18/src/libraries/core/BaseObject.h
code/branches/PresentationFS18/src/libraries/tools/Timer.cc
code/branches/PresentationFS18/src/libraries/tools/Timer.h
code/branches/PresentationFS18/src/orxonox/CMakeLists.txt
code/branches/PresentationFS18/src/orxonox/Level.cc
code/branches/PresentationFS18/src/orxonox/Level.h
code/branches/PresentationFS18/src/orxonox/controllers/CMakeLists.txt
code/branches/PresentationFS18/src/orxonox/controllers/Controller.cc
code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.cc
code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.h
code/branches/PresentationFS18/src/orxonox/infos/HumanPlayer.cc
code/branches/PresentationFS18/src/orxonox/items/ShipPart.cc
code/branches/PresentationFS18/src/orxonox/worldentities/CMakeLists.txt
code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.cc
code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.h
code/branches/PresentationFS18/src/orxonox/worldentities/MobileEntity.cc
code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.cc
code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.h
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/CMakeLists.txt
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Merged Scriptable Controller
Index: code/branches/PresentationFS18
===================================================================
--- code/branches/PresentationFS18 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18 2018-05-30 12:37:02 UTC (rev 12016)
Property changes on: code/branches/PresentationFS18
___________________________________________________________________
Modified: svn:mergeinfo
## -19,6 +19,8 ##
/code/branches/SOBv2_HS17:11459-11765
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
+/code/branches/ScriptableController_FS18:11822-12015
+/code/branches/ScriptableController_HS17:11462-11854
/code/branches/SpaceRace_HS16:11214-11357
/code/branches/StoryModeMap_HS16:11221-11358
/code/branches/SuperOrxoBros_FS17:11365-11448
Copied: code/branches/PresentationFS18/data/levels/ScriptableControllerTestMoveKillDrone.oxw (from rev 12015, code/branches/ScriptableController_FS18/data/levels/ScriptableControllerTestMoveKillDrone.oxw)
===================================================================
--- code/branches/PresentationFS18/data/levels/ScriptableControllerTestMoveKillDrone.oxw (rev 0)
+++ code/branches/PresentationFS18/data/levels/ScriptableControllerTestMoveKillDrone.oxw 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,48 @@
+<LevelInfo
+ name = "Scriptable Controller Moving and Killing Pawn"
+ description = "Demonstrates moving and killing a drone by using a lua script."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+ include("templates/HeavyCruiser.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipEscort.oxt")
+ include("templates/endurancetest_template.oxt")
+?>
+
+<Level script="scripts/ScriptableControllerMoveKill.lua">
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="100,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+
+ <ScriptableControllerDrone id="dummy" position="0,0,0">
+ <attached>
+ <Model scale="10" mesh="drone.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+ </collisionShapes>
+ </ScriptableControllerDrone>
+
+
+
+
+ </Scene>
+</Level>
Copied: code/branches/PresentationFS18/data/levels/ScriptableControllerTestSpawn.oxw (from rev 12015, code/branches/ScriptableController_FS18/data/levels/ScriptableControllerTestSpawn.oxw)
===================================================================
--- code/branches/PresentationFS18/data/levels/ScriptableControllerTestSpawn.oxw (rev 0)
+++ code/branches/PresentationFS18/data/levels/ScriptableControllerTestSpawn.oxw 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,41 @@
+<LevelInfo
+ name = "Scriptable Controller Spawning Pawn"
+ description = "Demonstrates spawning a drone by using a lua script."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+ include("templates/HeavyCruiser.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipEscort.oxt")
+ include("templates/endurancetest_template.oxt")
+ include("templates/ScriptableControllerDroneTemplate.oxt")
+?>
+
+<Level script="scripts/ScriptableControllerSpawn.lua">
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="100,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+
+
+
+
+
+ </Scene>
+</Level>
Modified: code/branches/PresentationFS18/data/levels/scriptController.oxw
===================================================================
--- code/branches/PresentationFS18/data/levels/scriptController.oxw 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/data/levels/scriptController.oxw 2018-05-30 12:37:02 UTC (rev 12016)
@@ -17,7 +17,7 @@
?>
<Level
- gametype = Deathmatch
+
>
<templates>
<Template link=lodtemplate_default />
Copied: code/branches/PresentationFS18/data/levels/scriptableControllerTest.oxw (from rev 12015, code/branches/ScriptableController_FS18/data/levels/scriptableControllerTest.oxw)
===================================================================
--- code/branches/PresentationFS18/data/levels/scriptableControllerTest.oxw (rev 0)
+++ code/branches/PresentationFS18/data/levels/scriptableControllerTest.oxw 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,42 @@
+<LevelInfo
+ name = "scriptableControllerTest"
+ description = "A level with absolutely nothing in it."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+ include("templates/HeavyCruiser.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipEscort.oxt")
+ include("templates/endurancetest_template.oxt")
+?>
+
+<Level script="scripts/scriptableControllerTest.lua">
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+ <ModularSpaceShip id="Station" velocity= "0,0,0" position="50000000,0,0" lookat= "0,0,0" health="500" maxhealth="500" initialhealth="500">
+ <templates>
+ <Template link=endurance />
+ </templates>
+ </ModularSpaceShip>
+
+ </Scene>
+</Level>
+
Copied: code/branches/PresentationFS18/data/levels/templates/ScriptableControllerDroneTemplate.oxt (from rev 12015, code/branches/ScriptableController_FS18/data/levels/templates/ScriptableControllerDroneTemplate.oxt)
===================================================================
--- code/branches/PresentationFS18/data/levels/templates/ScriptableControllerDroneTemplate.oxt (rev 0)
+++ code/branches/PresentationFS18/data/levels/templates/ScriptableControllerDroneTemplate.oxt 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,10 @@
+<Template name=ScriptableControllerDroneTemplate>
+ <ScriptableControllerDrone>
+ <attached>
+ <Model scale="10" mesh="drone.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+ </collisionShapes>
+ </ScriptableControllerDrone>
+</Template>
\ No newline at end of file
Modified: code/branches/PresentationFS18/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/core/BaseObject.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/libraries/core/BaseObject.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -76,7 +76,7 @@
if (this->creator_)
{
this->setFile(this->creator_->getFile());
-
+
// store strong-pointers on all four base objects by default (can be overwritten with weak-ptr after the constructor if necessary)
this->setNamespace(this->creator_->namespace_.createStrongPtr());
this->setScene (this->creator_->scene_ .createStrongPtr(), this->creator_->sceneID_);
Modified: code/branches/PresentationFS18/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/core/BaseObject.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/libraries/core/BaseObject.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -57,6 +57,7 @@
class Scene;
class Gametype;
class Level;
+ class ScriptableController;
/// The BaseObject is the parent of all classes representing an instance in the game.
class _CoreExport BaseObject : public OrxonoxClass
@@ -191,6 +192,7 @@
static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
+
protected:
void addEventState(const std::string& name, EventState* container);
EventState* getEventState(const std::string& name) const;
Modified: code/branches/PresentationFS18/src/libraries/tools/Timer.cc
===================================================================
--- code/branches/PresentationFS18/src/libraries/tools/Timer.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/libraries/tools/Timer.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -157,6 +157,14 @@
this->setTimer(interval, bLoop, executor, bKillAfterCall);
}
+ Timer::Timer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall)
+ {
+ this->init();
+ RegisterObject(Timer);
+
+ this->setTimer(interval, bLoop, func, bKillAfterCall);
+ }
+
/**
@brief Initializes the Timer
*/
@@ -192,13 +200,23 @@
this->bLoop_ = bLoop;
this->executor_ = executor;
this->bActive_ = true;
+ this->isStdFunction_ = false;
this->time_ = this->interval_;
this->bKillAfterCall_ = bKillAfterCall;
- executor->getFunctor()->setSafeMode(true);
+ if(executor != nullptr)
+ executor->getFunctor()->setSafeMode(true);
}
+ void Timer::setTimer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall)
+ {
+ // Without the cast, the call would be ambiguous, because nullptr is castable to
+ // both, ExecutorPtr and std::function.
+ this->setTimer(interval, bLoop, static_cast<ExecutorPtr>(nullptr), bKillAfterCall);
+ this->function_ = func;
+ this->isStdFunction_ = true;
+ }
/**
@brief Calls the executor and destroys the timer if requested.
@@ -207,7 +225,10 @@
{
bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
- (*this->executor_)();
+ if(this->isStdFunction_)
+ this->function_();
+ else
+ (*this->executor_)();
if (temp)
delete this;
Modified: code/branches/PresentationFS18/src/libraries/tools/Timer.h
===================================================================
--- code/branches/PresentationFS18/src/libraries/tools/Timer.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/libraries/tools/Timer.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -107,8 +107,10 @@
Timer();
Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
+ Timer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false);
void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
+ void setTimer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false);
void run();
@@ -153,7 +155,9 @@
void init();
ExecutorPtr executor_; //!< The executor of the function that will be called when the time expires
+ std::function<void (void)> function_;
+ bool isStdFunction_;
long long interval_; //!< The time-interval in micro seconds
bool bLoop_; //!< If true, the executor gets called every @a interval seconds
bool bActive_; //!< If true, the timer ticks and calls the executor if the time's up
Modified: code/branches/PresentationFS18/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/PresentationFS18/src/orxonox/CMakeLists.txt 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/CMakeLists.txt 2018-05-30 12:37:02 UTC (rev 12016)
@@ -50,6 +50,7 @@
ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(items)
ADD_SUBDIRECTORY(overlays)
+ADD_SUBDIRECTORY(scriptablecontroller)
ADD_SUBDIRECTORY(sound)
ADD_SUBDIRECTORY(weaponsystem)
ADD_SUBDIRECTORY(worldentities)
Modified: code/branches/PresentationFS18/src/orxonox/Level.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/Level.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/Level.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -41,6 +41,7 @@
#include "gametypes/Gametype.h"
#include "overlays/OverlayGroup.h"
#include "LevelManager.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -55,6 +56,7 @@
this->registerVariables();
this->xmlfilename_ = this->getFilename();
this->xmlfile_ = nullptr;
+ this->controller_.reset(new ScriptableController());
}
Level::~Level()
@@ -78,6 +80,8 @@
XMLPortParam(Level, "plugins", setPluginsString, getPluginsString, xmlelement, mode);
XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
+ XMLPortParamLoadOnly(Level, "script", setScript, xmlelement, mode).defaultValues("scripts/empty.lua");
+
XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
}
Modified: code/branches/PresentationFS18/src/orxonox/Level.h
===================================================================
--- code/branches/PresentationFS18/src/orxonox/Level.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/Level.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -41,6 +41,8 @@
namespace orxonox
{
+ class ScriptableController;
+
class _OrxonoxExport Level : public BaseObject, public Synchronisable, public Context
{
public:
@@ -54,7 +56,12 @@
MeshLodInformation* getLodInfo(std::string meshName) const;
+ inline ScriptableController *getScriptableController(void)
+ { return this->controller_.get(); }
+ inline const std::string &getScript(void)
+ { return this->level_script_; }
+
private:
void registerVariables();
void addObject(BaseObject* object);
@@ -77,14 +84,22 @@
void networkcallback_applyXMLFile();
+ inline void setScript(const std::string &script)
+ {
+ orxout(internal_warning) << "hi world" << endl;
+ this->level_script_ = script; }
+
+
std::string pluginsString_;
std::list<PluginReference*> plugins_;
-
std::string gametype_;
std::string xmlfilename_;
XMLFile* xmlfile_;
std::list<BaseObject*> objects_;
std::map<std::string,MeshLodInformation*> lodInformation_;
+
+ std::unique_ptr<ScriptableController> controller_;
+ std::string level_script_;
};
}
Copied: code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.cc (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/controllers/AutonomousDroneController.cc)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.cc (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,115 @@
+/*
+ * 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
+{
+ //TODO: Put your code in here:
+ // Create the factory for the drone controller.
+ RegisterClass(AutonomousDroneController);
+ /**
+ @brief
+ Constructor.
+ @param context
+ The context of this object.
+ */
+ AutonomousDroneController::AutonomousDroneController(Context* context) : Controller(context)
+ {
+ //TODO: Place your code here:
+ // Make sure to register the object and create the factory.
+ RegisterObject(AutonomousDroneController);
+ // This checks that our context really is a drone
+ // and saves the pointer to the drone for the controlling commands
+ /* NOTE from Sandro: This is currently broken */
+ //AutonomousDrone* drone = dynamic_cast<AutonomousDrone*>(context);
+ //assert(drone != nullptr);
+ //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)
+ {
+
+ static int i = 0;
+
+ /* NOTE: Ugly hack by Sandro to make the tutorial work for the moment.
+ * This will be reverted once the framework update is complete
+ */
+ //AutonomousDrone *myDrone = static_cast<AutonomousDrone*>(this->getControllableEntity());
+ ObjectList<AutonomousDrone> objectList;
+ ObjectList<AutonomousDrone>::iterator it = objectList.begin();
+ AutonomousDrone* myDrone = *it;
+
+ if (myDrone != nullptr)
+ {
+ //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
+ // 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.
+ // Apply them to myDrone (e.g. myDrone->rotateYaw(..) )
+ // dt is the time passed since the last call of the tick function in seconds.
+ int iMax = 100;
+ double R = 250;
+
+ double x = R * cos(math::twoPi/iMax*i);
+ double y = R * sin(math::twoPi/iMax*i);
+
+
+ const Vector2 motion1 = Vector2(x,0);
+ const Vector2 motion2 = Vector2(y,0);
+
+
+ myDrone->moveRightLeft(motion1);
+ myDrone->moveUpDown(motion2);
+
+ i = (i+1)%iMax;
+
+
+ }
+ }
+}
Copied: code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.h (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/controllers/AutonomousDroneController.h)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.h (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/controllers/AutonomousDroneController.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,59 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _AutonomousDroneController_H__
+#define _AutonomousDroneController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Controller.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Controller for the AutonomousDrone of the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport AutonomousDroneController : public Controller, public Tickable
+ {
+ public:
+ AutonomousDroneController(Context* context);
+ virtual ~AutonomousDroneController();
+
+ virtual void tick(float dt); //!< The controlling happens here. This method defines what the controller has to do each tick.
+
+ protected:
+
+ private:
+ };
+}
+
+#endif /* _AutonomousDroneController_H__ */
Modified: code/branches/PresentationFS18/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/PresentationFS18/src/orxonox/controllers/CMakeLists.txt 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/controllers/CMakeLists.txt 2018-05-30 12:37:02 UTC (rev 12016)
@@ -18,5 +18,7 @@
FlyingController.cc
FightingController.cc
MasterController.cc
- ArrowController.cc
+ ArrowController.cc;
+ AutonomousDroneController.cc;
+
)
Modified: code/branches/PresentationFS18/src/orxonox/controllers/Controller.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/controllers/Controller.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/controllers/Controller.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+//asdf
#include "Controller.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
Modified: code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -42,6 +42,8 @@
#include "controllers/HumanController.h"
#include "interfaces/GametypeMessageListener.h"
#include "interfaces/NotificationListener.h"
+#include "scriptablecontroller/scriptable_controller.h"
+#include "Level.h"
#include "PlayerInfo.h"
@@ -75,6 +77,7 @@
this->counter_ = 10;
this->spawned_ = false;
this->readyToSpawn_ = false;
+ this->isFirstSpawn_ = true;
this->registerVariables();
}
@@ -295,6 +298,7 @@
this->spawnedPlayers_.erase(player);
this->setReadyToSpawnHelper(player, false);
this->setSpawnedHelper(player, false);
+
}
}
@@ -309,9 +313,21 @@
if(GameMode::isMaster())
{
if(this->hasStarted() && !this->hasEnded())
-
this->setSpawnedHelper(player, true);
}
+
+ // TODO We might want to handle the subsequent spawns as well somehow
+ if(player->isHumanPlayer() && player->isLocalPlayer()) //&& this->isFirstSpawn_)
+ {
+ this->isFirstSpawn_ = false;
+ this->getLevel()->getScriptableController()->setPlayer(player);
+
+ // This handles paths relative to the 'level' directory
+ std::string script = this->getLevel()->getScript();
+ if(script.at(0) != '/')
+ script = "../levels/" + script; // Not very dynamic
+ this->getLevel()->getScriptableController()->runScript(script);
+ }
}
/**
@@ -344,8 +360,17 @@
if( player->isHumanPlayer() )
{
// Display "Press [Fire] to start the match" if the game has not yet ended.
- if(!this->hasEnded())
+ if(!this->hasEnded()){
NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, NotificationMessageType::info, NotificationSendMode::network, player->getClientID());
+
+ //this->getLevel()->getScriptableController()->setPlayer(player);
+
+ // This handles paths relative to the 'level' directory
+ //std::string script = this->getLevel()->getScript();
+ //if(script.at(0) != '/')
+ //script = "../levels/" + script; // Not very dynamic
+ //this->getLevel()->getScriptableController()->runScript(script);
+ }
// Else display "Game has ended".
else
NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, NotificationMessageType::info, NotificationSendMode::network, player->getClientID());
Modified: code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.h
===================================================================
--- code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/infos/GametypeInfo.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -82,6 +82,7 @@
*/
inline bool isStartCountdownRunning() const
{ return this->bStartCountdownRunning_; }
+
void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped.
/**
@@ -165,6 +166,7 @@
std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned.
bool spawned_; //!< Whether the local Player is currently spawned.
bool readyToSpawn_; //!< Whether the local Player is ready to spawn.
+ bool isFirstSpawn_;
};
}
Modified: code/branches/PresentationFS18/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/infos/HumanPlayer.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/infos/HumanPlayer.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -37,6 +37,8 @@
#include "controllers/NewHumanController.h"
#include "gametypes/Gametype.h"
#include "overlays/OverlayGroup.h"
+#include "Level.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
Modified: code/branches/PresentationFS18/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/items/ShipPart.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/items/ShipPart.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -41,6 +41,8 @@
#include "worldentities/StaticEntity.h"
#include "items/PartDestructionEvent.h"
#include "chat/ChatManager.h"
+#include "Level.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
@@ -214,6 +216,11 @@
parent_->setHealth(parent_->getHealth() - ((damage - shielddamage) - healthdamage) * (1- this->damageAbsorption_));
}
}
+
+ // This is a bit hacky, but it takes away damage control from the pawn, so it has to handle
+ // that as well.
+ this->getLevel()->getScriptableController()->pawnHit(parent_, originator, parent_->getHealth(), parent_->getShieldHealth());
+
if (this->health_ < 0)
this->death();
Copied: code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.cc (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/worldentities/AutonomousDrone.cc)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.cc (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,200 @@
+/*
+ * 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 "AutonomousDrone.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ //TODO: Put your code in here:
+ // Create the factory for the drone.
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ @param creator
+ The creator of this object.
+ */
+
+ RegisterClass(AutonomousDrone);
+
+ AutonomousDrone::AutonomousDrone(Context* context) : ControllableEntity(context)
+ {
+ //TODO: Put your code in here:
+ // Register the drone class to the core.
+
+ RegisterObject(AutonomousDrone);
+
+ this->myController_ = NULL;
+
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxiliaryThrust_ = 100;
+ this->rotationThrust_ = 10;
+ this->mass_ = 100;
+ this->linearDamping_ = 0.5;
+ this->angularDamping_ = 0.3;
+
+ this->setCollisionType(CollisionType::Dynamic);
+
+ //this->myController_ = new AutonomousDroneController(this); // Creates a new controller and passes our this pointer to it as creator.
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ AutonomousDrone::~AutonomousDrone()
+ {
+ // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
+ if( this->isInitialized() && this->myController_ != NULL )
+ delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a AutonomousDrone through XML.
+ */
+ void AutonomousDrone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // This calls the XMLPort function of the parent class
+ SUPER(AutonomousDrone, XMLPort, xmlelement, mode);
+
+ XMLPortParam(AutonomousDrone, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ //TODO: Put your code in here:
+ // Make sure you add the variables auxiliaryThrust_ and rotationThrust_ to XMLPort.
+ // Variables can be added by the following command
+ // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunctionName, getFunctionName, xmlelement, mode);
+ // Also make sure that you also create the get- and set-functions in AutonomousDrone.h. As you can see, the get- and set-functions for the variable primaryThrust_ has already been specified there, so you can get your inspiration from there.
+ XMLPortParam(AutonomousDrone, "auxiliaryThrust", setAuxiliaryThrust, getAuxiliaryThrust, xmlelement, mode);
+ XMLPortParam(AutonomousDrone, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
+ XMLPortParam(AutonomousDrone, "mass", setMass, getMass, xmlelement, mode);
+ XMLPortParam(AutonomousDrone, "linearDamping", setLinearDamping, getLinearDamping, xmlelement, mode);
+ XMLPortParam(AutonomousDrone, "angularDamping", setAngularDamping, getAngularDamping, xmlelement, mode);
+
+
+
+
+
+ }
+
+ /**
+ @brief
+ Defines which actions the AutonomousDrone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void AutonomousDrone::tick(float dt)
+ {
+ SUPER(AutonomousDrone, tick, dt);
+
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxiliaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxiliaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxiliaryThrust_);
+ 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);
+ }
+
+ /**
+ @brief
+ Moves the AutonomousDrone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void AutonomousDrone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the AutonomousDrone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void AutonomousDrone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the AutonomousDrone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void AutonomousDrone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the AutonomousDrone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void AutonomousDrone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ /**
+ @brief
+ Rotates the AutonomousDrone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void AutonomousDrone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the AutonomousDrone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void AutonomousDrone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+
+}
Copied: code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.h (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/worldentities/AutonomousDrone.h)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.h (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/AutonomousDrone.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,212 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _AutonomousDrone_H__
+#define _AutonomousDrone_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/XMLPort.h"
+#include "controllers/AutonomousDroneController.h"
+
+#include "ControllableEntity.h"
+
+namespace orxonox {
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport AutonomousDrone : public ControllableEntity
+ {
+ public:
+ AutonomousDrone(Context* context);
+ virtual ~AutonomousDrone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an AutonomousDrone through XML.
+ virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+ 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);
+
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+
+
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ /**
+ @brief Sets the primary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setPrimaryThrust( float thrust )
+ { this->primaryThrust_ = thrust; }
+ //TODO: Place your set-functions here.
+ // Hint: auxiliary thrust, rotation thrust.
+
+
+ /**
+ @brief Sets the auxiliary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setAuxiliaryThrust( float thrust )
+ { this->auxiliaryThrust_ = thrust; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setRotationThrust( float thrust )
+ { this->rotationThrust_ = thrust; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setMass( float mass )
+ { this->mass_ = mass; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setLinearDamping( float damping )
+ { this->linearDamping_ = damping; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setAngularDamping( float damping )
+ { this->angularDamping_ = damping; }
+
+
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+ //TODO: Place your get-functions here.
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getAuxiliaryThrust()
+ { return this->auxiliaryThrust_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getRotationThrust()
+ { return this->rotationThrust_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getMass()
+ { return this->mass_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getLinearDamping()
+ { return this->linearDamping_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getAngularDamping()
+ { return this->angularDamping_; }
+
+
+
+ private:
+ AutonomousDroneController *myController_; //!< The controller of the AutonomousDrone.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the AutonomousDrone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the AutonomousDrone the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxiliaryThrust_; //!< The amount of auxiliary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.s
+ float mass_;
+ float linearDamping_;
+ float angularDamping_;
+ };
+
+}
+
+#endif // _AutonomousDrone_H__
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/CMakeLists.txt 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/CMakeLists.txt 2018-05-30 12:37:02 UTC (rev 12016)
@@ -14,6 +14,7 @@
Actionpoint.cc
NameableStaticEntity.cc
Arrow.cc
+ AutonomousDrone.cc
)
-ADD_SUBDIRECTORY(pawns)
\ No newline at end of file
+ADD_SUBDIRECTORY(pawns)
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -38,6 +38,7 @@
#include "network/NetworkFunctionIncludes.h"
#include "Scene.h"
+#include "Level.h"
#include "infos/PlayerInfo.h"
#include "controllers/NewHumanController.h"
#include "graphics/Camera.h"
@@ -66,7 +67,6 @@
this->hud_ = nullptr;
this->camera_ = nullptr;
this->xmlcontroller_ = nullptr;
- //this->controller_ = nullptr;
this->reverseCamera_ = nullptr;
this->bDestroyWhenPlayerLeft_ = false;
this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/ControllableEntity.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -175,6 +175,7 @@
inline int getTeam() const
{ return this->team_; }
+
protected:
virtual void preDestroy() override;
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/MobileEntity.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/MobileEntity.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/MobileEntity.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -35,6 +35,8 @@
#include "core/XMLPort.h"
#include "Scene.h"
+#include "Level.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -71,6 +73,9 @@
else
this->setAngularVelocity(rotationAxis.normalisedCopy() * rotationRate.valueRadians());
}
+
+ if(!this->id_.empty() && this->getLevel() != nullptr)
+ this->getLevel()->getScriptableController()->registerMobileEntity(this->id_, this);
}
void MobileEntity::tick(float dt)
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -43,7 +43,9 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "Scene.h"
+#include "Level.h"
#include "collisionshapes/WorldEntityCollisionShape.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -78,6 +80,7 @@
this->parent_ = nullptr;
this->parentID_ = OBJECTID_UNKNOWN;
this->bDeleteWithParent_ = true;
+ this->id_ = -1;
this->node_->setPosition(Vector3::ZERO);
this->node_->setOrientation(Quaternion::IDENTITY);
@@ -159,6 +162,7 @@
XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
XMLPortParam (WorldEntity, "scale", setScale, getScale, xmlelement, mode);
+ XMLPortParamLoadOnly(WorldEntity, "id", setID, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode);
@@ -180,6 +184,9 @@
XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
// Attached collision shapes
XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
+
+ if(!this->id_.empty() && this->getLevel() != nullptr)
+ this->getLevel()->getScriptableController()->registerWorldEntity(this->id_, this);
}
void WorldEntity::registerVariables()
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/WorldEntity.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -110,6 +110,12 @@
virtual void changedActivity(void) override;
virtual void changedVisibility(void) override;
+ inline std::string getID(void)
+ { return this->id_; }
+
+ inline void setID(std::string id)
+ { this->id_ = id; }
+
virtual void setPosition(const Vector3& position) = 0;
inline void setPosition(float x, float y, float z)
{ this->setPosition(Vector3(x, y, z)); }
@@ -441,6 +447,7 @@
virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
btRigidBody* physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance.
+ std::string id_; //!< Used by the ScriptableController to identify objects
private:
void recalculateMassProps();
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/CMakeLists.txt
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/CMakeLists.txt 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/CMakeLists.txt 2018-05-30 12:37:02 UTC (rev 12016)
@@ -3,6 +3,7 @@
Spectator.cc
Pawn.cc
SpaceShip.cc
+ ScriptableControllerDrone.cc
ModularSpaceShip.cc
TeamBaseMatchBase.cc
Destroyer.cc
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/Pawn.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/Pawn.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -49,6 +49,8 @@
#include "weaponsystem/Munition.h"
#include "sound/WorldSound.h"
#include "core/object/ObjectListIterator.h"
+#include "Level.h"
+#include "scriptablecontroller/scriptable_controller.h"
#include "controllers/FormationController.h"
@@ -159,6 +161,9 @@
XMLPortParam(Pawn, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode);
XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
+
+ if(!this->id_.empty() && this->getLevel() != nullptr)
+ this->getLevel()->getScriptableController()->registerPawn(this->id_, this);
}
void Pawn::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -281,7 +286,7 @@
if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
{
// Health-damage cannot be absorbed by shields.
- // Shield-damage only reduces shield health.
+ // Shield-damage only reduces shield health.
// Normal damage can be (partially) absorbed by shields.
if (shielddamage >= this->getShieldHealth())
@@ -301,6 +306,7 @@
// set remaining damage to health
this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
}
+ this->getLevel()->getScriptableController()->pawnHit(this, originator, this->health_, this->shieldHealth_);
this->lastHitOriginator_ = originator;
}
@@ -401,6 +407,8 @@
this->goWithStyle();
}
}
+
+ this->getLevel()->getScriptableController()->pawnKilled(this);
}
void Pawn::goWithStyle()
{
@@ -624,7 +632,7 @@
else
{
// delete all debug models
- for(Model* model : debugWeaponSlotModels_)
+ for(Model* model : debugWeaponSlotModels_)
{
model->destroy();
}
@@ -649,4 +657,4 @@
it->drawWeapons(bDraw);
}
}
-}
\ No newline at end of file
+}
Copied: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.cc (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.cc)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.cc (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,208 @@
+/*
+ * 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 "ScriptableControllerDrone.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ //TODO: Put your code in here:
+ // Create the factory for the drone.
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ @param creator
+ The creator of this object.
+ */
+
+ RegisterClass(ScriptableControllerDrone);
+
+ ScriptableControllerDrone::ScriptableControllerDrone(Context* context) : Pawn(context)
+ {
+ //TODO: Put your code in here:
+ // Register the drone class to the core.
+
+ RegisterObject(ScriptableControllerDrone);
+
+ //this->myController_ = NULL;
+
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxiliaryThrust_ = 100;
+ this->rotationThrust_ = 10;
+ this->mass_ = 100;
+ this->linearDamping_ = 0.5;
+ this->angularDamping_ = 0.3;
+
+ this->setRadarVisibility(false);
+
+ this->setCollisionType(WorldEntity::CollisionType::Dynamic);
+
+ //this->setCollisionType(CollisionType::Dynamic);
+
+ //this->myController_ = new ScriptableControllerDroneController(this); // Creates a new controller and passes our this pointer to it as creator.
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ ScriptableControllerDrone::~ScriptableControllerDrone()
+ {
+ // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
+ if( this->isInitialized()); //)&& this->myController_ != NULL )
+ //delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a ScriptableControllerDrone through XML.
+ */
+ void ScriptableControllerDrone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // This calls the XMLPort function of the parent class
+ SUPER(ScriptableControllerDrone, XMLPort, xmlelement, mode);
+
+ XMLPortParam(ScriptableControllerDrone, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ //TODO: Put your code in here:
+ // Make sure you add the variables auxiliaryThrust_ and rotationThrust_ to XMLPort.
+ // Variables can be added by the following command
+ // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunctionName, getFunctionName, xmlelement, mode);
+ // Also make sure that you also create the get- and set-functions in ScriptableControllerDrone.h. As you can see, the get- and set-functions for the variable primaryThrust_ has already been specified there, so you can get your inspiration from there.
+ XMLPortParam(ScriptableControllerDrone, "auxiliaryThrust", setAuxiliaryThrust, getAuxiliaryThrust, xmlelement, mode);
+ XMLPortParam(ScriptableControllerDrone, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
+ XMLPortParam(ScriptableControllerDrone, "mass", setMass, getMass, xmlelement, mode);
+ XMLPortParam(ScriptableControllerDrone, "linearDamping", setLinearDamping, getLinearDamping, xmlelement, mode);
+ XMLPortParam(ScriptableControllerDrone, "angularDamping", setAngularDamping, getAngularDamping, xmlelement, mode);
+
+
+
+
+
+ }
+
+ /**
+ @brief
+ Defines which actions the ScriptableControllerDrone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void ScriptableControllerDrone::tick(float dt)
+ {
+ SUPER(ScriptableControllerDrone, tick, dt);
+
+
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxiliaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxiliaryThrust_);
+
+
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxiliaryThrust_);
+ 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);
+ }
+
+ /**
+ @brief
+ Moves the ScriptableControllerDrone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void ScriptableControllerDrone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the ScriptableControllerDrone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void ScriptableControllerDrone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the ScriptableControllerDrone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void ScriptableControllerDrone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the ScriptableControllerDrone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void ScriptableControllerDrone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ /**
+ @brief
+ Rotates the ScriptableControllerDrone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void ScriptableControllerDrone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the ScriptableControllerDrone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void ScriptableControllerDrone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+
+}
Copied: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h (from rev 12015, code/branches/ScriptableController_FS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h)
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h (rev 0)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/ScriptableControllerDrone.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -0,0 +1,212 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _ScriptableControllerDrone_H__
+#define _ScriptableControllerDrone_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/XMLPort.h"
+//#include "controllers/AutonomousDroneController.h"
+
+#include "Pawn.h"
+
+namespace orxonox {
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport ScriptableControllerDrone : public Pawn
+ {
+ public:
+ ScriptableControllerDrone(Context* context);
+ virtual ~ScriptableControllerDrone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an AutonomousDrone through XML.
+ virtual void tick(float dt); //!< Defines which actions the AutonomousDrone has to take in each tick.
+
+ 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);
+
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+
+
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ /**
+ @brief Sets the primary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setPrimaryThrust( float thrust )
+ { this->primaryThrust_ = thrust; }
+ //TODO: Place your set-functions here.
+ // Hint: auxiliary thrust, rotation thrust.
+
+
+ /**
+ @brief Sets the auxiliary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setAuxiliaryThrust( float thrust )
+ { this->auxiliaryThrust_ = thrust; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setRotationThrust( float thrust )
+ { this->rotationThrust_ = thrust; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setMass( float mass )
+ { this->mass_ = mass; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setLinearDamping( float damping )
+ { this->linearDamping_ = damping; }
+
+ /**
+ @brief Sets the rotation thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setAngularDamping( float damping )
+ { this->angularDamping_ = damping; }
+
+
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+ //TODO: Place your get-functions here.
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getAuxiliaryThrust()
+ { return this->auxiliaryThrust_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getRotationThrust()
+ { return this->rotationThrust_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getMass()
+ { return this->mass_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getLinearDamping()
+ { return this->linearDamping_; }
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getAngularDamping()
+ { return this->angularDamping_; }
+
+
+
+ private:
+ //AutonomousDroneController *myController_; //!< The controller of the AutonomousDrone.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the AutonomousDrone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the AutonomousDrone the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxiliaryThrust_; //!< The amount of auxiliary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.s
+ float mass_;
+ float linearDamping_;
+ float angularDamping_;
+ };
+
+}
+
+#endif // _AutonomousDrone_H__
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.cc 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.cc 2018-05-30 12:37:02 UTC (rev 12016)
@@ -162,7 +162,7 @@
for(Engine* engine : this->engineList_)
engine->run(dt);
- if (this->hasLocalController())
+ if (this->hasLocalController() || true)
{
// If not in mouse look apply the angular movement to the ship.
if (!this->isInMouseLook())
Modified: code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.h 2018-05-30 12:23:47 UTC (rev 12015)
+++ code/branches/PresentationFS18/src/orxonox/worldentities/pawns/SpaceShip.h 2018-05-30 12:37:02 UTC (rev 12016)
@@ -116,6 +116,13 @@
virtual void moveUpDown(const Vector2& value)
{ this->steering_.y += (0.6)*value.x; }
+ 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)); }
+
virtual void rotateYaw(const Vector2& value); // Rotate in yaw direction.
virtual void rotatePitch(const Vector2& value); // Rotate in pitch direction.
virtual void rotateRoll(const Vector2& value); // Rotate in roll direction.
More information about the Orxonox-commit
mailing list