Changeset 11152 for code/branches/plehmannFS16/src/orxonox/controllers
- Timestamp:
- Mar 24, 2016, 3:54:06 PM (9 years ago)
- Location:
- code/branches/plehmannFS16/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.cc
r11141 r11152 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 */ … … 90 91 /* Output some debugging information */ 91 92 orxout(verbose) << "ScriptController: Taking control" << endl; 92 orxout(verbose) << "This-pointer: " << this << endl; 93 orxout(verbose) << "This-pointer: " << this << endl; 93 94 94 95 /* Set the controller ID (the argument here should be nonzero) */ … … 103 104 */ 104 105 this->entity_->setDestroyWhenPlayerLeft(false); 105 // uncomment the next line because i just did that for debug 106 //this->player_->pauseControl(); 106 this->player_->stopTemporaryControl(); 107 107 this->entity_->setController(this); 108 108 this->setControllableEntity(this->entity_); 109 this->entity_->mouseLook();110 this->entity_->setVisible(false);109 //this->entity_->mouseLook(); 110 //this->entity_->setVisible(false); 111 111 112 112 // TODO take the human Controllers control dont forget to give it back in the destructor … … 204 204 { 205 205 // Abbreviation for "spiral" (rotation + translation) 206 if (this->currentEvent.fctName == "spi") { 207 208 // Need to know a perpendicular basis to the translation vector: 206 if (this->currentEvent.fctName == "spi") 207 { 208 spi(dl); // call the external function 209 } 210 211 // Abbreviation for "rotate and look" 212 else if (this->currentEvent.fctName == "ral") 213 { 214 ral(dl); 215 } 216 else if( this->currentEvent.fctName == "mal" ) 217 { 218 mal(dl); 219 } 220 else if( this->currentEvent.fctName == "chl" ) 221 { 222 chl(dl); 223 } 224 225 226 /* Force mouse look */ 227 if( this->entity_->isInMouseLook() == false ) 228 this->entity_->mouseLook(); 229 } 230 } 231 232 void ScriptController::eventScheduler(std::string instruction, 233 float x1, float y1, float z1, 234 float x2, float y2, float z2, 235 float duration, float executionTime) 236 { 237 /* put data (from LUA) into time-sorted eventList*/ 238 /* Nimmt den befehl und die argumente aus luascript und ertellt einen 239 * struct pro event, diese structs werden sortiert nach eventTime 240 */ 241 struct event tmp; 242 243 /* Fill the structure with all the provided information */ 244 tmp.fctName = instruction; 245 246 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 247 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 248 tmp.v1 = Vector3(x1,y1,z1); 249 tmp.v2 = Vector3(x2,y2,z2); 250 251 // the parameters are not required to be vector coordinates! 252 // for convenience they are however stored twice if they have some kind of different meaning 253 tmp.a = x1; 254 tmp.b = y1; 255 tmp.c = z1; 256 tmp.d = x2; 257 tmp.e = y2; 258 tmp.f = z2; 259 260 tmp.duration = duration; 261 262 /* This is kind of a hack. If we hit the function idle all we want to do is 263 advance event execution time, not schedule anything */ 264 if (instruction == "idle") { 265 tmp.eventTime = this->prevEventTime; 266 this->prevEventTime += x1; 267 return; 268 } else { 269 tmp.eventTime = this->prevEventTime; 270 this->prevEventTime += duration; 271 } 272 273 /* Add the created event to the event list */ 274 if(eventList.size()==0) 275 { /* The list is still empty, just add it */ 276 orxout(verbose) << "eventList empty (01)" << endl; 277 eventList.insert(eventList.begin(), tmp); 278 this->eventno += 1; 279 return; /* Nothing more to do, the event was added */ 280 } 281 282 /* Event was not added yet since the list was not empty. Walk through 283 * the list of events and add it so that the events are correctly in 284 * order. 285 */ 286 for (std::vector<event>::iterator it=eventList.begin(); it<eventList.end(); it++) 287 { if(tmp.eventTime < it->eventTime) 288 { eventList.insert(it,tmp); 289 this->eventno += 1; 290 //orxout()<<"new event added"<<endl; 291 return; 292 } 293 } 294 295 /* If the event was still not added here, it belongs in the end of the list */ 296 eventList.insert(eventList.end(), tmp); 297 this->eventno += 1; 298 299 } 300 301 // Event Functions 302 303 void ScriptController::spi(float dl) 304 { 305 306 // Need to know a perpendicular basis to the translation vector: 209 307 // Given (a, b, c) we chose (b, -a, 0)norm and (0, c, -b)norm 210 308 // Currently we set a fix rotational radius of 400 … … 224 322 delete ortho1; 225 323 delete ortho2; 226 } 227 228 // Abbreviation for "rotate and look" 229 if (this->currentEvent.fctName == "ral")230 {324 325 } 326 327 void ScriptController::ral(float dl) 328 { 231 329 // Specify the axis 232 330 Vector3 a; … … 253 351 /* Look at the specified position */ 254 352 this->entity_->lookAt(this->currentEvent.v1); 255 } 256 else if( this->currentEvent.fctName == "mal" ) 257 { 353 354 } 355 356 void ScriptController::mal(float dl) 357 { 258 358 /* Set the position to the correct place in the trajectory */ 259 359 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1); … … 261 361 /* Look at the specified position */ 262 362 this->entity_->lookAt(this->currentEvent.v2); 263 } 264 else if( this->currentEvent.fctName == "chl" ) 265 { 363 364 } 365 366 void ScriptController::chl(float dl) 367 { 266 368 /* Sweep the look from v1 to v2 */ 267 369 this->entity_->lookAt( (1-dl)*this->currentEvent.v1 + 268 370 dl * this->currentEvent.v2 ); 269 } 270 271 272 /* Force mouse look */ 273 if( this->entity_->isInMouseLook() == false ) 274 this->entity_->mouseLook(); 275 } 276 } 277 278 void ScriptController::eventScheduler(std::string instruction, 279 float x1, float y1, float z1, 280 float x2, float y2, float z2, 281 float duration, float executionTime) 282 { 283 /* put data (from LUA) into time-sorted eventList*/ 284 /* Nimmt den befehl und die argumente aus luascript und ertellt einen 285 * struct pro event, diese structs werden sortiert nach eventTime 286 */ 287 struct event tmp; 288 289 /* Fill the structure with all the provided information */ 290 tmp.fctName = instruction; 291 292 //tmp.x1 = x1; tmp.y1 = y1; tmp.z1 = z1; 293 //tmp.x2 = x2; tmp.y2 = y2; tmp.z2 = z2; 294 tmp.v1 = Vector3(x1,y1,z1); 295 tmp.v2 = Vector3(x2,y2,z2); 296 297 // the parameters are not required to be vector coordinates! 298 // for convenience they are however stored twice if they have some kind of different meaning 299 tmp.a = x1; 300 tmp.b = y1; 301 tmp.c = z1; 302 tmp.d = x2; 303 tmp.e = y2; 304 tmp.f = z2; 305 306 tmp.duration = duration; 307 308 /* This is kind of a hack. If we hit the function idle all we want to do is 309 advance event execution time, not schedule anything */ 310 if (instruction == "idle") { 311 tmp.eventTime = this->prevEventTime; 312 this->prevEventTime += x1; 313 return; 314 } else { 315 tmp.eventTime = this->prevEventTime; 316 this->prevEventTime += duration; 317 } 318 319 /* Add the created event to the event list */ 320 if(eventList.size()==0) 321 { /* The list is still empty, just add it */ 322 orxout(verbose) << "eventList empty (01)" << endl; 323 eventList.insert(eventList.begin(), tmp); 324 this->eventno += 1; 325 return; /* Nothing more to do, the event was added */ 326 } 327 328 /* Event was not added yet since the list was not empty. Walk through 329 * the list of events and add it so that the events are correctly in 330 * order. 331 */ 332 for (std::vector<event>::iterator it=eventList.begin(); it<eventList.end(); it++) 333 { if(tmp.eventTime < it->eventTime) 334 { eventList.insert(it,tmp); 335 this->eventno += 1; 336 //orxout()<<"new event added"<<endl; 337 return; 338 } 339 } 340 341 /* If the event was still not added here, it belongs in the end of the list */ 342 eventList.insert(eventList.end(), tmp); 343 this->eventno += 1; 371 372 } 373 374 void ScriptController::rotX(float dl) 375 { 376 344 377 345 378 } -
code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h
r11071 r11152 128 128 //Vector3 lookAtPosition; 129 129 130 131 /* private member functions */ 132 133 /*spiral event*/ 134 void spi(float dl); 135 136 /* rotate and look event */ 137 void ral(float dl); 138 139 /* move and look event */ 140 void mal(float dl); 141 142 /* transition look event */ 143 void chl(float dl); 144 145 /* rotate around x-coordinate event */ 146 void rotX(float dl); 147 130 148 };// tolua_export 131 149 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.