Changeset 8967 for code/branches
- Timestamp:
- Dec 8, 2011, 5:01:18 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/formation/src/orxonox/controllers/Masterable.cc
r8965 r8967 344 344 } 345 345 346 void Masterable::copyOrientation(const Quaternion& orient) 347 { 348 //roll angle in radian, difference between master and slave 349 float diff=orient.getRoll().valueRadians()-(this->getControllableEntity()->getOrientation().getRoll().valueRadians()); 350 if ((diff<math::twoPi && diff>math::pi) || diff>(math::pi)*3) 351 { 352 diff=diff-math::twoPi; 353 } 354 this->getControllableEntity()->rotateRoll(1.0f*ROTATEFACTOR_MASTER*diff); 346 //copy the Roll orientation of given Quaternion. 347 void Masterable::copyOrientation(const Quaternion& orient) 348 { 349 //roll angle difference in radian 350 float diff=orient.getRoll(false).valueRadians()-(this->getControllableEntity()->getOrientation().getRoll(false).valueRadians()); 351 while(diff>math::twoPi) diff-=math::twoPi; 352 while(diff<-math::twoPi) diff+=math::twoPi; 353 this->getControllableEntity()->rotateRoll(diff*ROTATEFACTOR_MASTER); 355 354 } 356 355 357 356 void Masterable::copyTargetOrientation() 358 357 { 359 360 361 362 358 if (bHasTargetOrientation_) 359 { 360 copyOrientation(targetOrientation_); 361 } 363 362 } 364 363 … … 475 474 dest += 1.0f*orient*WorldEntity::BACK; 476 475 Vector3 pos = Vector3::ZERO; 477 bool left=true;476 bool left=true; 478 477 int i = 1; 479 478 … … 481 480 { 482 481 pos = Vector3::ZERO; 483 484 482 if (left) 483 { 485 484 pos+=dest+i*FORMATION_WIDTH*(orient*WorldEntity::LEFT); 486 } else 487 { 488 pos+=dest+i*FORMATION_WIDTH*(orient*WorldEntity::RIGHT); 489 i++; 490 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 491 } 492 (*it)->setTargetOrientation(orient); 485 } else{ 486 pos+=dest+i*FORMATION_WIDTH*(orient*WorldEntity::RIGHT); 487 i++; 488 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 489 } 490 (*it)->setTargetOrientation(orient); 493 491 (*it)->setTargetPosition(pos); 494 492 left=!left; 495 493 } 496 494 } … … 633 631 { 634 632 orxout(debug_output)<<"slaves, attack!"<<endl; 633 unsigned int i=0; 634 for(std::vector<Masterable*>::reverse_iterator it = slaves_.rbegin(); it != slaves_.rend(); it++) 635 { 636 if ((*it)->state_!=FREE) 637 { 638 (*it)->state_=FREE; 639 (*it)->forceFreedom(); 640 (*it)->target_=originator; 641 } 642 i++; 643 if (i==slaves_.size()/2) break; //half the formation should attack. 644 } 635 645 } 636 646 … … 846 856 void Masterable::setTargetOrientation(const Quaternion& orient) 847 857 { 848 849 858 this->targetOrientation_=orient; 859 this->bHasTargetOrientation_=true; 850 860 } 851 861 852 862 void Masterable::setTargetOrientation(Pawn* target) 853 863 { 854 855 864 if (target) 865 setTargetOrientation(target->getOrientation()); 856 866 } 857 867
Note: See TracChangeset
for help on using the changeset viewer.