Changeset 5759 in orxonox.OLD for branches/guidedmissile/src/world_entities/weapons
- Timestamp:
- Nov 24, 2005, 3:06:54 PM (19 years ago)
- Location:
- branches/guidedmissile/src/world_entities/weapons
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/guidedmissile/src/world_entities/weapons/guided_missile.cc
r5758 r5759 10 10 11 11 ### File Specific 12 main-programmer: Patrick Boenzli13 co-programmer: Benjamin Grauer12 main-programmer: Silvan Nellen 13 co-programmer: 14 14 15 15 */ 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 17 17 18 #include " rocket.h"18 #include "guided_missile.h" 19 19 20 20 #include "fast_factory.h" … … 32 32 using namespace std; 33 33 34 CREATE_FAST_FACTORY_STATIC( Rocket, CL_ROCKET);34 CREATE_FAST_FACTORY_STATIC(GuidedMissile, CL_GUIDED_MISSILE); 35 35 36 36 /** 37 37 * standard constructor 38 38 */ 39 Rocket::Rocket() : Projectile()39 GuidedMissile::GuidedMissile () : Projectile() 40 40 { 41 this->setClassID(CL_ TEST_BULLET, "Rocket");41 this->setClassID(CL_GUIDED_MISSILE, "GuidedMissile"); 42 42 43 43 float modelSize = .3; 44 this->loadModel("models/projectiles/orx- rocket.obj", .3);44 this->loadModel("models/projectiles/orx-guided_missile.obj", .3); 45 45 46 46 this->energyMin = 1; … … 58 58 * standard deconstructor 59 59 */ 60 Rocket::~Rocket()60 GuidedMissile::~GuidedMissile () 61 61 { 62 62 // delete this->emitter; 63 63 64 64 /* this is normaly done by World.cc by deleting the ParticleEngine */ 65 if ( Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)65 if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 66 66 { 67 if (ClassList::exists( Rocket::trailParticles, CL_PARTICLE_SYSTEM))68 delete Rocket::trailParticles;69 Rocket::trailParticles = NULL;67 if (ClassList::exists(GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM)) 68 delete GuidedMissile::trailParticles; 69 GuidedMissile::trailParticles = NULL; 70 70 } 71 if ( Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)71 if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 72 72 { 73 if (ClassList::exists( Rocket::explosionParticles, CL_PARTICLE_SYSTEM))74 delete Rocket::explosionParticles;75 Rocket::explosionParticles = NULL;73 if (ClassList::exists(GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM)) 74 delete GuidedMissile::explosionParticles; 75 GuidedMissile::explosionParticles = NULL; 76 76 } 77 77 78 78 } 79 79 80 ParticleSystem* Rocket::trailParticles = NULL;81 ParticleSystem* Rocket::explosionParticles = NULL;80 ParticleSystem* GuidedMissile::trailParticles = NULL; 81 ParticleSystem* GuidedMissile::explosionParticles = NULL; 82 82 83 void Rocket::activate()83 void GuidedMissile::activate() 84 84 { 85 85 State::getWorldEntityList()->add(this); 86 if (unlikely( Rocket::trailParticles == NULL))86 if (unlikely(GuidedMissile::trailParticles == NULL)) 87 87 { 88 Rocket::trailParticles = new ParticleSystem(2000, PARTICLE_SPRITE);89 Rocket::trailParticles->setName("RocketTrailParticles");90 Rocket::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");91 Rocket::trailParticles->setLifeSpan(1.0, .3);92 Rocket::trailParticles->setRadius(0.0, .5);93 Rocket::trailParticles->setRadius(0.2, 2.0);94 Rocket::trailParticles->setRadius(.5, .8);95 Rocket::trailParticles->setRadius(1.0, .8);96 Rocket::trailParticles->setColor(0.0, 1,0,0,.7);97 Rocket::trailParticles->setColor(0.2, .8,.8,0,.5);98 Rocket::trailParticles->setColor(0.5, .8,.8,.8,.8);99 Rocket::trailParticles->setColor(1.0, .8,.8,.8,.0);88 GuidedMissile::trailParticles = new ParticleSystem(2000, PARTICLE_SPRITE); 89 GuidedMissile::trailParticles->setName("GuidedMissileTrailParticles"); 90 GuidedMissile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png"); 91 GuidedMissile::trailParticles->setLifeSpan(1.0, .3); 92 GuidedMissile::trailParticles->setRadius(0.0, .5); 93 GuidedMissile::trailParticles->setRadius(0.2, 2.0); 94 GuidedMissile::trailParticles->setRadius(.5, .8); 95 GuidedMissile::trailParticles->setRadius(1.0, .8); 96 GuidedMissile::trailParticles->setColor(0.0, 1,0,0,.7); 97 GuidedMissile::trailParticles->setColor(0.2, .8,.8,0,.5); 98 GuidedMissile::trailParticles->setColor(0.5, .8,.8,.8,.8); 99 GuidedMissile::trailParticles->setColor(1.0, .8,.8,.8,.0); 100 100 } 101 if (unlikely( Rocket::explosionParticles == NULL))101 if (unlikely(GuidedMissile::explosionParticles == NULL)) 102 102 { 103 Rocket::explosionParticles = new ParticleSystem(200, PARTICLE_SPRITE);104 Rocket::explosionParticles->setName("RocketExplosionParticles");105 Rocket::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");106 Rocket::explosionParticles->setLifeSpan(.5, .3);107 Rocket::explosionParticles->setRadius(0.0, 10);108 Rocket::explosionParticles->setRadius(.5, 15.0);109 Rocket::explosionParticles->setRadius(1.0, 10.0);110 Rocket::explosionParticles->setColor(0.0, 0,1,0,1);111 Rocket::explosionParticles->setColor(0.5, .8,.8,0,.8);112 Rocket::explosionParticles->setColor(0.8, .8,.8,.3,.8);113 Rocket::explosionParticles->setColor(1.0, 1,1,1,.0);103 GuidedMissile::explosionParticles = new ParticleSystem(200, PARTICLE_SPRITE); 104 GuidedMissile::explosionParticles->setName("GuidedMissileExplosionParticles"); 105 GuidedMissile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png"); 106 GuidedMissile::explosionParticles->setLifeSpan(.5, .3); 107 GuidedMissile::explosionParticles->setRadius(0.0, 10); 108 GuidedMissile::explosionParticles->setRadius(.5, 15.0); 109 GuidedMissile::explosionParticles->setRadius(1.0, 10.0); 110 GuidedMissile::explosionParticles->setColor(0.0, 0,1,0,1); 111 GuidedMissile::explosionParticles->setColor(0.5, .8,.8,0,.8); 112 GuidedMissile::explosionParticles->setColor(0.8, .8,.8,.3,.8); 113 GuidedMissile::explosionParticles->setColor(1.0, 1,1,1,.0); 114 114 } 115 115 116 ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::trailParticles);116 ParticleEngine::getInstance()->addConnection(this->emitter, GuidedMissile::trailParticles); 117 117 118 118 this->update(0); … … 122 122 123 123 124 void Rocket::deactivate()124 void GuidedMissile::deactivate() 125 125 { 126 126 ParticleEngine::getInstance()->breakConnections(this->emitter); … … 129 129 // GarbageCollector::getInstance()->collect(this); 130 130 State::getWorldEntityList()->remove(this); 131 Rocket::fastFactory->kill(this);131 GuidedMissile::fastFactory->kill(this); 132 132 } 133 133 134 134 135 void Rocket::collidesWith(WorldEntity* entity, const Vector& location)135 void GuidedMissile::collidesWith(WorldEntity* entity, const Vector& location) 136 136 { 137 137 if (this->hitEntity != entity && entity->isA(CL_NPC)) … … 144 144 * @param time since last tick 145 145 */ 146 void Rocket::tick (float time)146 void GuidedMissile::tick (float time) 147 147 { 148 148 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); … … 164 164 * the function gets called, when the projectile is destroyed 165 165 */ 166 void Rocket::destroy ()166 void GuidedMissile::destroy () 167 167 { 168 PRINTF(5)("DESTROY Rocket\n");168 PRINTF(5)("DESTROY GuidedMissile\n"); 169 169 this->lifeCycle = .95; //!< @todo calculate this usefully. 170 ParticleEngine::getInstance()->breakConnection(this->emitter, Rocket::trailParticles);171 ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::explosionParticles);170 ParticleEngine::getInstance()->breakConnection(this->emitter, GuidedMissile::trailParticles); 171 ParticleEngine::getInstance()->addConnection(this->emitter, GuidedMissile::explosionParticles); 172 172 173 173 this->emitter->setEmissionRate(1000.0); … … 178 178 179 179 180 void Rocket::draw () const180 void GuidedMissile::draw () const 181 181 { 182 182 glMatrixMode(GL_MODELVIEW); -
branches/guidedmissile/src/world_entities/weapons/guided_missile.h
r5758 r5759 1 1 /*! 2 * @file rocket.h3 * @brief a RocketProjectile2 * @file guided_missile.h 3 * @brief a GuidedMissile Projectile 4 4 */ 5 5 6 #ifndef _ ROCKET_H7 #define _ ROCKET_H6 #ifndef _GUIDED_MISSILE_H 7 #define _GUIDED_MISSILE_H 8 8 9 9 #include "projectile.h" … … 14 14 class ParticleEmitter; 15 15 class FastFactory; 16 class Aim; 16 17 17 class Rocket: public Projectile18 class GuidedMissile : public Projectile 18 19 { 19 20 public: 20 Rocket();21 virtual ~ Rocket();21 GuidedMissile (); 22 virtual ~GuidedMissile (); 22 23 23 24 void setTarget(PNode* target); 24 25 virtual void activate(); 25 26 virtual void deactivate(); … … 39 40 40 41 ParticleEmitter* emitter; 41 42 Aim* target; 42 43 43 44 WorldEntity* hitEntity; // FIXME TEMPORARY … … 45 46 }; 46 47 47 #endif /* _ ROCKET_H */48 #endif /* _GUIDED_MISSILE_H */
Note: See TracChangeset
for help on using the changeset viewer.