Changeset 10946
- Timestamp:
- Dec 7, 2015, 4:06:37 PM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10935 r10946 113 113 this->moveToTargetPosition(dt); 114 114 } 115 if (!this || !this->getControllableEntity()) 116 return; 115 117 else if (this->bLookAtTarget_) 116 118 { … … 146 148 this->bDodge_ = true; 147 149 } 150 if (!this || !this->getControllableEntity()) 151 return; 148 152 if (ActionpointController::sTicks_ % 100 == step * this->actionpointControllerId_ + 1) 149 153 { … … 175 179 this->doFire(); 176 180 } 181 if (!this || !this->getControllableEntity()) 182 return; 177 183 this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp; 178 184 this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth(); … … 202 208 if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_) 203 209 { 210 if (!this || !this->getControllableEntity()) 211 return; 204 212 Point p = { Action::FIGHTALL, "", Vector3::ZERO, false }; 205 213 this->parsedActionpoints_.push_back (p); 206 214 } 215 if (!this || !this->getControllableEntity()) 216 return; 207 217 this->executeActionpoint(); 218 if (!this || !this->getControllableEntity()) 219 return; 208 220 this->bTakenOver_ = false; 209 221 } … … 220 232 if (newTarget) 221 233 { 234 if (!this || !this->getControllableEntity()) 235 return; 222 236 this->setAction (Action::FIGHTALL, newTarget); 223 237 } 224 238 else 225 239 { 240 if (!this || !this->getControllableEntity()) 241 return; 226 242 this->nextActionpoint(); 243 if (!this || !this->getControllableEntity()) 244 return; 227 245 this->executeActionpoint(); 228 246 … … 233 251 else if (this->action_ == Action::FIGHT) 234 252 { 235 236 253 if (!this->hasTarget() ) 237 254 { 238 255 //----find a target---- 239 ControllableEntity* newTarget = this->closestTarget(); 256 ControllableEntity* newTarget = this->closestTarget(); 257 if (!this || !this->getControllableEntity()) 258 return; 240 259 if (newTarget && 241 260 CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_) 242 261 { 262 if (!this || !this->getControllableEntity()) 263 return; 243 264 this->setAction (Action::FIGHT, newTarget); 244 265 } 245 266 else 246 267 { 268 if (!this || !this->getControllableEntity()) 269 return; 247 270 this->nextActionpoint(); 271 if (!this || !this->getControllableEntity()) 272 return; 248 273 this->executeActionpoint(); 249 274 } … … 257 282 { 258 283 ControllableEntity* newTarget = this->closestTarget(); 259 284 if (!this || !this->getControllableEntity()) 285 return; 260 286 if (newTarget && 261 287 CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_) 262 288 { 289 if (!this || !this->getControllableEntity()) 290 return; 263 291 this->setAction (Action::FIGHT, newTarget); 264 292 } 265 293 else 266 294 { 295 if (!this || !this->getControllableEntity()) 296 return; 267 297 this->nextActionpoint(); 298 if (!this || !this->getControllableEntity()) 299 return; 268 300 this->executeActionpoint(); 269 301 } … … 275 307 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 276 308 { 309 if (!this || !this->getControllableEntity()) 310 return; 277 311 this->nextActionpoint(); 312 if (!this || !this->getControllableEntity()) 313 return; 278 314 this->executeActionpoint(); 279 315 } … … 283 319 if (!this->getProtect()) 284 320 { 321 if (!this || !this->getControllableEntity()) 322 return; 285 323 this->nextActionpoint(); 324 if (!this || !this->getControllableEntity()) 325 return; 286 326 this->executeActionpoint(); 287 327 } 328 if (!this || !this->getControllableEntity()) 329 return; 288 330 this->stayNearProtect(); 289 331 } 290 332 else if (this->action_ == Action::ATTACK) 291 333 { 292 334 if (!this || !this->getControllableEntity()) 335 return; 293 336 if (!this->hasTarget()) 294 337 { 338 if (!this || !this->getControllableEntity()) 339 return; 295 340 this->nextActionpoint(); 341 if (!this || !this->getControllableEntity()) 342 return; 296 343 this->executeActionpoint(); 297 344 } … … 302 349 void ActionpointController::setProtect (ControllableEntity* protect) 303 350 { 351 304 352 this->protect_ = protect; 305 353 } 306 354 ControllableEntity* ActionpointController::getProtect () 307 355 { 356 308 357 return this->protect_; 309 358 } … … 401 450 void ActionpointController::setAction (Action::Value action, ControllableEntity* target) 402 451 { 452 if (!this || !this->getControllableEntity()) 453 return; 403 454 this->action_ = action; 404 455 if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK) … … 415 466 void ActionpointController::setAction (Action::Value action, const Vector3& target) 416 467 { 468 if (!this || !this->getControllableEntity()) 469 return; 417 470 this->action_ = action; 418 471 if (action == Action::FLY) … … 423 476 void ActionpointController::setAction (Action::Value action, const Vector3& target, const Quaternion& orient ) 424 477 { 478 if (!this || !this->getControllableEntity()) 479 return; 425 480 this->action_ = action; 426 481 if (action == Action::FLY) … … 466 521 return; 467 522 } 523 if (!this || !this->getControllableEntity()) 524 return; 468 525 if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop) 469 526 { 470 527 //MOVES all points that are in loop to a loop vector 471 528 this->fillLoop(); 529 if (!this || !this->getControllableEntity()) 530 return; 472 531 this->bLoop_ = true; 473 532 executeActionpoint(); 474 533 return; 475 534 } 535 if (!this || !this->getControllableEntity()) 536 return; 476 537 this->setAction (p.action); 477 538 if (!this || !this->getControllableEntity()) … … 487 548 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 488 549 { 550 if (!this || !this->getControllableEntity()) 551 return; 489 552 if (CommonController::getName(*itP) == targetName) 490 553 { … … 497 560 { 498 561 this->setTargetPosition( p.position ); 562 if (!this || !this->getControllableEntity()) 563 return; 499 564 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 500 565 { 566 if (!this || !this->getControllableEntity()) 567 return; 501 568 this->nextActionpoint(); 569 if (!this || !this->getControllableEntity()) 570 return; 502 571 this->executeActionpoint(); 503 572 } … … 553 622 if (CommonController::getName(*itP) == targetName) 554 623 { 624 if (!this || !this->getControllableEntity()) 625 return; 555 626 this->setTarget (static_cast<ControllableEntity*>(*itP)); 556 627 } … … 559 630 { 560 631 this->nextActionpoint(); 632 if (!this || !this->getControllableEntity()) 633 return; 561 634 this->executeActionpoint(); 562 635 } … … 648 721 void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b) 649 722 { 650 this->parsedActionpoints_ = vector; 651 this->loopActionpoints_ = loop; 652 this->bLoop_ = b; 653 this->bTakenOver_ = true; 723 if (!this || !this->getControllableEntity()) 724 return; 725 this->parsedActionpoints_ = vector; 726 if (!this || !this->getControllableEntity()) 727 return; 728 this->loopActionpoints_ = loop; 729 this->bLoop_ = b; 730 this->bTakenOver_ = true; 654 731 } 655 732 void ActionpointController::setClosestTarget() … … 667 744 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 668 745 { 746 if (!this || !this->getControllableEntity()) 747 return 0; 669 748 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) ) 670 749 continue; … … 692 771 if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_)) 693 772 { 773 if (!this || !this->getControllableEntity()) 774 return; 694 775 Pawn* newTarget = this->closestTarget(); 695 776 if ( newTarget && -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
r10935 r10946 246 246 bool bDefaultPatrol_; 247 247 bool stop_; 248 static unsigned int sTicks_; 249 //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action()248 static unsigned int sTicks_; //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep 249 //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action() 250 250 static unsigned int nextActionpointControllerId_; //<! if level has 16 ActionpointControllers, than this variable equals to 17 after first tick 251 251 unsigned int actionpointControllerId_; //<! integer from 0 to nextActionpointControllerId_, different for every ActionpointController in level 252 unsigned int ticks_; //<! local tick counter 253 254 255 private: 256 252 unsigned int ticks_; //<! local tick counter 257 253 }; 258 254 } -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10885 r10946 9 9 * modify it under the terms of the GNU General Public License 10 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or ( at your option)any later version.11 * of the License, or (at your option)any later version. 12 12 * 13 13 * This program is distributed in the hope that it will be useful, … … 28 28 #include "controllers/CommonController.h" 29 29 30 // stuff for sameTeam function30 //here starts stuff for sameTeam function copied from FormationController 31 31 #include "gametypes/TeamDeathmatch.h" 32 32 #include "gametypes/Gametype.h" … … 39 39 { 40 40 41 RegisterClass( CommonController);42 43 CommonController::CommonController( Context* context ): Controller( context)44 { 45 RegisterObject( CommonController);41 RegisterClass(CommonController); 42 43 CommonController::CommonController(Context* context): Controller(context) 44 { 45 RegisterObject(CommonController); 46 46 } 47 47 CommonController::~CommonController() 48 48 { 49 50 } 51 52 float CommonController::randomInRange( float a, float b ) 49 //no member variables - nothing to destroy 50 } 51 /** 52 @brief 53 PRE: a < b. 54 returns random float between a and b. 55 */ 56 float CommonController::randomInRange(float a, float b) 53 57 { 54 58 return a + rnd(1.0f) * (b - a); 55 59 } 56 float CommonController::distance (ControllableEntity* entity1, ControllableEntity* entity2) 60 /** 61 @brief 62 returns distance between two entities, if either is zero pointer, returns infinity 63 */ 64 float CommonController::distance (const ControllableEntity* entity1, const ControllableEntity* entity2) 57 65 { 58 66 if (!entity1 || !entity2) 59 67 return std::numeric_limits<float>::infinity(); 60 return ( entity1->getPosition() - entity2->getPosition() ).length(); 61 } 68 return (entity1->getPosition() - entity2->getPosition()).length(); 69 } 70 /** 71 @brief 72 bad function from FormationController that returns true if both entities have same team 73 */ 62 74 bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 63 75 { 76 //uncomment following code if functions stops working due to being a hack 64 77 /*if (!entity1 || !entity2) 65 78 return false; 66 79 return entity1->getTeam() == entity2->getTeam();*/ 80 if (!entity1 || !entity2) 81 return false; 67 82 if (entity1 == entity2) 68 83 return true; … … 161 176 team2 = dynamic->getParty(entity2->getPlayer()); 162 177 163 if (team1 ==-1 ||team2 ==-1 178 if (team1 ==-1 ||team2 ==-1) {return false;} 164 179 else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;} 165 180 else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;} … … 170 185 return (team1 == team2 && team1 != -1); 171 186 } 172 bool CommonController::isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) 173 { 174 if ( !entityThatLooks || !entityBeingLookedAt ) 187 /** 188 @brief 189 returns true if entityThatLooks does look at entityBeingLookeAt with a tolerance of angle. 190 */ 191 bool CommonController::isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle) 192 { 193 if (!entityThatLooks || !entityBeingLookedAt) 175 194 return false; 176 return ( getAngle(entityThatLooks ->getPosition() ,195 return (getAngle(entityThatLooks ->getPosition() , 177 196 entityThatLooks->getOrientation() * WorldEntity::FRONT, 178 entityBeingLookedAt->getWorldPosition() ) < angle ); 179 } 180 std::string CommonController::getName(Pawn* entity) 197 entityBeingLookedAt->getWorldPosition()) < angle); 198 } 199 /** 200 @brief 201 returns a name of a Pawn entity, if no name set, returns string representing address of the Pawn. 202 */ 203 std::string CommonController::getName(const Pawn* entity) 181 204 { 182 205 std::string name = entity->getName(); -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10885 r10946 31 31 32 32 33 #include "controllers/Controller.h" 34 #include <limits> 33 #include "controllers/Controller.h" //that's what I inherit from 35 34 36 #include "worldentities/ControllableEntity.h" 37 #include "worldentities/pawns/Pawn.h" 35 #include <limits> //I use limits pretty much in every class, so might as well include it in the parent class 36 37 #include "worldentities/ControllableEntity.h" //same for ControllableEntity 38 #include "worldentities/pawns/Pawn.h" //and Pawn 38 39 39 40 … … 44 45 45 46 public: 46 static const float ACTION_INTERVAL = 1.0f; 47 48 static const float hardcoded_projectile_speed = 750; 47 static const float hardcoded_projectile_speed = 750; //<! FightingController uses it to predict enemy position 49 48 50 49 CommonController(Context* context); … … 52 51 53 52 static float randomInRange(float a, float b); 54 static float distance( ControllableEntity* entity1,ControllableEntity* entity2);53 static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2); 55 54 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt); 56 static bool isLooking( ControllableEntity* entityThatLooks,ControllableEntity* entityBeingLookedAt, float angle ) ;57 static std::string getName( Pawn* entity ) ;55 static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle ) ; 56 static std::string getName(const Pawn* entity ) ; 58 57 }; 59 58 } -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10935 r10946 70 70 void DivisionController::action() 71 71 { 72 if (!this || !this->getControllableEntity() )72 if (!this || !this->getControllableEntity() || !this->isActive()) 73 73 return; 74 74 -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
r10923 r10946 9 9 * modify it under the terms of the GNU General Public License 10 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or ( at your option)any later version.11 * of the License, or (at your option)any later version. 12 12 * 13 13 * This program is distributed in the hope that it will be useful, … … 27 27 * 28 28 */ 29 #include <OgreMatrix3.h> //for Quaternion manipulations 30 31 #include "util/Math.h" 32 #include "core/XMLPort.h" 29 33 #include "controllers/FlyingController.h" 30 #include "core/XMLPort.h" 31 #include "worldentities/pawns/SpaceShip.h" 32 #include "util/Math.h" 33 #include <OgreMatrix3.h> 34 35 #include "worldentities/pawns/SpaceShip.h" //for boosting 34 36 35 37 namespace orxonox … … 60 62 FormationMode::Value value; 61 63 62 if ( valUpper == "WALL")64 if (valUpper == "WALL") 63 65 value = FormationMode::WALL; 64 else if ( valUpper == "FINGER4")66 else if (valUpper == "FINGER4") 65 67 value = FormationMode::FINGER4; 66 else if ( valUpper == "DIAMOND")68 else if (valUpper == "DIAMOND") 67 69 value = FormationMode::DIAMOND; 68 70 else 69 ThrowException(ParseError, std::string( "Attempting to set an unknown FormationMode: '")+ val + "'.");71 ThrowException(ParseError, std::string("Attempting to set an unknown FormationMode: '")+ val + "'."); 70 72 this->setFormationMode(value); 71 73 } 72 74 std::string FlyingController::getFormationModeXML() const 73 75 { 74 switch ( this->formationMode_)76 switch (this->formationMode_) 75 77 { 76 78 case FormationMode::WALL: … … 88 90 this->bHasTargetPosition_ = false; 89 91 } 92 /** 93 @brief 94 if distance to targetPosition is smaller than this->tolerance_, no moving should be made, otherwise 95 find amount of yaw and pitch that have to be applied, so that ship looks at targetPosition, then 96 ship is moved forward towards targetPosition. Also target orientation is being applied. 97 */ 90 98 void FlyingController::moveToPosition(const Vector3& targetPosition, float dt) 91 99 { … … 94 102 ControllableEntity* entity = this->getControllableEntity(); 95 103 96 float distance = ( targetPosition - entity->getPosition() ).length(); 97 98 if ( distance >= this->tolerance_ ) 99 { 104 float distance = (targetPosition - entity->getPosition()).length(); 105 106 if (distance >= this->tolerance_) 107 { 108 //function that calculates how much yaw and pitch are to be applied 100 109 Vector2 coord = get2DViewCoordinates 101 ( 110 (entity->getPosition() , 102 111 entity->getOrientation() * WorldEntity::FRONT, 103 112 entity->getOrientation() * WorldEntity::UP, 104 targetPosition ); 105 float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f ); 106 float rotateY = clamp( coord.y * 10, -1.0f, 1.0f ); 107 entity->rotateYaw( ROTATEFACTOR * rotateX * dt ); 108 entity->rotatePitch( ROTATEFACTOR * rotateY * dt ); 109 113 targetPosition); 114 //limit yaw and pitch by [-1,1] 115 float rotateX = -clamp(coord.x * 10, -1.0f, 1.0f); 116 float rotateY = clamp(coord.y * 10, -1.0f, 1.0f); 117 118 if (!entity) 119 return; 120 121 //apply yaw and pitch 122 entity->rotateYaw(ROTATEFACTOR * rotateX * dt); 123 entity->rotatePitch(ROTATEFACTOR * rotateY * dt); 124 125 if (!entity) 126 return; 127 128 //only move either if ship looks at target with a certain tolerance, or if ship is far enough for it to be ok to move in a curve. 110 129 if (distance > this->tolerance_*1.5f || (rotateX > -0.03 && rotateX < 0.03 && rotateY > -0.03 && rotateY < 0.03)) 111 entity->moveFrontBack( SPEED * dt ); 112 copyTargetOrientation(dt); 130 entity->moveFrontBack(SPEED * dt); 131 //roll 132 copyTargetOrientation(dt); 113 133 } 114 134 else … … 117 137 } 118 138 } 119 139 /** 140 @brief 141 fly towards a preset targetPosition_ 142 */ 120 143 void FlyingController::moveToTargetPosition(float dt) 121 144 { 122 145 this->moveToPosition (this->targetPosition_, dt); 123 146 } 147 /** 148 @brief 149 roll ship so that it has same roll as orient 150 */ 124 151 void FlyingController::copyOrientation(const Quaternion& orient, float dt) 125 152 { … … 155 182 } 156 183 } 157 184 /** 185 @brief 186 roll ship so that it has same roll as a preset targetOrientation_ 187 */ 158 188 void FlyingController::copyTargetOrientation(float dt) 159 189 { … … 163 193 } 164 194 } 165 195 /** 196 @brief 197 set Vector to fly to 198 */ 166 199 void FlyingController::setTargetPosition(const Vector3& target) 167 200 { … … 169 202 this->bHasTargetPosition_ = true; 170 203 } 171 204 /** 205 @brief 206 set orientation to apply 207 */ 172 208 void FlyingController::setTargetOrientation(const Quaternion& orient) 173 209 { … … 175 211 this->bHasTargetOrientation_=true; 176 212 } 177 213 /** 214 @brief 215 set orientation to apply 216 */ 178 217 void FlyingController::setTargetOrientation(ControllableEntity* target) 179 218 { … … 181 220 this->setTargetOrientation(target->getOrientation()); 182 221 } 222 /** 223 @brief 224 boost if you can 225 */ 183 226 void FlyingController::boostControl() 184 227 { … … 187 230 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 188 231 if(ship == NULL) return; 189 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() 232 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower()) //upper limit ->boost 190 233 { 191 234 this->getControllableEntity()->boost(true); … … 196 239 } 197 240 } 241 /** 242 @brief 243 keep this ship in a formation with its division 244 */ 198 245 void FlyingController::keepFormation(const ControllableEntity* leaderEntity, Vector3& targetRelativePosition) 199 246 { 247 if (!this->getControllableEntity()) 248 return; 200 249 ControllableEntity* myEntity = this->getControllableEntity(); 201 250 Vector3 myPosition = myEntity->getWorldPosition(); … … 212 261 return; 213 262 } 263 //calculate where in world coordinates this ship should fly 214 264 Vector3 targetAbsolutePosition = 215 265 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 216 266 + (orient* (targetRelativePosition))); 217 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.267 //let ship finish rotating. also don't call copyOrientation too often as it is a slow function. Don't know how to do it different 218 268 if (static_cast<int>(rnd(1.0f) * 100) % 3 == 0) 219 269 this->setTargetOrientation (orient); 270 //set a position to fly to 220 271 this->setTargetPosition (targetAbsolutePosition); 272 273 //boost if too far 221 274 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 222 275 { … … 225 278 else 226 279 { 227 this->getControllableEntity()->boost(false); 280 if (!this->getControllableEntity()) 281 return; 282 this->getControllableEntity()->boost(false); 228 283 } 229 284 } -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
r10923 r10946 39 39 FlyingController stores all the flying methods and member variables of AI. 40 40 */ 41 42 //Formation mode for the divisions 41 43 namespace FormationMode 42 44 { … … 51 53 52 54 public: 53 static const float SPEED = 0.9f/0.02f; 54 static const float ROTATEFACTOR = 0.6f/0.02f; 55 static const float SPEED = 0.9f/0.02f; //<! ship's speed 56 static const float ROTATEFACTOR = 0.6f/0.02f; //<! ship's rotation factor 55 57 56 58 FlyingController(Context* context); … … 58 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 59 61 60 void setSpread (int spread) 62 void setSpread (int spread) //<! spread is a multiplier for formation flight, should be bigger than 100 61 63 { this->spread_ = spread; } 62 int getSpread () const 64 int getSpread () const 63 65 { return this->spread_; } 64 66 … … 72 74 73 75 protected: 74 void stopMoving(); 76 void stopMoving(); //<! don't call moveToTargetPosition() in tick, call lookAtTarget() from FightingController instead 75 77 76 void moveToPosition(const Vector3& target, float dt); 77 void moveToTargetPosition(float dt); 78 void moveToPosition(const Vector3& target, float dt); //<! move towards a vector 79 void moveToTargetPosition(float dt); //<! move to the preset position. Don't mix with positionOfTarget! 78 80 79 void copyOrientation(const Quaternion& orient, float dt); 80 void copyTargetOrientation(float dt); 81 void copyOrientation(const Quaternion& orient, float dt); //<! roll to have same roll as orient 82 void copyTargetOrientation(float dt); //<! roll to have a preset orient 81 83 82 void setTargetPosition(const Vector3& target); 83 void setTargetOrientation(const Quaternion& orient); 84 void setTargetOrientation(ControllableEntity* target); 85 virtual void boostControl(); 86 void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition); 84 void setTargetPosition(const Vector3& target); //<! preset a Vector to fly to 85 void setTargetOrientation(const Quaternion& orient); //<! preset a desired orientation 86 void setTargetOrientation(ControllableEntity* target); //<! preset a desired orientation 87 virtual void boostControl(); //<! boost if you can 88 void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition); //<! preset targetPosition, so that 89 //<! this stays in a certain position relative to leader 87 90 88 91 FormationMode::Value formationMode_; 89 92 90 float rotationProgress_; //<! for slerp 93 float rotationProgress_; //<! for slerping 91 94 bool bHasTargetPosition_; 92 Vector3 targetPosition_; 95 Vector3 targetPosition_; //<! vector to fly to 93 96 bool bHasTargetOrientation_; 94 Quaternion targetOrientation_; 95 int spread_; 96 int tolerance_; 97 Quaternion targetOrientation_; //<! orientation to take 98 int spread_; //<! spread is a multiplier for formation flight, should be bigger than 100 99 int tolerance_; //<! if this ship is tolerance_ away from targetPosition_, ship decides that it finished moving 97 100 }; 98 101 } -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10935 r10946 73 73 void SectionController::action() 74 74 { 75 if (!this || !this->getControllableEntity() )75 if (!this || !this->getControllableEntity() || !this->isActive()) 76 76 return; 77 77 -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10935 r10946 73 73 void WingmanController::action() 74 74 { 75 if (!this || !this->getControllableEntity() )75 if (!this || !this->getControllableEntity() || !this->isActive()) 76 76 return; 77 77 //----If no leader, find one----
Note: See TracChangeset
for help on using the changeset viewer.