[Orxonox-commit 6546] r11187 - in code/branches/plehmannFS16/src/orxonox/controllers: . scriptTasks

plehmann at orxonox.net plehmann at orxonox.net
Thu May 12 16:08:32 CEST 2016


Author: plehmann
Date: 2016-05-12 16:08:32 +0200 (Thu, 12 May 2016)
New Revision: 11187

Added:
   code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc
   code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h
Modified:
   code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
   code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
Log:
added a MoveToTask TODO: implement the update function

Modified: code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc	2016-05-12 14:07:25 UTC (rev 11186)
+++ code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc	2016-05-12 14:08:32 UTC (rev 11187)
@@ -134,7 +134,7 @@
 
           orxout() << this->scTime_ << endl;
 
-          if(this->taskList_.front()->getStartTime() < this->scTime_)
+          if(this->taskList_.front().getStartTime() < this->scTime_)
           {
              activeTasks_.push_back(this->taskList_.front());
              this->taskList_.pop_front();
@@ -145,11 +145,10 @@
           //orxout() << "no tasks in taskList_" << endl;
         }
         
-        for (std::vector<Task*>::iterator it = activeTasks_.begin(); it != activeTasks_.end(); it++)
+        for (std::vector<Task>::iterator it = activeTasks_.begin(); it != activeTasks_.end(); it++)
         {
-          if( !((*it)->update(dt)) )
+          if( !(it->update(dt)) )
           {
-            delete (*it); // delete the task that was created with new
             activeTasks_.erase(it);
             it--; // set back the iterator so we continue with the next element and not with the one after that
           }
@@ -167,8 +166,8 @@
 
     void NewScriptController::debugOut(float startTime)
     {
-      DebugTask* task = new DebugTask(context_);
-      task->initialize(startTime);
+      DebugTask task = DebugTask(context_);
+      task.initialize(startTime);
 
       if(taskList_.empty())
       {
@@ -177,11 +176,11 @@
 
       else
       {
-        for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
+        for (std::list<Task>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
         {
           orxout() << taskList_.empty() << endl;
 
-          if(task->getStartTime() < (*it)->getStartTime() )
+          if(task.getStartTime() < it->getStartTime() )
           {
             taskList_.insert(it, task);
           }
@@ -191,8 +190,8 @@
 
     void NewScriptController::stringOut(float startTime, std::string output)
     {
-      stringOutTask* task = new stringOutTask(context_);
-      task->initialize(startTime, output);
+      stringOutTask task = stringOutTask(context_);
+      task.initialize(startTime, output);
 
       if(taskList_.empty())
       {
@@ -201,11 +200,11 @@
 
       else
       {
-        for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
+        for (std::list<Task>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime
         {
           orxout() << taskList_.empty() << endl;
 
-          if(task->getStartTime() < (*it)->getStartTime() )
+          if(task.getStartTime() < it->getStartTime() )
           {
             taskList_.insert(it, task);
           }

Modified: code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h	2016-05-12 14:07:25 UTC (rev 11186)
+++ code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h	2016-05-12 14:08:32 UTC (rev 11187)
@@ -84,11 +84,11 @@
             int ctrlid_;
 
             // List of events to walk through sorted by starting times
-            std::list<Task*> taskList_;
+            std::list<Task> taskList_;
 
 
             //List of Tasks currently active 
-            std::vector<Task*> activeTasks_;
+            std::vector<Task> activeTasks_;
 
             // Time since the creation of this ScriptController object
             float scTime_;  

Added: code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc	2016-05-12 14:08:32 UTC (rev 11187)
@@ -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:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "MoveToTask.h"
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+
+namespace orxonox
+{
+   
+    RegisterClass(MoveToTask);
+
+    MoveToTask::MoveToTask(Context* context): Task(context)
+    {
+        RegisterObject(MoveToTask);
+    }
+
+    void MoveToTask::initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity)
+    {
+        this->starTime_ = startTime;
+        this->player_ = player;
+        this->entity_ = this->player_->getControllableEntity();
+        this->destination_ = destination;
+        this->entity->setVelocity( Vector3(0,0,0) )
+    }
+
+    bool MoveToTask::update(float dt)
+    {
+
+
+        /* Set the position to the correct place in the trajectory */
+        this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1);
+
+        /* Look at the specified position */
+        this->entity_->lookAt(this->currentEvent.v2);
+
+    }
+
+}
\ No newline at end of file

Added: code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h
===================================================================
--- code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h	                        (rev 0)
+++ code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h	2016-05-12 14:08:32 UTC (rev 11187)
@@ -0,0 +1,67 @@
+/*
+ *   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:
+ *      Paul Lehmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _MoveToTask_H__
+#define _MoveToTask_H__
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+#include "Task.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport MoveToTask : public Task
+    {
+        public:
+            MoveToTask(Context* context);
+            virtual ~MoveToTask(){}
+
+            void initialize(float startTime, PlayerInfo* player, vector3 destination);
+
+            virtual bool update(float dt) override;
+
+        private:
+
+            std::string output_;
+
+            // Information about the player that this ScriptController will
+            // control 
+            // - Player pointer 
+            PlayerInfo* player_;
+
+            // - Entity pointer, this is for convenience and will be the same as 
+            //   player_->getControllableEntity() 
+            ControllableEntity* entity_;
+
+            vector3 destination_;
+
+    };
+}
+
+#endif /* _MoveToTask_H__ */
\ No newline at end of file




More information about the Orxonox-commit mailing list