- Timestamp:
- May 10, 2010, 4:40:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/DroneController.cc
r6847 r6891 59 59 60 60 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this))); 61 62 this->owner_.setCallback(createFunctor(&DroneController::ownerDied, this)); 61 63 } 62 64 … … 83 85 const Vector3& dronePosition = getDrone()->getWorldPosition(); 84 86 85 const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*( dronePosition-ownerPosition); //Vector from Drone To Owner out of drones local coordinate system87 const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system 86 88 87 89 int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x) … … 90 92 91 93 if (distance > 500) { //TODO: variable implementation of maxdistance 92 drone_->moveUpDown( -locOwnerDir.y);93 drone_->moveFrontBack( locOwnerDir.z);94 drone_->moveRightLeft( -locOwnerDir.x);94 drone_->moveUpDown(locOwnerDir.y); 95 drone_->moveFrontBack(-locOwnerDir.z); 96 drone_->moveRightLeft(locOwnerDir.x); 95 97 } 96 98 99 100 random = rnd(maxrand); 101 if ( random < 30 && (!this->target_)) 102 this->searchNewTarget(); 103 104 105 this->aimAtTarget(); 106 drone_->fire(0); 107 108 109 110 111 //COUT(0) << "Drone: " << dronePosition << endl; 112 //COUT(0) << "Distance: " << distance << endl; 113 COUT(0) << "locDrone: " << locOwnerDir << endl; 114 COUT(0) << "target: " << targetPosition_ << endl; 97 115 COUT(0) << "Owner: " << ownerPosition << endl; 98 COUT(0) << "Drone: " << dronePosition << endl; 99 COUT(0) << "Distance: " << distance << endl; 100 COUT(0) << "locDrone: " << locOwnerDir << endl; 101 116 COUT(0) << "Rand: " << random << endl; 102 117 103 118 /* … … 160 175 setTargetPosition(this->getControllableEntity()->getPosition()); 161 176 162 /* myDrone->setRotationThrust(25);163 myDrone->setAuxilaryThrust(30);164 myDrone->rotateYaw(10*dt); */165 177 } 166 178 167 179 SUPER(AIController, tick, dt); 168 180 169 // you can use the following commands for steering 170 // - moveFrontBack, moveRightLeft, moveUpDown 171 // - rotatePitch, rotateYaw, rotateRoll 172 // - apply the to myDrone (e.g. myDrone->rotateYaw(..) ) 181 } 173 182 183 void DroneController::ownerDied() 184 { 185 if (this->drone_) 186 this->drone_->destroy(); 187 else 188 this->destroy(); 174 189 } 175 190 }
Note: See TracChangeset
for help on using the changeset viewer.