- Timestamp:
- Oct 31, 2015, 12:20:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
r10725 r10729 34 34 35 35 RegisterClass(DivisionController); 36 static const float ACTION_INTERVAL = 1.0f;37 36 38 37 DivisionController::DivisionController(Context* context) : LeaderController(context) … … 45 44 this->myWingman_ = 0; 46 45 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this))); 46 47 /*Vector3* pos = new Vector3(500,500,-500); 48 this->setTargetPosition(*pos);*/ 47 49 48 50 } … … 54 56 void DivisionController::tick(float dt) 55 57 { 58 if (this->bHasTargetPosition_) 59 { 60 this->moveToTargetPosition(); 61 } 62 56 63 SUPER(DivisionController, tick, dt); 57 64 … … 59 66 void DivisionController::action() 60 67 { 61 /* setDesiredPositionOfFollower();62 set DesiredPositionOfWingman();*/68 setTargetPositionOfFollower(); 69 setTargetPositionOfWingman(); 63 70 } 64 71 … … 76 83 } 77 84 78 /* void DivisionController::setDesiredPositionOfWingman()85 void DivisionController::setTargetPositionOfWingman() 79 86 { 80 87 if (!this->myWingman_) 81 88 return; 82 89 Vector3* targetRelativePositionOfWingman; 83 90 switch (this->formationMode_){ 84 91 case WALL: 85 92 { 86 myWingman_->desiredRelativePosition_ = new Vector3 (200, 0, 0);93 targetRelativePositionOfWingman = new Vector3 (400, 0, 0); 87 94 break; 88 95 } … … 100 107 } 101 108 } 109 Quaternion orient = this->getControllableEntity()->getWorldOrientation(); 110 111 Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 112 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman))); 113 114 myWingman_->setTargetOrientation(orient); 115 myWingman_->setTargetPosition(targetAbsolutePositionOfWingman); 102 116 103 117 } 104 void DivisionController::set DesiredPositionOfFollower()118 void DivisionController::setTargetPositionOfFollower() 105 119 { 106 120 if (!this->myFollower_) 107 121 return; 108 122 Vector3* targetRelativePositionOfFollower; 109 123 switch (this->formationMode_){ 110 124 case WALL: 111 125 { 112 myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);126 targetRelativePositionOfFollower = new Vector3 (-400, 0, 0); 113 127 break; 114 128 } … … 126 140 } 127 141 } 142 Quaternion orient = this->getControllableEntity()->getWorldOrientation(); 143 144 Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) + 145 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower))); 146 147 myFollower_->setTargetOrientation(orient); 148 myFollower_->setTargetPosition(targetAbsolutePositionOfFollower); 128 149 129 } */150 } 130 151 void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode) 131 152 {
Note: See TracChangeset
for help on using the changeset viewer.