Changeset 10345 in orxonox.OLD for branches/playability/src/world_entities/projectiles/swarm_projectile.cc
- Timestamp:
- Jan 24, 2007, 6:13:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10271 r10345 62 62 //this->trail->setParent( this); 63 63 this->trail->setTexture( "maps/laser.png"); 64 65 66 this->origList = this->getOMListNumber(); 67 this->toList(OM_ENVIRON); 64 68 } 65 69 … … 190 194 this->deactivate(); 191 195 192 /*193 Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0);194 195 {196 speed = velocity.len();197 diffVector = ((targetFarFarAway - this->getAbsCoor()).getNormalized());198 199 if(velocity.dot(diffVector) != 0)200 {201 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;202 203 if( (diffVector * (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility )204 velocity = ((diffVector * (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;205 else if(velocity.dot(diffVector) > 0)206 velocity += correctionVector;207 else if (velocity.dot(diffVector) < 0)208 velocity -= correctionVector;209 }210 else211 velocity += diffVector * agility;212 213 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));214 }215 216 velocity *= maxVelocity/velocity.len();217 Vector v = this->velocity * (time);218 this->shiftCoor(v);*/219 196 220 197 … … 235 212 this->shiftCoor(this->velocity * time); 236 213 237 /*238 239 Vector pjV = this->getVelocity();240 Vector tV = this->target->getVelocity();241 Vector pT = this->target->getAbsCoor() - this->getAbsCoor(); // vector projectile target242 243 Vector a = tV.getNormalized() * pT.dot(tV.getNormalized());244 245 float A = 2 * pT.len() * pT.len();246 float B = 2 * a.len() * a.len();247 float D = 2 * sqrt(B * B - 4 * pT.len() * pT.len() *(tV.len() * tV.len() - pjV.len() * pjV.len()));248 float tti;249 250 if (A != 0){251 if ( B < D ) tti = ( B + D ) / A;252 else tti = ( B + D ) / A;253 }254 else tti = 0;255 256 257 Vector estTargetDir;258 if (tti == 0)259 estTargetDir = pT.getNormalized() * pjV.len();260 else261 estTargetDir = pT / tti + pjV;262 263 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time );264 265 this->shiftCoor(this->velocity * (this->maxVelocity * time));*/266 267 214 if(this->tickLifeCycle(time)) 268 215 this->deactivate(); … … 276 223 this->lastDir = this->curDir; 277 224 this->curDir = this->velocity; 278 if( (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3) // FIXME Temp fake workaround for collision :) 225 226 if( this->target != NULL && (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3) // FIXME Temp fake workaround for collision :) 279 227 { 280 dynamic_cast<WorldEntity*>(target)-> destroy(this);281 this->de stroy( this);228 dynamic_cast<WorldEntity*>(target)->hit(this->getDamage(), this); 229 this->deactivate(); 282 230 } 283 231 }
Note: See TracChangeset
for help on using the changeset viewer.