Changeset 10153 in orxonox.OLD
- Timestamp:
- Dec 28, 2006, 11:44:44 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10132 r10153 216 216 this->shiftCoor(v);*/ 217 217 218 219 /** old guiding functuion*/ 220 218 221 float projectileVelocity = this->getVelocity().len(); 219 222 if (target != NULL){ 220 /* float tti; //Time To Impact*/221 // float targetVelocity = this->target->getVelocity().len();222 // if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably223 // tti = 1; // we do have a problem....224 // else225 // tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);226 223 Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); 227 // estTargetDir.slerpTo(this->velocity, 1);228 224 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 229 225 } … … 235 231 // printf("target position: %f, %f, %f\n", this->target->getAbsCoor().x, this->target->getAbsCoor().y, this->target->getAbsCoor().z); 236 232 237 this->shiftCoor(this->velocity * (time)); 233 this->shiftCoor(this->velocity * time); 234 235 236 /* 237 Vector pjV = this->getVelocity(); 238 Vector tV = this->target->getVelocity(); 239 Vector pT = this->target->getAbsCoor() - this->getAbsCoor(); // vector projectile target 240 241 Vector a = tV.getNormalized() * pT.dot(tV.getNormalized()); 242 243 float A = 2 * pT.len() * pT.len(); 244 float B = 2 * a.len() * tV.len(); 245 float D = 2 * sqrt(B * B - 4 * pT.len() * pT.len() *(tV.len() * tV.len() - pjV.len() * pjV.len())); 246 float tti; 247 248 if (A != 0){ 249 if ( B < D ) tti = ( B + D ) / A; 250 else tti = ( B + D ) / A; 251 } 252 else tti = 0; 253 254 255 Vector estTargetDir; 256 if (tti == 0) 257 estTargetDir = pT.getNormalized() * pjV.len(); 258 else 259 estTargetDir = pT / tti + pjV; 260 261 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 262 263 this->shiftCoor(this->velocity * (this->maxVelocity * time));*/ 238 264 239 265 if(this->tickLifeCycle(time)) … … 246 272 this->lastDir = this->curDir; 247 273 this->curDir = this->velocity; 274 /* 248 275 if( (this->getAbsCoor() - this->target->getAbsCoor()).len() < 3) // FIXME Temp fake workaround for collision :) 249 276 { 250 277 dynamic_cast<WorldEntity*>(target)->destroy( this); 251 278 this->destroy( this); 252 } 279 }*/ 253 280 } 254 281
Note: See TracChangeset
for help on using the changeset viewer.