Changeset 3746 in orxonox.OLD for orxonox/branches/levelloader/src/world_entities/projectile.cc
- Timestamp:
- Apr 7, 2005, 3:54:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/world_entities/projectile.cc
r3605 r3746 18 18 19 19 #include "projectile.h" 20 #include "stdincl.h" 20 21 21 #include "world_entity.h" 22 #include "weapon.h" 23 #include "null_parent.h" 24 #include "model.h" 22 25 #include "vector.h" 23 #include "objModel.h"24 26 25 27 using namespace std; … … 29 31 \brief standard constructor 30 32 */ 31 Projectile::Projectile ( ) : WorldEntity()33 Projectile::Projectile (Weapon* weapon) : WorldEntity() 32 34 { 33 this->model = new OBJModel(""); 35 this->model = (Model*)ResourceManager::getInstance()->load("sphere", PRIM, RP_LEVEL); 36 this->weapon = weapon; 37 this->flightDirection = NULL; 38 this->currentLifeTime = 0.0f; 39 this->ttl = 0.75f; /* sec */ 40 this->speed = 2.0f; 34 41 } 35 42 … … 40 47 Projectile::~Projectile () 41 48 { 42 49 /* 50 do not delete the test projectModel, since it is pnode 51 and will be cleaned out by world 52 */ 53 //delete this->projectileModel; 43 54 } 44 55 56 57 /** 58 \brief this sets the flight direction of the projectile 59 \param directin in which to flight 60 61 this function will calculate a vector out of this to be used in the 62 tick function 63 */ 64 void Projectile::setFlightDirection(Quaternion flightDirection) 65 { 66 if( this->flightDirection == NULL) 67 this->flightDirection = new Vector(); 68 Vector v(1, 0, 0); 69 *this->flightDirection = flightDirection.apply(v); 70 this->flightDirection->normalize(); 71 } 72 73 74 /** 75 \brief this sets the time to life of the projectile 76 \param ttl in second 77 78 after this life time, the projectile will garbage collect itself 79 */ 80 void Projectile::setTTL(float ttl) 81 { 82 this->ttl = ttl; 83 } 84 85 86 /** 87 \brief sets the speed of the projectile 88 */ 89 void Projectile::setSpeed(float speed) 90 { 91 this->speed = speed * 3; /* fix speed settings */ 92 PRINTF(4)("Projectile::setting speed to: %f\n", this->speed); 93 } 45 94 46 95 /** … … 49 98 */ 50 99 void Projectile::tick (float time) 51 {} 100 { 101 Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.7); 102 this->shiftCoor(v); 103 104 this->currentLifeTime += time; 105 if( this->ttl < this->currentLifeTime) 106 { 107 PRINTF(5)("FINALIZE==========================\n"); 108 PRINTF(5)("current life time is: %f/%f\n", this->currentLifeTime, this->ttl); 109 PRINTF(5)("FINALIZE===========================\n"); 110 this->finalize(); 111 this->currentLifeTime = 0.0f; 112 } 113 } 52 114 53 115 /**
Note: See TracChangeset
for help on using the changeset viewer.