[3655] | 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: ... |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 17 | |
---|
[3924] | 18 | #include "particle_engine.h" |
---|
[3655] | 19 | |
---|
[3931] | 20 | #include "particle_system.h" |
---|
| 21 | #include "particle_emitter.h" |
---|
| 22 | |
---|
[3930] | 23 | #include "list.h" |
---|
| 24 | |
---|
[3655] | 25 | using namespace std; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | \brief standard constructor |
---|
| 29 | */ |
---|
[3923] | 30 | ParticleEngine::ParticleEngine () |
---|
[3655] | 31 | { |
---|
[3923] | 32 | this->setClassName ("ParticleEngine"); |
---|
[3655] | 33 | |
---|
[3931] | 34 | this->systemList = new tList<ParticleSystem>; |
---|
[3655] | 35 | } |
---|
| 36 | |
---|
| 37 | /** |
---|
| 38 | \brief the singleton reference to this class |
---|
| 39 | */ |
---|
[3923] | 40 | ParticleEngine* ParticleEngine::singletonRef = NULL; |
---|
[3655] | 41 | |
---|
| 42 | /** |
---|
| 43 | \returns a Pointer to this Class |
---|
| 44 | */ |
---|
[3923] | 45 | ParticleEngine* ParticleEngine::getInstance(void) |
---|
[3655] | 46 | { |
---|
[3923] | 47 | if (!ParticleEngine::singletonRef) |
---|
| 48 | ParticleEngine::singletonRef = new ParticleEngine(); |
---|
| 49 | return ParticleEngine::singletonRef; |
---|
[3655] | 50 | } |
---|
| 51 | |
---|
| 52 | /** |
---|
[3923] | 53 | \brief standard destructor |
---|
[3655] | 54 | |
---|
| 55 | */ |
---|
[3923] | 56 | ParticleEngine::~ParticleEngine () |
---|
[3655] | 57 | { |
---|
[3931] | 58 | delete this->systemList; |
---|
[3930] | 59 | |
---|
| 60 | |
---|
[3923] | 61 | ParticleEngine::singletonRef = NULL; |
---|
[3655] | 62 | } |
---|
[3931] | 63 | |
---|
| 64 | /** |
---|
| 65 | \brief this function ticks all the ParticleSystems, so an animation will flow |
---|
| 66 | \param dt passed since last tick |
---|
| 67 | */ |
---|
| 68 | void ParticleEngine::tick(float dt) |
---|
| 69 | { |
---|
| 70 | tIterator<ParticleSystem>* tmpIt = systemList->getIterator(); |
---|
| 71 | ParticleSystem* tmpSys = tmpIt->nextElement(); |
---|
| 72 | while(tmpSys) |
---|
| 73 | { |
---|
| 74 | tmpSys->tick(dt); |
---|
| 75 | tmpSys = tmpIt->nextElement(); |
---|
| 76 | } |
---|
| 77 | delete tmpIt; |
---|
| 78 | |
---|
| 79 | } |
---|