Changeset 10763
- Timestamp:
- Nov 3, 2015, 5:06:05 PM (9 years ago)
- Location:
- code/branches/AI_HS15/src/orxonox/controllers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
r10762 r10763 190 190 void CommonController::moveToPosition(const Vector3& target) 191 191 { 192 float factor = 1; 192 193 if (!this->getControllableEntity()) 193 194 return; 194 195 if (this->rank_ == Rank::DIVISIONLEADER) 195 SPEED *= 0.8;196 factor = 0.8; 196 197 if (this->rank_ == Rank::SECTIONLEADER) 197 SPEED *= 0.9;198 factor = 0.9; 198 199 199 200 //100 is (so far) the smallest tolerance (empirically found) that can be reached, … … 233 234 } 234 235 } 235 this->getControllableEntity()->moveFrontBack(1.2f*SPEED); 236 orxout (internal_error) << "MOVING" <<endl ; 237 238 this->getControllableEntity()->moveFrontBack(1.2f*SPEED*factor); 236 239 } 237 240 else … … 257 260 { 258 261 //check pointers 259 if (!this->getControllableEntity() || !this->target_ || !this->target_->getControllableEntity())262 if (!this->getControllableEntity() || !this->target_) 260 263 return false; 261 264 262 265 //check if this points in the direction of target_ 263 266 264 267 Vector3 myPosition = this->getControllableEntity()->getWorldPosition(); 265 Vector3 targetPosition = this->target_->get ControllableEntity()->getWorldPosition();268 Vector3 targetPosition = this->target_->getWorldPosition(); 266 269 Vector3 differenceVector = targetPosition - myPosition; 267 float scalarProduct = differenceVector * WorldEntity::FRONT;270 float scalarProduct = differenceVector.dotProduct(WorldEntity::FRONT); 268 271 Vector3 projection = scalarProduct * WorldEntity::FRONT; 269 272 if ((differenceVector - projection).length() > 50) … … 282 285 allyPosition = it->getControllableEntity()->getWorldPosition(); 283 286 allyDifference = allyPosition - myPosition; 284 allyScalarProduct = allyDifference * WorldEntity::FRONT;287 allyScalarProduct = allyDifference.dotProduct(WorldEntity::FRONT); 285 288 allyProjection = allyScalarProduct * WorldEntity::FRONT; 286 289 if (allyScalarProduct < 0 || allyScalarProduct > scalarProduct) … … 291 294 } 292 295 296 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 297 if (pawn) 298 pawn->setAimPosition(WorldEntity::FRONT); 299 293 300 return true; 294 301 -
code/branches/AI_HS15/src/orxonox/controllers/CommonController.h
r10762 r10763 109 109 110 110 void setTarget(ControllableEntity* target); 111 111 112 112 void setTargetOrientation(const Quaternion& orient); 113 113 void setTargetOrientation(ControllableEntity* target); -
code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
r10762 r10763 40 40 41 41 this->setFormationMode(FormationMode::DIAMOND); 42 42 this->target_ = 0; 43 43 this->myFollower_ = 0; 44 44 this->myWingman_ = 0; … … 46 46 this->rank_ = Rank::DIVISIONLEADER; 47 47 48 Vector3* pos = new Vector3(-4000,-1000,-2000);49 this->setTargetPosition(*pos);50 48 51 49 } … … 76 74 void DivisionController::action() 77 75 { 76 /* 77 Vector3* pos = new Vector3(4000,1000,2000); 78 this->setTargetPosition(*pos);*/ 79 78 80 setTargetPositionOfFollower(); 79 81 setTargetPositionOfWingman(); -
code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc
r10759 r10763 58 58 this->divisions_.clear(); 59 59 60 /*for (ObjectList<DivisionController>::iterator it = ObjectList<DivisionController>::begin(); it; ++it)60 for (ObjectList<DivisionController>::iterator it = ObjectList<DivisionController>::begin(); it; ++it) 61 61 { 62 62 if ((this->getControllableEntity()->getTeam() == (it)->getControllableEntity()->getTeam())) … … 65 65 } 66 66 } 67 /*for(std::vector<WeakPtr<DivisionController> >::iterator it2 = divisions_.begin(); it2 != divisions_.end(); ++it2) 68 { 69 (*it2)->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 70 }*/ 67 71 for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it) 68 72 { 69 if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()) && (it)->getControllableEntity()->getTeam() != 0)73 if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()) && (it)->getControllableEntity()->getTeam() == 0) 70 74 { 71 75 for(std::vector<WeakPtr<DivisionController> >::iterator it2 = divisions_.begin(); it2 != divisions_.end(); ++it2) { 72 76 (*it2)->setTarget(it->getControllableEntity()); 77 (*it2)->setTargetPosition(it->getControllableEntity()->getWorldPosition()); 73 78 } 74 79 break; 75 80 } 76 } */81 } 77 82 78 83 }
Note: See TracChangeset
for help on using the changeset viewer.