Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.