Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/heathaze/src/world_entities/effects/explosion.cc @ 10610

Last change on this file since 10610 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific
12   main-programmer: Patrick Boenzli
13   co-programmer: Benjamin Grauer
14
15*/
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
17
18#include "explosion.h"
19
20#include "loading/fast_factory.h"
21
22#include "state.h"
23
24#include "particles/box_emitter.h"
25#include "particles/sprite_particles.h"
26
27
28
29#include "class_id_DEPRECATED.h"
30ObjectListDefinitionID(Explosion, CL_EXPLOSION);
31CREATE_FAST_FACTORY_STATIC(Explosion);
32
33/**
34 *  standard constructor
35*/
36Explosion::Explosion ()
37{
38  this->registerObject(this, Explosion::_objectList);
39  this->toList(OM_DEAD_TICK);
40
41  this->emitter = new BoxEmitter(Vector(10,10,10), 200, 45, M_2_PI);
42  this->emitter->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
43  this->emitter->setParent(this);
44  this->emitter->setSpread(M_PI, M_PI);
45
46  this->lifeCycle = 0.0f;
47  this->lifeTime = .5f;
48
49}
50
51
52/**
53 *  standard deconstructor
54*/
55Explosion::~Explosion ()
56{
57  delete this->emitter;
58
59  /* this is normaly done by World.cc by deleting the ParticleEngine */
60  if (Explosion::explosionParticles != NULL && Explosion::objectList().size() <= 1)
61     Explosion::explosionParticles = NULL;
62}
63
64SpriteParticles* Explosion::explosionParticles = NULL;
65
66void Explosion::explode(PNode* position, const Vector& size)
67{
68  Explosion* explosion = dynamic_cast<Explosion*>(Explosion::fastFactory->resurrect());
69  explosion->setAbsCoor(position->getAbsCoor());
70  explosion->emitter->setSize(size);
71  explosion->activate();
72}
73
74
75void Explosion::activate()
76{
77  if (unlikely(Explosion::explosionParticles == NULL))
78  {
79    Explosion::explosionParticles = new SpriteParticles(5000);
80    Explosion::explosionParticles->setName("ExplosionExplosionParticles");
81    Explosion::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");
82    Explosion::explosionParticles->setLifeSpan(1.5, .3);
83    Explosion::explosionParticles->setRadius(0.0, 10);
84    Explosion::explosionParticles->setRadius(.5, 30.0);
85    Explosion::explosionParticles->setRadius(1.0, 10.0);
86    Explosion::explosionParticles->setColor(0.0, 1,0,0,1);
87    Explosion::explosionParticles->setColor(0.5, .8,.8,0,.5);
88    Explosion::explosionParticles->setColor(0.8, .8,.8,.3,.3);
89    Explosion::explosionParticles->setColor(1.0, 1,1,1,.0);
90  }
91
92  this->emitter->setSystem(Explosion::explosionParticles);
93  this->emitter->updateNode(.01);
94  this->emitter->updateNode(.01);
95  this->toList(OM_DEAD_TICK);
96  this->lifeCycle = 0.0;
97}
98
99
100void Explosion::deactivate()
101{
102  this->emitter->setSystem(NULL);
103  this->toList(OM_DEAD);
104  Explosion::fastFactory->kill(this);
105}
106
107
108/**
109 *  signal tick, time dependent things will be handled here
110 * @param time since last tick
111*/
112void Explosion::tick (float dt)
113{
114  this->lifeCycle += dt;
115  if(this->lifeTime < this->lifeCycle)
116    this->deactivate();
117}
Note: See TracBrowser for help on using the repository browser.