Changeset 10158 in orxonox.OLD for branches/ai/src/ai/ai_swarm.cc
- Timestamp:
- Jan 2, 2007, 9:47:28 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/ai/ai_swarm.cc
r10138 r10158 16 16 #include "ai_swarm.h" 17 17 #include "debug.h" 18 #include <stdio.h> 18 19 19 20 void AISwarm::process(float dt) 20 21 { 21 22 std::set<AIModule*>::iterator it; 22 it= swarmMembers.begin(); 23 Vector leaderPosition=(*it)->getPosition(); 24 (*it)->setDestination(destination); 25 (*it)->setEnemyList(enemyList); 26 (*it)->process(dt); 27 28 for (it++; it!= swarmMembers.end(); it++ ){ 29 (*it)->setDestination(leaderPosition); 23 Vector swarmPosition=this->getPosition(); 24 //std::cout << swarmPosition.x << " " << swarmPosition.z << "\n"; 25 26 float aMax=70.0f; 27 float vMax=1000.0f; 28 29 Vector correction=(destination-swarmPosition)-movement; 30 correction.y=0; 31 32 float correctionLen=correction.len(); 33 if(correctionLen>aMax*dt)correction=correction/correctionLen*aMax*dt; 34 35 //std::cout << angleRad(correction,movement) << "\n"; 36 movement+=correction; 37 38 float movementLen=movement.len(); 39 if(movementLen>vMax)movement=movement/movementLen*vMax; 40 41 42 for (it= swarmMembers.begin(); it!= swarmMembers.end(); it++ ){ 43 (*it)->setDestination(swarmPosition); 44 (*it)->setDestinationMovement(movement); 30 45 (*it)->setEnemyList(enemyList); 31 46 (*it)->process(dt);
Note: See TracChangeset
for help on using the changeset viewer.