Changeset 9964 in orxonox.OLD for branches/playability/src
- Timestamp:
- Nov 28, 2006, 11:43:26 PM (18 years ago)
- Location:
- branches/playability/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/lib/coord/p_node.h
r9869 r9964 98 98 inline const Vector& getRelCoor () const { return this->prevRelCoordinate; }; 99 99 /** @returns the Relative Coordinate Destination */ 100 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };100 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; }; 101 101 void setAbsCoor (const Vector& absCoord); 102 102 void setAbsCoor (float x, float y, float z); -
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 -
branches/playability/src/world_entities/projectiles/projectile.h
r9960 r9964 64 64 protected: 65 65 // energy 66 float energyMin;//!< The minimal Energy a Projectile needs to be emitted.67 bool bChargeable;//!< if the Projectile is Charegeable66 float energyMin; //!< The minimal Energy a Projectile needs to be emitted. 67 bool bChargeable; //!< if the Projectile is Charegeable 68 68 69 float lifeCycle;//!< The percentage of the Lifetime done [0-1]70 float lifeSpan;//!< The entire lifespan of the Shoot. in seconds69 float lifeCycle; //!< The percentage of the Lifetime done [0-1] 70 float lifeSpan; //!< The entire lifespan of the Shoot. in seconds 71 71 72 72 float physDamage; //!< damage to shield and armor 73 73 float elecDamage; //!< damage to elctronic 74 float turningSpeed; //!< degrees per tick 74 75 75 Vector flightDirection;//!< DOF direction in which the shoot flighs76 Vector flightDirection; //!< DOF direction in which the shoot flighs 76 77 77 Vector velocity;//!< velocity of the projectile.78 Vector velocity; //!< velocity of the projectile. 78 79 79 PNode* target; //!< A target for guided Weapons. 80 PNode* target; //!< A target for guided Weapons. 81 Vector targetPosition; //!< current target position relative to projectile 82 Vector targetVelocity; //!< current target speed and direction 83 float eta; //!< estimated time of arrival == time to kaboom! 80 84 81 85 OrxSound::SoundSource soundSource; … … 83 87 OrxSound::SoundBuffer explosionBuffer; 84 88 OrxSound::SoundBuffer engineBuffer; 89 90 virtual Vector newDirection(Vector curDirection, Vector estTargetDir, float angle); 85 91 }; 86 92
Note: See TracChangeset
for help on using the changeset viewer.