Changeset 9105
- Timestamp:
- Apr 20, 2012, 4:31:00 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/waypoints/src/orxonox/controllers/FormationController.cc
r9093 r9105 276 276 if(coord.x < 0.0001 && coord.y < 0.0001) 277 277 { 278 // I AM HERE279 Vector3 v_temp = this->getControllableEntity()->get Orientation();280 Quaternion quat = v_temp.getRotationTo(target) * v_temp;278 // if the ship reaches a direction very close to the direct one, set it to the direct one 279 Vector3 v_temp = this->getControllableEntity()->getPosition(); 280 Quaternion quat = v_temp.getRotationTo(target); 281 281 this->getControllableEntity()->rotate(quat); 282 283 //this->getControllableEntity()->setOrientation(this->getControllableEntity()->getPosition().getRotationTo(target) * this->getControllableEntity()->getOrientation());284 282 } 285 283 … … 318 316 319 317 if(this->state_ == SLAVE) 320 321 322 323 324 325 326 327 328 329 copyTargetOrientation();330 331 332 {//linear speed reduction333 334 335 336 337 338 339 340 318 { 319 320 this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2); 321 this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2); 322 323 if (distance < 300) 324 { 325 if (bHasTargetOrientation_) 326 { 327 copyTargetOrientation(); 328 } 329 if (distance < 100) 330 { //linear speed reduction 331 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 332 333 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 334 335 } else { 336 this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f); 337 } 338 } 341 339 342 340 if (distance < 10) … … 391 389 void FormationController::searchNewMaster() 392 390 { 393 if (this->state_==SLAVE) 391 if (this->state_==SLAVE) 394 392 return; 395 393 if (!this->getControllableEntity()) … … 402 400 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it) 403 401 { 404 402 405 403 //same team? 406 404 Gametype* gt=this->getGametype(); … … 487 485 bool left=true; 488 486 int i = 1; 489 487 490 488 for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++) 491 489 { … … 498 496 i++; 499 497 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 500 } 498 } 501 499 (*it)->setTargetOrientation(orient); 502 500 (*it)->setTargetPosition(pos); … … 607 605 608 606 if (this->state_==SLAVE) //become master of this formation 609 { 607 { 610 608 this->slaves_=this->myMaster_->slaves_; 611 609 this->myMaster_->slaves_.clear(); 612 610 this->myMaster_->state_=SLAVE; 613 611 this->myMaster_->myMaster_=this; 614 612 615 613 //delete myself in slavelist 616 614 std::vector<FormationController*>::iterator it2 = std::find(this->slaves_.begin(), this->slaves_.end(), this); … … 655 653 if (i>=slaves_.size()/2) break; //half the formation should attack. 656 654 } 657 } 655 } 658 656 659 657 … … 868 866 void FormationController::setTargetOrientation(const Quaternion& orient) 869 867 { 870 this->targetOrientation_=orient; 868 this->targetOrientation_=orient; 871 869 this->bHasTargetOrientation_=true; 872 870 }
Note: See TracChangeset
for help on using the changeset viewer.