Changeset 9964 in orxonox.OLD for branches/playability/src/world_entities/projectiles/projectile.cc
- Timestamp:
- Nov 28, 2006, 11:43:26 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/projectile.cc
r9960 r9964 23 23 #include "model.h" 24 24 #include "sound/resource_sound_buffer.h" 25 26 #include <cmath> 25 27 26 28 #include "debug.h" … … 157 159 } 158 160 161 162 /** 163 * this function gets called by tick to calculate the new flight direction 164 * @param curDirection direction vector 165 * @param estTargetDir target vector, pointing to where the target will be on hit 166 * @param angle = tick * turningSpeed 167 * @return normalized (new) direction vector 168 */ 169 Vector Projectile::newDirection(Vector curDirection, Vector estTargetDir, float angle) 170 { 171 float tmp = angleDeg ( curDirection, estTargetDir); 172 if (tmp == 0) { return curDirection; } 173 174 if( angle > tmp ) { angle = tmp; } 175 176 //Vector n = curDirection.cross(estTargetDir); 177 //Vector d = n.cross(curDirection); 178 Vector d = curDirection.cross(estTargetDir).cross(curDirection); 179 d.normalize(); 180 if( angle == 90) { return d; } 181 182 Vector newDir = curDirection + d * curDirection.len() * tan (angle); 183 newDir.normalize(); 184 return newDir; 185 } 186 187 159 188 /** 160 189 * signal tick, time dependent things will be handled here … … 163 192 void Projectile::tick (float dt) 164 193 { 194 Vector estTargetDir = this->targetPosition + this->targetVelocity * this->eta; 195 //Vector estTargetDir = (this->target.getRelCoor() + this->target.getVelocity()) / this->velocity.len() ; 196 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * dt ) * this->velocity.len(); 165 197 Vector v = this->velocity * (dt); 166 198 this->shiftCoor(v); … … 179 211 this->soundSource.play(this->explosionBuffer); 180 212 } 213
Note: See TracChangeset
for help on using the changeset viewer.