Changeset 11207 for code/branches/presentationFS16/src/orxonox
- Timestamp:
- May 26, 2016, 4:38:51 PM (8 years ago)
- Location:
- code/branches/presentationFS16
- Files:
-
- 8 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationFS16
- Property svn:mergeinfo changed
/code/branches/plehmannFS16 (added) merged: 11137,11141,11152,11165,11167,11172,11178-11179,11183,11187,11190,11204
- Property svn:mergeinfo changed
-
code/branches/presentationFS16/src/orxonox/CMakeLists.txt
r11206 r11207 66 66 infos/PlayerInfo.h 67 67 sound/SoundManager.h 68 controllers/ ScriptController.h68 controllers/NewScriptController.h 69 69 overlays/CampaignMenu.h 70 70 PCH_FILE -
code/branches/presentationFS16/src/orxonox/OrxonoxPrereqs.h
r11080 r11207 98 98 class HumanController; 99 99 class ScriptController; 100 class NewScriptController; 100 101 class WaypointController; 101 102 class WaypointPatrolController; -
code/branches/presentationFS16/src/orxonox/controllers/CMakeLists.txt
r11052 r11207 5 5 ArtificialController.cc 6 6 AIController.cc 7 ScriptController.cc8 7 WaypointController.cc 9 8 WaypointPatrolController.cc … … 19 18 FightingController.cc 20 19 MasterController.cc 20 NewScriptController.cc 21 21 ) 22 ADD_SUBDIRECTORY(scriptTasks) -
code/branches/presentationFS16/src/orxonox/controllers/ControllerDirector.cc
r11071 r11207 6 6 7 7 #include "ControllerDirector.h" 8 #include " ScriptController.h"8 #include "NewScriptController.h" 9 9 #include "core/CoreIncludes.h" 10 10 … … 64 64 { 65 65 /* Output a message confirming that the function was called */ 66 orxout( verbose)<<"test takecontrol."<< endl;66 orxout()<<"test takecontrol."<< endl; 67 67 68 68 /* First, we set up a new controller to attach to the unit that … … 74 74 { 75 75 /* Create a scriptcontroller object */ 76 ScriptController *newctrl = newScriptController(this->context_);76 NewScriptController *newctrl = new NewScriptController(this->context_); 77 77 78 78 /* Make the player we were given its slave */ … … 105 105 * the next time it is triggered */ 106 106 ctrlid += 1; 107 108 orxout()<<"swag"<< endl; 107 109 } 108 110 … … 112 114 this->player_ = nullptr; 113 115 114 orxout( verbose) << "Preparation to take Control!" << endl;116 orxout() << "Preparation to take Control!" << endl; 115 117 116 118 // Check whether it is a player trigger and extract pawn from it … … 121 123 122 124 // Check if there actually was a player returned. 123 if( this->player_ == nullptr) return false; 125 if( this->player_ == nullptr) { 126 orxout()<<"swag control"<< endl; 127 128 return false; 129 } 124 130 } 125 131 else 126 132 { 127 orxout( verbose) << "ControllerDirector::preparationToTakeControl "133 orxout() << "ControllerDirector::preparationToTakeControl " 128 134 << "Not a player trigger, can't extract pawn from it.." << endl; 129 135 return false; -
code/branches/presentationFS16/src/orxonox/controllers/ControllerDirector.h
r11071 r11207 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/presentationFS16/src/orxonox/controllers/ScriptController.cc
r11083 r11207 34 34 * Command | Abbreviation | Parameter 1 | '' 2 | '' 3 | '' 4 | '' 5 | '' 6 | '' 7 35 35 * 36 * "Move And Look" | mal | GoTo X Coordinate | '' Y '' | '' Z '' | LookAt X Coordinate | '' Y '' | '' Y '' | Duration 37 * "Rotate And Look" | ral | GoTo X Coordinate | '' Y '' | '' Z '' | Axis (1=x, 2=z, 3=z) | - | - | Duration 38 * "Spiral" | spi | GoTo X Coordinate | '' Y '' | '' Z '' | - | - | - | Duration 39 * "Transition Look" | chl | From X Coordinate | '' Y '' | '' Z '' | To X Coordinate | '' Y '' | '' Y '' | Duration 36 * "Move And Look" | mal | GoTo X Coordinate | '' Y '' | '' Z '' | LookAt X Coordinate | '' Y '' | '' Y '' | Duration 37 * "Rotate And Look" | ral | GoTo X Coordinate | '' Y '' | '' Z '' | Axis (1=x, 2=y, 3=z) | - | - | Duration 38 * "Spiral" | spi | GoTo X Coordinate | '' Y '' | '' Z '' | - | - | - | Duration 39 * "Transition Look" | chl | From X Coordinate | '' Y '' | '' Z '' | To X Coordinate | '' Y '' | '' Y '' | Duration 40 * "rotate round X crd"| rotX | anchor coordinate | angle(rad)| - | | | | Duration 40 41 * "Idle (Do nothing)" | idle | Duration 41 42 */ … … 46 47 #include "worldentities/ControllableEntity.h" 47 48 #include "core/LuaState.h" 48 #include "core/LuaState.h"49 49 #include "util/Math.h" 50 50 … … 90 90 /* Output some debugging information */ 91 91 orxout(verbose) << "ScriptController: Taking control" << endl; 92 orxout(verbose) << "This-pointer: " << this << endl; 92 orxout(verbose) << "This-pointer: " << this << endl; 93 93 94 94 /* Set the controller ID (the argument here should be nonzero) */ … … 103 103 */ 104 104 this->entity_->setDestroyWhenPlayerLeft(false); 105 this->player_-> pauseControl();105 this->player_->stopTemporaryControl(); 106 106 this->entity_->setController(this); 107 107 this->setControllableEntity(this->entity_); 108 this->entity_->mouseLook(); 109 this->entity_->setVisible(false); 108 //this->entity_->mouseLook(); 109 //this->entity_->setVisible(false); 110 111 // TODO take the human Controllers control dont forget to give it back in the destructor 110 112 } 111 113 … … 201 203 { 202 204 // Abbreviation for "spiral" (rotation + translation) 203 if (this->currentEvent.fctName == "spi") { 204 205 // Need to know a perpendicular basis to the translation vector: 205 if (this->currentEvent.fctName == "spi") 206 { 207 spi(dl); // call the external function 208 } 209 210 // Abbreviation for "rotate and look" 211 else if (this->currentEvent.fctName == "ral") 212 { 213 ral(dl); 214 } 215 else if( this->currentEvent.fctName == "mal" ) 216 { 217 mal(dl); 218 } 219 else if( this->currentEvent.fctName == "chl" ) 220 { 221 chl(dl); 222 } 223 224 225 /* Force mouse look */ 226 if( this->entity_->isInMouseLook() == false ) 227 this->entity_->mouseLook(); 228 } 229 } 230 231 void ScriptController::eventScheduler(std::string instruction, 232 float x1, float y1, float z1, 233 float x2, float y2, float z2, 234 float duration, float executionTime) 235 { 236 /* put data (from LUA) into time-sorted eventList*/ 237 /* Nimmt den befehl und die argumente aus luascript und ertellt einen 238 * struct pro event, diese structs werden sortiert nach eventTime 239 */ 240 struct event tmp; 241 242 /* Fill the structure with all the provided information */ 243 tmp.fctName = instruction; 244 245 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 246 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 247 tmp.v1 = Vector3(x1,y1,z1); 248 tmp.v2 = Vector3(x2,y2,z2); 249 250 // the parameters are not required to be vector coordinates! 251 // for convenience they are however stored twice if they have some kind of different meaning 252 tmp.a = x1; 253 tmp.b = y1; 254 tmp.c = z1; 255 tmp.d = x2; 256 tmp.e = y2; 257 tmp.f = z2; 258 259 tmp.duration = duration; 260 261 /* This is kind of a hack. If we hit the function idle all we want to do is 262 advance event execution time, not schedule anything */ 263 if (instruction == "idle") { 264 tmp.eventTime = this->prevEventTime; 265 this->prevEventTime += x1; 266 return; 267 } else { 268 tmp.eventTime = this->prevEventTime; 269 this->prevEventTime += duration; 270 } 271 272 /* Add the created event to the event list */ 273 if(eventList.size()==0) 274 { /* The list is still empty, just add it */ 275 orxout(verbose) << "eventList empty (01)" << endl; 276 eventList.insert(eventList.begin(), tmp); 277 this->eventno += 1; 278 return; /* Nothing more to do, the event was added */ 279 } 280 281 /* Event was not added yet since the list was not empty. Walk through 282 * the list of events and add it so that the events are correctly in 283 * order. 284 */ 285 for (std::vector<event>::iterator it=eventList.begin(); it<eventList.end(); it++) 286 { if(tmp.eventTime < it->eventTime) 287 { eventList.insert(it,tmp); 288 this->eventno += 1; 289 //orxout()<<"new event added"<<endl; 290 return; 291 } 292 } 293 294 /* If the event was still not added here, it belongs in the end of the list */ 295 eventList.insert(eventList.end(), tmp); 296 this->eventno += 1; 297 298 } 299 300 // Event Functions 301 302 void ScriptController::spi(float dl) 303 { 304 305 // Need to know a perpendicular basis to the translation vector: 206 306 // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm 207 307 // Currently we set a fix rotational radius of 400 … … 221 321 delete ortho1; 222 322 delete ortho2; 223 } 224 225 // Abbreviation for "rotate and look" 226 if (this->currentEvent.fctName == "ral")227 {323 324 } 325 326 void ScriptController::ral(float dl) 327 { 228 328 // Specify the axis 229 329 Vector3 a; … … 250 350 /* Look at the specified position */ 251 351 this->entity_->lookAt(this->currentEvent.v1); 252 } 253 else if( this->currentEvent.fctName == "mal" ) 254 { 352 353 } 354 355 void ScriptController::mal(float dl) 356 { 255 357 /* Set the position to the correct place in the trajectory */ 256 358 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1); … … 258 360 /* Look at the specified position */ 259 361 this->entity_->lookAt(this->currentEvent.v2); 260 } 261 else if( this->currentEvent.fctName == "chl" ) 262 { 362 363 } 364 365 void ScriptController::chl(float dl) 366 { 263 367 /* Sweep the look from v1 to v2 */ 264 368 this->entity_->lookAt( (1-dl)*this->currentEvent.v1 + 265 369 dl * this->currentEvent.v2 ); 266 } 267 268 269 /* Force mouse look */ 270 if( this->entity_->isInMouseLook() == false ) 271 this->entity_->mouseLook(); 272 } 273 } 274 275 void ScriptController::eventScheduler(std::string instruction, 276 float x1, float y1, float z1, 277 float x2, float y2, float z2, 278 float duration, float executionTime) 279 { 280 /* put data (from LUA) into time-sorted eventList*/ 281 /* Nimmt den befehl und die argumente aus luascript und ertellt einen 282 * struct pro event, diese structs werden sortiert nach eventTime 283 */ 284 struct event tmp; 285 286 /* Fill the structure with all the provided information */ 287 tmp.fctName = instruction; 288 289 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 290 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 291 tmp.v1 = Vector3(x1,y1,z1); 292 tmp.v2 = Vector3(x2,y2,z2); 293 294 // the parameters are not required to be vector coordinates! 295 // for convenience they are however stored twice if they have some kind of different meaning 296 tmp.a = x1; 297 tmp.b = y1; 298 tmp.c = z1; 299 tmp.d = x2; 300 tmp.e = y2; 301 tmp.f = z2; 302 303 tmp.duration = duration; 304 305 /* This is kind of a hack. If we hit the function idle all we want to do is 306 advance event execution time, not schedule anything */ 307 if (instruction == "idle") { 308 tmp.eventTime = this->prevEventTime; 309 this->prevEventTime += x1; 310 return; 311 } else { 312 tmp.eventTime = this->prevEventTime; 313 this->prevEventTime += duration; 314 } 315 316 /* Add the created event to the event list */ 317 if(eventList.size()==0) 318 { /* The list is still empty, just add it */ 319 orxout(verbose) << "eventList empty (01)" << endl; 320 eventList.insert(eventList.begin(), tmp); 321 this->eventno += 1; 322 return; /* Nothing more to do, the event was added */ 323 } 324 325 /* Event was not added yet since the list was not empty. Walk through 326 * the list of events and add it so that the events are correctly in 327 * order. 328 */ 329 for (std::vector<event>::iterator it=eventList.begin(); it<eventList.end(); it++) 330 { if(tmp.eventTime < it->eventTime) 331 { eventList.insert(it,tmp); 332 this->eventno += 1; 333 //orxout()<<"new event added"<<endl; 334 return; 335 } 336 } 337 338 /* If the event was still not added here, it belongs in the end of the list */ 339 eventList.insert(eventList.end(), tmp); 340 this->eventno += 1; 370 371 } 372 373 void ScriptController::rotX(float dl) 374 { 375 341 376 342 377 } -
code/branches/presentationFS16/src/orxonox/controllers/ScriptController.h
r11071 r11207 36 36 37 37 38 namespace orxonox // tolua_export39 { // tolua_export38 namespace orxonox 39 { 40 40 41 41 /** Structure to describe a single event */ … … 61 61 }; 62 62 63 class _OrxonoxExport ScriptController // tolua_export63 class _OrxonoxExport ScriptController 64 64 : public ArtificialController, public Tickable 65 { // tolua_export65 { 66 66 public: 67 67 ScriptController(Context* context); … … 73 73 virtual void tick(float dt) override; 74 74 75 // LUA interface 76 // tolua_begin 75 77 76 void eventScheduler(std::string instruction = "", 78 77 float x1 = 0, float y1 = 0, float z1 = 0, … … 84 83 int getID() { return ctrlid_; } 85 84 86 // tolua_end85 87 86 const Vector3& getPosition(); 88 87 … … 128 127 //Vector3 lookAtPosition; 129 128 130 };// tolua_export 131 } // tolua_export 129 130 /* private member functions */ 131 132 /*spiral event*/ 133 void spi(float dl); 134 135 /* rotate and look event */ 136 void ral(float dl); 137 138 /* move and look event */ 139 void mal(float dl); 140 141 /* transition look event */ 142 void chl(float dl); 143 144 /* rotate around x-coordinate event */ 145 void rotX(float dl); 146 147 }; 148 } 132 149 133 150 #endif /* _ScriptController_H__ */
Note: See TracChangeset
for help on using the changeset viewer.