Changeset 11204 for code/branches/plehmannFS16/src/orxonox
- Timestamp:
- May 26, 2016, 3:54:24 PM (9 years ago)
- Location:
- code/branches/plehmannFS16/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/plehmannFS16/src/orxonox/controllers/ControllerDirector.h
r11071 r11204 27 27 */ 28 28 29 /* 30 @todo: 31 32 in the take control or preparationToTakeControl functions remove the former controller and store it somewhere so it can be put back later. 33 34 */ 29 35 #ifndef _ControllerDirector_H__ 30 36 #define _ControllerDirector_H__ -
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
r11190 r11204 46 46 #include "scriptTasks/DebugTask.h" 47 47 #include "scriptTasks/stringOutTask.h" 48 #include "scriptTasks/MoveToTask.h" 48 49 #include "scriptTasks/Task.h" 49 50 #include "infos/PlayerInfo.h" … … 102 103 this->setControllableEntity(this->entity_); 103 104 this->entity_->mouseLook(); 104 this->entity_->setVisible( false);105 this->entity_->setVisible(true); 105 106 106 107 // TODO take the human Controllers control dont forget to give it back in the destructor … … 116 117 // If this controller has no entity entry, do nothing 117 118 if( !(this->entity_) ) return; 118 119 120 /*121 if(taskQueue_.front()->getStartTime() <= scTime_)122 {123 activeTasks_.push_back(taskQueue_.front());124 taskQueue_.pop();125 }126 127 for(Task* task : activeTasks_)128 {129 task->tick(dt);130 }*/131 119 132 120 if(!this->taskList_.empty()) … … 211 199 212 200 task->initialize(startTime, output); 201 202 bool inserted = false; 203 204 if(taskList_.empty()) 205 { 206 taskList_.push_front(task); 207 inserted = true; 208 } 209 210 else 211 { 212 for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime 213 { 214 orxout() << "stringOutTask" << endl; 215 216 if(task->getStartTime() < (*it)->getStartTime() ) 217 { 218 taskList_.insert(it, task); 219 inserted = true; 220 break; 221 } 222 } 223 } 224 225 if (!inserted) 226 { 227 taskList_.push_back(task); 228 } 229 230 } 231 232 void NewScriptController::moveTo(float startTime, float x, float y, float z, float velocity) 233 { 234 235 MoveToTask* task = new MoveToTask(context_); 236 237 Vector3 destination = Vector3(x,y,z); 238 239 task->initialize(startTime, player_, destination, velocity); 213 240 214 241 bool inserted = false; -
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
r11190 r11204 25 25 * ... 26 26 * 27 * 28 * 27 29 */ 28 30 … … 32 34 #include "scriptTasks/DebugTask.h" 33 35 #include "scriptTasks/stringOutTask.h" 36 #include "scriptTasks/MoveToTask.h" 34 37 #include "scriptTasks/Task.h" 35 38 #include "OrxonoxPrereqs.h" /* die ganzen tolua, kopiert aus Dock.h*/ … … 42 45 { // tolua_export 43 46 47 /** 48 @brief 44 49 50 A scriptController to carry out tasks on an entity. 51 The tasks are provided as a lua script. 52 The commands which are exported to lua have to create the specified task, initialze it and add it to the TaskList. 53 54 Important add the export comment after functions that need to be accessed from the lua script. 55 56 @todo 57 58 take away the human controller and put it back into place when this controller is deleted. 59 This is probably better done in the controller director class. 60 61 remove the startTimes of the tasks so that the lua script is just carried out one task after the other. 62 to avoid problems when to tasks are carried out simultainiously. 63 64 also the velocity while the controller is taking control is kept and hinders the tasks. 65 66 the moveToTask does not work right. 67 */ 45 68 46 69 class _OrxonoxExport NewScriptController // tolua_export … … 61 84 62 85 void stringOut(float startTime, std::string output);// tolua_export 86 87 void moveTo(float startTime, float x, float y, float z, float velocity);// tolua_export 63 88 64 89 static NewScriptController* getNewScriptController();// tolua_export -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/CMakeLists.txt
r11183 r11204 3 3 DebugTask.cc 4 4 stringOutTask.cc 5 MoveToTask.cc 5 6 ) -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc
r11190 r11204 23 23 * Paul Lehmann 24 24 * Co-authors: 25 * .. .25 * .. 26 26 * 27 27 */ … … 45 45 void MoveToTask::initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity) 46 46 { 47 this->star Time_ = startTime;47 this->startTime_ = startTime; 48 48 this->player_ = player; 49 49 this->entity_ = this->player_->getControllableEntity(); 50 50 this->destination_ = destination; 51 51 this->velocity_ = velocity; 52 this->entity->setVelocity( Vector3(0,0,0) ) 52 this->entity_->setVelocity( Vector3(0,0,0) ); 53 // unit vector in the direction of travel 54 this->direction_ = (destination - this->entity_->getPosition() )/( (destination - this->entity_->getPosition() ).length() ); 55 53 56 } 54 57 … … 56 59 { 57 60 58 float dl = this->velocity_ * dt; 61 /* Look at the specified position */ 62 this->entity_->lookAt(this->destination_); 59 63 60 61 /* Set the position to the correct place in the trajectory */ 62 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1); 64 this->entity_->setPosition(this->entity_->getPosition() + velocity_ * dt * direction_); 63 65 64 /* Look at the specified position */ 65 this->entity_->lookAt(this->currentEvent.v2); 66 //this->entity_->setVelocity( Vector3(0,0,0) ); 66 67 68 orxout() << (this->entity_->getPosition() - destination_ ).length() << endl; 69 70 if ((this->entity_->getPosition() - destination_ ).length() > 30) 71 { 72 return true; 73 } 74 else 75 { 76 return false; 77 } 67 78 } 68 79 -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h
r11190 r11204 43 43 virtual ~MoveToTask(){} 44 44 45 void initialize(float startTime, PlayerInfo* player, vector3 destination);45 void initialize(float startTime, PlayerInfo* player, Vector3 destination, float velocity); 46 46 47 47 virtual bool update(float dt) override; … … 60 60 ControllableEntity* entity_; 61 61 62 vector3 destination_;62 Vector3 direction_; 63 63 64 Vector3 destination_; 65 66 // velocitz in m/s 64 67 float velocity_; 65 68
Note: See TracChangeset
for help on using the changeset viewer.