Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/Explosion.cc @ 650

Last change on this file since 650 was 646, checked in by landauf, 17 years ago
  • added very bad collision detection (presentation hack :D)
  • added explosions
  • fixed bug in ParticleInterface (it tried to delete SceneManager)

AND:

  • fixed one of the most amazing bugs ever! (the game crashed when I deleted an object through a timer-function. because the timer-functions is called by an iterator, the iterator indirectly delted its object. by overloading the (it++) operator, i was able to solve this problem)
File size: 1.3 KB
Line 
1#include "Explosion.h"
2#include "../Orxonox.h"
3
4namespace orxonox
5{
6    CreateFactory(Explosion);
7
8    Explosion::Explosion(WorldEntity* owner)
9    {
10        RegisterObject(Explosion);
11
12        this->particle_ = 0;
13        this->lifetime_ = 0.4;
14
15        if (owner)
16        {
17            this->destroyTimer_.setTimer(this->lifetime_, false, this, &Explosion::destroyObject);
18
19            this->scale(1);
20            Vector3 position = owner->getNode()->getWorldPosition();
21
22            this->particle_ = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(), "explosion" + this->getName(), "Orxonox/treibwerk");
23            this->particle_->getParticleSystem()->setParameter("local_space", "true");
24            this->particle_->newEmitter();
25            this->particle_->setPositionOfEmitter(0, position);
26            this->particle_->setPositionOfEmitter(1, position);
27//            this->particle_->setColour(ColourValue(1.0, 0.8, 0.2));
28
29            this->particle_->addToSceneNode(this->getNode());
30        }
31    }
32
33    Explosion::~Explosion()
34    {
35        if (this->particle_)
36        {
37            this->particle_->detachFromSceneNode();
38            delete this->particle_;
39        }
40    };
41
42    void Explosion::destroyObject()
43    {
44        delete this;
45    }
46}
Note: See TracBrowser for help on using the repository browser.