Changeset 10087 in orxonox.OLD for branches/playability
- Timestamp:
- Dec 17, 2006, 9:48:31 PM (18 years ago)
- Location:
- branches/playability/src/world_entities/projectiles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10086 r10087 114 114 this->rotationSpeed = 360; 115 115 this->angle = 0; 116 117 this->curDir = this->lastDir = this->velocity; 116 118 } 117 119 … … 210 212 211 213 float projectileVelocity = this->getVelocity().len(); 212 //if (target != NULL){213 float tti; //Time To Impact 214 float targetVelocity = this->target->getVelocity().len();215 if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably216 tti = 1; // we do have a problem....217 else218 tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);214 if (target != NULL){ 215 /* float tti; //Time To Impact*/ 216 // float targetVelocity = this->target->getVelocity().len(); 217 // if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably 218 // tti = 1; // we do have a problem.... 219 // else 220 // tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity); 219 221 Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized() * maxVelocity; 220 // Vector estTargetDir = (this->target->getAbsCoor() - (Vector(2000, 30, 300) + VECTOR_RAND(20))).getNormalized() * projectileVelocity;221 222 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 222 //}223 //else224 //if (likely(projectileVelocity != 0))225 //this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max223 } 224 else 225 if (likely(projectileVelocity != 0)) 226 this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max 226 227 227 228 // printf("position: %f, %f, %f\n", this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z); … … 233 234 this->deactivate(); 234 235 235 this->updateAngle(time);236 237 236 this->trail->tick(time); 237 238 this->angle += this->rotationSpeed * time; 239 240 this->lastDir = this->curDir; 241 this->curDir = this->velocity; 238 242 } 239 243 … … 257 261 } 258 262 259 void SwarmProjectile::updateAngle(float time)260 {261 this->angle += this->rotationSpeed * time;262 }263 263 264 264 void SwarmProjectile::draw () const … … 267 267 glPushMatrix(); 268 268 269 Vector tmpDir = this->curDir *.5 + this->lastDir * .5; 270 269 271 float matrix[4][4]; 270 272 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 271 Vector tmpRot = this->getAbsCoor().cross(t his->velocity);272 glRotatef (angle Rad ( this->getAbsCoor(), this->velocity), tmpRot.x, tmpRot.y, tmpRot.z );273 Vector tmpRot = this->getAbsCoor().cross(tmpDir); 274 glRotatef (angleDeg ( this->getAbsCoor(), tmpDir), tmpRot.x, tmpRot.y, tmpRot.z ); 273 275 glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile 274 276 this->getAbsDir().matrix (matrix); -
branches/playability/src/world_entities/projectiles/swarm_projectile.h
r10081 r10087 48 48 Vector correctionVector; 49 49 50 Vector curDir; 51 Vector lastDir; 52 50 53 WorldEntity* hitEntity; // FIXME TEMPORARY 51 54 … … 53 56 54 57 // spinning missle 55 void updateAngle(float time);56 58 float rotationSpeed; 57 59 float angle;
Note: See TracChangeset
for help on using the changeset viewer.