| | 1 | = ParticleEngine = |
| | 2 | Particles are an easy to use, fast and efficient way to produce many different volumetric effects like |
| | 3 | * snow |
| | 4 | * dust |
| | 5 | * smoke |
| | 6 | * fire |
| | 7 | * commets |
| | 8 | * and much more |
| | 9 | normally they are quite tiny objects, that follow some laws like velocity, forces and so on... |
| | 10 | |
| | 11 | == properties == |
| | 12 | each particle has some properties that are given to it by its ParticleSystem. |
| | 13 | those are: |
| | 14 | {{{ |
| | 15 | #!cpp |
| | 16 | float lifeTime; //!< The time this particle has to live. |
| | 17 | float lifeCycle; //!< The fraction of time passed. (in percentage of its lifeTime) |
| | 18 | |
| | 19 | Vector position; //!< The current position of this particle. |
| | 20 | Vector velocity; //!< The current velocity of this particle. |
| | 21 | Vector extForce; //!< The external Force that influences this Particle. |
| | 22 | Quaternion rotation; //!< The current rotation of this particle. |
| | 23 | float mass; //!< The mass of this particle. |
| | 24 | float massRand; //!< A random mass |
| | 25 | float radius; //!< The current size of this particle. |
| | 26 | float radiusRand; //!< a random Radius |
| | 27 | GLfloat color [4]; //!< A Color for the particles. |
| | 28 | }}} |
| | 29 | through the ParticleSystem, they are all animatable. |
| | 30 | (if you are interested in more detail how you can animate this stuff visit: [http://www.orxonox.ethz.ch/trunk/doc/html/annotated.html this] and goto ParticleSystem. |
| | 31 | |
| | 32 | == How It Works == |
| | 33 | https://www.orxonox.net/additionals/ParticleEngine.png |
| | 34 | |
| | 35 | __GENERAL IDEA__ |
| | 36 | |
| | 37 | The Diagram above shows how the flow of the ParticleEngine works. |
| | 38 | 1. The driver(world.cc) tells the ParticleEngine what to do (either tick or draw) |
| | 39 | 2. The ParticleEngine tells the ParticleEmitter's to emitt into their ParticleSystem's |
| | 40 | 3. The ParticleEngine telss the ParticleSystem's to tick themselves. |
| | 41 | moves/iterates/removes particles |
| | 42 | 4. The ParticleEngine tells the ParticleSystem's to draw themselves |
| | 43 | |
| | 44 | __IN ORXONOX__ |
| | 45 | 1. All the ParticleSystems are WorldEntitites and as such are drawn within the internal engine. So our framework acts as ParticleEngine |
| | 46 | 2. Emitters have one/or no ParticleSystem in which they emit into. The ParticleSystems tell them to emit |
| | 47 | 3. Systems have multiple emitters, and they are tickt and drawn in ORXONOX OM_ENVIRON_TICK (see ObjectManager) |
| | 48 | |
| | 49 | == Creation == |
| | 50 | 1. hardcoded |
| | 51 | {{{ |
| | 52 | #!cpp |
| | 53 | /* create a ParticleSystem */ |
| | 54 | ParticleSystem* system = new SpriteParticles(100000); |
| | 55 | /* create a ParticleEmitter */ |
| | 56 | ParticleEmitter* emitter = new ParticleEmitter(Vector(-1, 0, 0), M_PI_4, 400, .5); |
| | 57 | /* let the emitter emit into system */ |
| | 58 | emitter->setSystem(system) |
| | 59 | // or |
| | 60 | system->addEmitter(emitter); |
| | 61 | |
| | 62 | }}} |
| | 63 | 2. lodeable |
| | 64 | this is the easiest version see the LoadParam page for more information on howto do this |
| | 65 | |
| | 66 | you could also use one of the many functions, to let the Particles look better, but this is for you to decide. |