Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5443 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Oct 28, 2005, 9:44:57 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: heavy ParticleEmission from the Bullets

@patrick: i think, this is what you wanted me to do…

Location:
trunk/src/world_entities/weapons
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/projectile.h

    r5039 r5443  
    4444
    4545
     46    /** @brief This is called, when the Projectile is Emitted */
     47    virtual void activate() = 0;
     48    /** @brief This is called, when the Projectile is being destroyed, or deleted */
     49    virtual void deactivate() = 0;
    4650
    4751    virtual void destroy ();
  • trunk/src/world_entities/weapons/test_bullet.cc

    r5357 r5443  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1311   ### File Specific
    1412   main-programmer: Patrick Boenzli
    15    co-programmer:
     13   co-programmer: Benjamin Grauer
     14
    1615*/
    1716#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
     
    2423#include "fast_factory.h"
    2524
    26 #include "obb_tree.h"
     25#include "state.h"
     26#include "list.h"
     27
     28#include "particle_engine.h"
     29#include "particle_emitter.h"
     30#include "particle_system.h"
     31
    2732
    2833using namespace std;
     
    4449  this->remove();
    4550  this->lifeSpan = 5;
     51
     52  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 0.01);
     53  this->emitter->setParent(this);
     54  this->emitter->setEmissionRate(20);
     55
     56  this->emitter->setSpread(M_2_PI);
    4657}
    4758
     
    5263TestBullet::~TestBullet ()
    5364{
     65  delete this->emitter;
    5466  /*
    5567     do not delete the test projectModel, since it is pnode
     
    5971}
    6072
     73ParticleSystem* TestBullet::explosionParticles = NULL;
     74
     75
     76void TestBullet::activate()
     77{
     78  State::getWorldEntityList()->add(this);
     79  if (unlikely(TestBullet::explosionParticles == NULL))
     80  {
     81    TestBullet::explosionParticles = new ParticleSystem(10000, PARTICLE_SPRITE);
     82    TestBullet::explosionParticles->setLifeSpan(.5);
     83    TestBullet::explosionParticles->setRadius(0.0, .5);
     84    TestBullet::explosionParticles->setRadius(0.5, 2.0);
     85    TestBullet::explosionParticles->setRadius(0.0, 0.0);
     86    TestBullet::explosionParticles->setColor(0.0, 1,0,0,.7);
     87    TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);
     88    TestBullet::explosionParticles->setColor(1.0, .5,.5,.5,.0);
     89  }
     90
     91  ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles);
     92}
     93
     94
     95void TestBullet::deactivate()
     96{
     97  ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::explosionParticles);
     98
     99  GarbageCollector::getInstance()->collect(this);
     100  this->lifeCycle = 0.0;
     101}
     102
     103
    61104void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)
    62105{
    63   this->destroy();
     106
    64107}
    65108
     
    81124      PRINTF(5)("FINALIZE===========================\n");
    82125//      this->finalize();
    83       GarbageCollector::getInstance()->collect(this);
    84       this->lifeCycle = 0.0; //! @todo should not be here
     126      this->deactivate();
    85127    }
    86128}
     
    91133void TestBullet::destroy ()
    92134{
     135  this->deactivate();
    93136
     137
     138  GarbageCollector::getInstance()->collect(this);
    94139
    95140}
  • trunk/src/world_entities/weapons/test_bullet.h

    r5257 r5443  
    1111class Vector;
    1212class Weapon;
     13class ParticleSystem;
     14class ParticleEmitter;
    1315
    1416class TestBullet : public Projectile
    1517{
    16  public:
    17   TestBullet ();
    18   virtual ~TestBullet ();
     18  public:
     19    TestBullet ();
     20    virtual ~TestBullet ();
    1921
    20   virtual void collidesWith(WorldEntity* entity, const Vector& location);
    21   virtual void destroy ();
    2222
    23   virtual void tick (float time);
    24   virtual void draw ();
     23    virtual void activate();
     24    virtual void deactivate();
     25
     26    virtual void collidesWith(WorldEntity* entity, const Vector& location);
     27
     28    virtual void destroy ();
     29
     30    virtual void tick (float time);
     31    virtual void draw ();
     32
     33
     34  private:
     35    static ParticleSystem*     explosionParticles;
     36    ParticleEmitter*           emitter;
    2537
    2638};
  • trunk/src/world_entities/weapons/test_gun.cc

    r5441 r5443  
    2929#include "factory.h"
    3030
    31 #include "state.h"
    3231#include "vector.h"
    3332#include "list.h"
     
    189188  pj->setAbsCoor(this->getEmissionPoint());
    190189  pj->setAbsDir(this->getAbsDir());
    191   State::getWorldEntityList()->add(pj);
     190  pj->activate();
    192191}
    193192
  • trunk/src/world_entities/weapons/turret.cc

    r5441 r5443  
    138138  if (target != NULL)
    139139  {
    140     pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(20)
     140    pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13)
    141141            /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    142142  }
     
    147147  pj->setAbsCoor(this->getEmissionPoint());
    148148  pj->setAbsDir(this->getAbsDir());
    149 
    150   State::getWorldEntityList()->add(pj);
     149  pj->activate();
    151150}
    152151
Note: See TracChangeset for help on using the changeset viewer.