Changeset 9217 in orxonox.OLD for branches/presentation/src
- Timestamp:
- Jul 5, 2006, 12:32:30 PM (18 years ago)
- Location:
- branches/presentation/src
- Files:
-
- 2 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/defs/class_id.h
r9186 r9217 222 222 CL_FPS_SNIPER_RIFLE = 0x000003a7, 223 223 CL_FPS_LASER_RIFLE = 0x000003a8, 224 CL_BOOMERANG_GUN = 0x00000309, 224 225 225 226 // Projectiles … … 233 234 CL_GUIDED_MISSILE = 0x000003e7, 234 235 CL_HYPERBLAST = 0x000003e8, 236 CL_BOOMERANG_PROJECTILE = 0x00000309, 235 237 236 238 // NPC's -
branches/presentation/src/world_entities/WorldEntities.am
r9180 r9217 33 33 world_entities/weapons/aiming_system.cc \ 34 34 world_entities/weapons/fps_sniper_rifle.cc \ 35 world_entities/weapons/boomerang_gun.cc \ 35 36 \ 36 37 world_entities/projectiles/bomb.cc \ … … 40 41 world_entities/projectiles/rocket.cc \ 41 42 world_entities/projectiles/guided_missile.cc \ 43 world_entities/projectiles/boomerang_projectile.cc \ 42 44 world_entities/projectiles/hyperblast.cc \ 43 45 \ … … 100 102 weapons/aiming_turret.h \ 101 103 weapons/targeting_turret.h \ 104 weapons/boomerang_gun.h \ 102 105 weapons/aim.h \ 103 106 weapons/aiming_system.h \ … … 110 113 projectiles/rocket.h \ 111 114 projectiles/guided_missile.h \ 115 projectiles/boomerang_projectile.h \ 112 116 projectiles/hyperblast.h \ 113 117 \ -
branches/presentation/src/world_entities/projectiles/boomerang_projectile.cc
r9206 r9217 1 1 2 /* 2 3 orxonox - the future of 3D-vertical-scrollers … … 16 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 17 18 18 #include " guided_missile.h"19 #include "boomerang_projectile.h" 19 20 20 21 #include "state.h" … … 26 27 #include "debug.h" 27 28 28 CREATE_FAST_FACTORY_STATIC( GuidedMissile, CL_GUIDED_MISSILE);29 CREATE_FAST_FACTORY_STATIC(BoomerangProjectile, CL_BOOMERANG_PROJECTILE); 29 30 30 31 /** 31 32 * standard constructor 32 33 */ 33 GuidedMissile::GuidedMissile () : Projectile()34 { 35 this->setClassID(CL_ GUIDED_MISSILE, "GuidedMissile");34 BoomerangProjectile::BoomerangProjectile () : Projectile() 35 { 36 this->setClassID(CL_BOOMERANG_PROJECTILE, "BoomerangProjectile"); 36 37 37 38 this->loadModel("models/projectiles/orx-rocket.obj", 2.0); … … 54 55 * standard deconstructor 55 56 */ 56 GuidedMissile::~GuidedMissile ()57 BoomerangProjectile::~BoomerangProjectile () 57 58 { 58 59 // delete this->emitter; 59 60 60 61 /* this is normaly done by World.cc by deleting the ParticleEngine */ 61 if ( GuidedMissile::trailParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)62 { 63 if (ClassList::exists( GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM))64 delete GuidedMissile::trailParticles;65 GuidedMissile::trailParticles = NULL;66 } 67 if ( GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)68 { 69 if (ClassList::exists( GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM))70 delete GuidedMissile::explosionParticles;71 GuidedMissile::explosionParticles = NULL;72 } 73 74 } 75 76 SpriteParticles* GuidedMissile::trailParticles = NULL;77 SpriteParticles* GuidedMissile::explosionParticles = NULL;78 79 80 81 void GuidedMissile::activate()82 { 83 if (unlikely( GuidedMissile::trailParticles == NULL))84 { 85 GuidedMissile::trailParticles = new SpriteParticles(2000);86 GuidedMissile::trailParticles->setName("GuidedMissileTrailParticles");87 GuidedMissile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");88 GuidedMissile::trailParticles->setLifeSpan(1.0, .3);89 GuidedMissile::trailParticles->setRadius(0.0, .5);90 GuidedMissile::trailParticles->setRadius(0.2, 4.0);91 GuidedMissile::trailParticles->setRadius(.5, 1.5);92 GuidedMissile::trailParticles->setRadius(1.0, 1.5);93 GuidedMissile::trailParticles->setColor(0.0, 1,0,0,.7);94 GuidedMissile::trailParticles->setColor(0.2, .8,.8,0,.5);95 GuidedMissile::trailParticles->setColor(0.5, .8,.8,.8,.8);96 GuidedMissile::trailParticles->setColor(1.0, .8,.8,.8,.0);97 } 98 if (unlikely( GuidedMissile::explosionParticles == NULL))99 { 100 GuidedMissile::explosionParticles = new SpriteParticles(200);101 GuidedMissile::explosionParticles->setName("GuidedMissileExplosionParticles");102 GuidedMissile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");103 GuidedMissile::explosionParticles->setLifeSpan(.5, .3);104 GuidedMissile::explosionParticles->setRadius(0.0, 10);105 GuidedMissile::explosionParticles->setRadius(.5, 15.0);106 GuidedMissile::explosionParticles->setRadius(1.0, 10.0);107 GuidedMissile::explosionParticles->setColor(0.0, 0,1,0,1);108 GuidedMissile::explosionParticles->setColor(0.5, .8,.8,0,.8);109 GuidedMissile::explosionParticles->setColor(0.8, .8,.8,.3,.8);110 GuidedMissile::explosionParticles->setColor(1.0, 1,1,1,.0);111 } 112 113 this->emitter->setSystem( GuidedMissile::trailParticles);62 if (BoomerangProjectile::trailParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1) 63 { 64 if (ClassList::exists(BoomerangProjectile::trailParticles, CL_PARTICLE_SYSTEM)) 65 delete BoomerangProjectile::trailParticles; 66 BoomerangProjectile::trailParticles = NULL; 67 } 68 if (BoomerangProjectile::explosionParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1) 69 { 70 if (ClassList::exists(BoomerangProjectile::explosionParticles, CL_PARTICLE_SYSTEM)) 71 delete BoomerangProjectile::explosionParticles; 72 BoomerangProjectile::explosionParticles = NULL; 73 } 74 75 } 76 77 SpriteParticles* BoomerangProjectile::trailParticles = NULL; 78 SpriteParticles* BoomerangProjectile::explosionParticles = NULL; 79 80 81 82 void BoomerangProjectile::activate() 83 { 84 if (unlikely(BoomerangProjectile::trailParticles == NULL)) 85 { 86 BoomerangProjectile::trailParticles = new SpriteParticles(2000); 87 BoomerangProjectile::trailParticles->setName("BoomerangProjectileTrailParticles"); 88 BoomerangProjectile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png"); 89 BoomerangProjectile::trailParticles->setLifeSpan(1.0, .3); 90 BoomerangProjectile::trailParticles->setRadius(0.0, .5); 91 BoomerangProjectile::trailParticles->setRadius(0.2, 4.0); 92 BoomerangProjectile::trailParticles->setRadius(.5, 1.5); 93 BoomerangProjectile::trailParticles->setRadius(1.0, 1.5); 94 BoomerangProjectile::trailParticles->setColor(0.0, 1,0,0,.7); 95 BoomerangProjectile::trailParticles->setColor(0.2, .8,.8,0,.5); 96 BoomerangProjectile::trailParticles->setColor(0.5, .8,.8,.8,.8); 97 BoomerangProjectile::trailParticles->setColor(1.0, .8,.8,.8,.0); 98 } 99 if (unlikely(BoomerangProjectile::explosionParticles == NULL)) 100 { 101 BoomerangProjectile::explosionParticles = new SpriteParticles(200); 102 BoomerangProjectile::explosionParticles->setName("BoomerangProjectileExplosionParticles"); 103 BoomerangProjectile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png"); 104 BoomerangProjectile::explosionParticles->setLifeSpan(.5, .3); 105 BoomerangProjectile::explosionParticles->setRadius(0.0, 10); 106 BoomerangProjectile::explosionParticles->setRadius(.5, 15.0); 107 BoomerangProjectile::explosionParticles->setRadius(1.0, 10.0); 108 BoomerangProjectile::explosionParticles->setColor(0.0, 0,1,0,1); 109 BoomerangProjectile::explosionParticles->setColor(0.5, .8,.8,0,.8); 110 BoomerangProjectile::explosionParticles->setColor(0.8, .8,.8,.3,.8); 111 BoomerangProjectile::explosionParticles->setColor(1.0, 1,1,1,.0); 112 } 113 114 this->emitter->setSystem(BoomerangProjectile::trailParticles); 114 115 115 116 this->updateNode(0); … … 121 122 122 123 123 void GuidedMissile::deactivate()124 void BoomerangProjectile::deactivate() 124 125 { 125 126 this->emitter->setSystem(NULL); … … 128 129 this->toList(OM_DEAD); 129 130 this->removeNode(); 130 GuidedMissile::fastFactory->kill(this);131 } 132 133 134 void GuidedMissile::collidesWith(WorldEntity* entity, const Vector& location)131 BoomerangProjectile::fastFactory->kill(this); 132 } 133 134 135 void BoomerangProjectile::collidesWith(WorldEntity* entity, const Vector& location) 135 136 { 136 137 if (this->hitEntity != entity) … … 143 144 * @param time since last tick 144 145 */ 145 void GuidedMissile::tick (float time)146 { 147 148 149 if (this->target != NULL && this->target->getParent() != PNode::getNullParent()) 150 146 void BoomerangProjectile::tick (float time) 147 { 148 149 Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0); 150 151 { 151 152 speed = velocity.len(); 152 diffVector = ((target ->getAbsCoor()- this->getAbsCoor()).getNormalized());153 diffVector = ((targetFarFarAway - this->getAbsCoor()).getNormalized()); 153 154 154 155 if(velocity.dot(diffVector) != 0) 155 156 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;156 { 157 correctionVector = (( ( diffVector * (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility; 157 158 158 159 if( (diffVector * (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility ) 159 velocity = ((diffVector * (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;160 velocity = ((diffVector * (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility; 160 161 else if(velocity.dot(diffVector) > 0) 161 162 velocity += correctionVector; 162 163 else if (velocity.dot(diffVector) < 0) 163 164 velocity -= correctionVector; 164 165 } 165 166 else 166 167 velocity += diffVector * agility; 167 168 168 169 169 this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0))); 170 } 170 171 171 172 velocity *= maxVelocity/velocity.len(); … … 180 181 * the function gets called, when the projectile is destroyed 181 182 */ 182 void GuidedMissile::destroy (WorldEntity* killer)183 void BoomerangProjectile::destroy (WorldEntity* killer) 183 184 { 184 185 … … 186 187 187 188 Projectile::destroy( killer ); 188 PRINTF(5)("DESTROY GuidedMissile\n");189 PRINTF(5)("DESTROY BoomerangProjectile\n"); 189 190 this->lifeCycle = .95; //!< @todo calculate this usefully. 190 this->emitter->setSystem( GuidedMissile::explosionParticles);191 this->emitter->setSystem(BoomerangProjectile::explosionParticles); 191 192 192 193 this->emitter->setEmissionRate(1000.0); 193 194 this->emitter->setEmissionVelocity(50.0); 194 // this->deactivate();195 196 } 197 198 199 void GuidedMissile::draw () const195 // this->deactivate(); 196 197 } 198 199 200 void BoomerangProjectile::draw () const 200 201 { 201 202 glMatrixMode(GL_MODELVIEW); -
branches/presentation/src/world_entities/projectiles/boomerang_projectile.h
r9206 r9217 1 1 /*! 2 * @file guided_missile.h3 * @brief a GuidedMissile Projectile2 * @file boomerang_projectile.h 3 * @brief a BoomerangProjectile Projectile 4 4 */ 5 5 6 #ifndef _ GUIDED_MISSILE_H7 #define _ GUIDED_MISSILE_H6 #ifndef _BOOMERANG_PROJECTILE_H 7 #define _BOOMERANG_PROJECTILE_H 8 8 9 9 #include "projectile.h" … … 15 15 class Aim; 16 16 17 class GuidedMissile : public Projectile17 class BoomerangProjectile : public Projectile 18 18 { 19 19 public: 20 GuidedMissile ();21 virtual ~ GuidedMissile ();20 BoomerangProjectile (); 21 virtual ~BoomerangProjectile (); 22 22 23 23 virtual void activate(); … … 48 48 }; 49 49 50 #endif /* _ GUIDED_MISSILE_H */50 #endif /* _BOOMERANG_PROJECTILE_H */ -
branches/presentation/src/world_entities/weapons/boomerang_gun.cc
r9206 r9217 15 15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 16 16 17 #include " turret.h"17 #include "boomerang_gun.h" 18 18 19 19 #include "weapon_manager.h" … … 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY( Turret, CL_TURRET);29 CREATE_FACTORY(BoomerangGun, CL_BOOMERANG_GUN); 30 30 31 using namespace std;32 31 33 32 /** 34 33 * standard constructor 35 34 * 36 * creates a new Turret35 * creates a new BoomerangGun 37 36 */ 38 Turret::Turret()37 BoomerangGun::BoomerangGun () 39 38 : Weapon() 40 39 { … … 43 42 44 43 /** 45 * creates a new Turretfrom a TiXmlElement44 * creates a new BoomerangGun from a TiXmlElement 46 45 */ 47 Turret::Turret(const TiXmlElement* root)46 BoomerangGun::BoomerangGun(const TiXmlElement* root) 48 47 { 49 48 this->init(); … … 55 54 * standard deconstructor 56 55 */ 57 Turret::~Turret()56 BoomerangGun::~BoomerangGun () 58 57 { 59 58 // model will be deleted from WorldEntity-destructor 60 59 } 61 60 62 void Turret::init()61 void BoomerangGun::init() 63 62 { 64 this->setClassID(CL_ TURRET, "Turret");63 this->setClassID(CL_BOOMERANG_GUN, "BoomerangGun"); 65 64 66 65 … … 85 84 //this->minCharge = 2; 86 85 87 this->setCapability(WTYPE_ALLDIRS | WTYPE_ TURRET);88 this->setProjectileType(CL_ ROCKET);86 this->setCapability(WTYPE_ALLDIRS | WTYPE_BOMMERANG_GUN); 87 this->setProjectileType(CL_BOOMERANG_PROJECTILE); 89 88 90 this->loadModel("models/guns/turret1.obj" );89 this->loadModel("models/guns/turret1.obj", 5.0); 91 90 92 91 this->setEmissionPoint(1.684, 0.472, 0); … … 99 98 } 100 99 101 void Turret::loadParams(const TiXmlElement* root)100 void BoomerangGun::loadParams(const TiXmlElement* root) 102 101 { 103 102 Weapon::loadParams(root); 104 103 } 105 104 106 void Turret::activate()105 void BoomerangGun::activate() 107 106 { 108 107 } 109 108 110 void Turret::deactivate()109 void BoomerangGun::deactivate() 111 110 { 112 111 } 113 112 114 void Turret::tick(float dt)113 void BoomerangGun::tick(float dt) 115 114 { 116 115 if (!Weapon::tickW(dt)) … … 134 133 } 135 134 136 void Turret::fire()135 void BoomerangGun::fire() 137 136 { 138 137 Projectile* pj = this->getProjectile(); -
branches/presentation/src/world_entities/weapons/boomerang_gun.h
r9206 r9217 4 4 5 5 6 #ifndef _ TURRET_H7 #define _ TURRET_H6 #ifndef _BOOMERANG_GUN_H 7 #define _BOOMERANG_GUN_H 8 8 9 9 #include "weapon.h" 10 10 11 class Turret: public Weapon11 class BoomerangGun : public Weapon 12 12 { 13 13 public: 14 Turret();15 Turret(const TiXmlElement* root);16 virtual ~ Turret();14 BoomerangGun (); 15 BoomerangGun(const TiXmlElement* root); 16 virtual ~BoomerangGun (); 17 17 18 18 void init(); … … 29 29 }; 30 30 31 #endif /* _ TURRET_H */31 #endif /* _BOOMERANG_GUN_H */
Note: See TracChangeset
for help on using the changeset viewer.