Changeset 10035 in orxonox.OLD for branches/playability/src/world_entities/projectiles/swarm_projectile.cc
- Timestamp:
- Dec 9, 2006, 7:00:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10004 r10035 37 37 { 38 38 39 this->loadModel("models/projectiles/orx-rocket.obj", 0.5); 39 /* this->loadModel("models/projectiles/orx-rocket.obj", 0.5);*/ 40 this->loadModel("models/projectiles/swarm_projectile.obj"); 40 41 this->loadExplosionSound("sound/explosions/explosion_4.wav"); 41 42 … … 45 46 this->lifeSpan = 2.0; 46 47 this->agility = 3.5; 47 this->maxVelocity = 1 50;48 this->maxVelocity = 100; 48 49 49 50 this->emitter = new DotEmitter(100, 5, M_2_PI); … … 141 142 } 142 143 144 145 146 /** 147 * this function gets called by tick to calculate the new flight direction 148 * @param curDirection direction vector 149 * @param estTargetDir target vector, pointing to where the target will be on hit 150 * @param angle = tick * turningSpeed 151 * @return (new) direction vector 152 */ 153 Vector SwarmProjectile::newDirection(Vector curDirection, Vector estTargetDir, float angle) 154 { 155 printf("recalculating direction\n"); 156 float tmp = angleDeg ( curDirection, estTargetDir); 157 if ( unlikely(tmp == 0) ) { return curDirection * maxVelocity / curDirection.len(); } 158 159 if( fabsf(angle) > fabsf(tmp) ) { angle = tmp; } 160 161 Vector d = curDirection.cross(estTargetDir).cross(curDirection); 162 d.normalize(); 163 if( unlikely( angle == 90)) { return d; } //avoid complication 164 165 Vector newDir = curDirection + d * curDirection.len() * tan (angle); 166 newDir.normalize(); 167 newDir *= curDirection.len(); 168 return newDir; 169 } 170 171 172 173 143 174 /** 144 175 * signal tick, time dependent things will be handled here … … 147 178 void SwarmProjectile::tick (float time) 148 179 { 149 180 /* 150 181 Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0); 151 182 … … 173 204 velocity *= maxVelocity/velocity.len(); 174 205 Vector v = this->velocity * (time); 175 this->shiftCoor(v); 206 this->shiftCoor(v);*/ 207 208 if (target != NULL){ 209 float tti = this->target->getRelCoor().len() / this->getVelocity().len(); 210 Vector estTargetDir = (this->target->getRelCoor() + this->target->getVelocity()) * tti; 211 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 212 } 213 else 214 velocity *= maxVelocity / velocity.len(); // set speed to max 215 216 this->shiftCoor(velocity * time); 176 217 177 218 if(this->tickLifeCycle(time)) … … 208 249 this->getAbsDir().matrix (matrix); 209 250 glMultMatrixf((float*)matrix); 210 glScalef(2.0, 2.0, 2.0);251 //glScalef(2.0, 2.0, 2.0); 211 252 this->getModel()->draw(); 212 253
Note: See TracChangeset
for help on using the changeset viewer.