Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc @ 3932

Last change on this file since 3932 was 3932, checked in by bensch, 19 years ago

orxonox/branches/particleEngine: the first particles are being drawn :)

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: ...
13   co-programmer: Patrick Boenzli
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "particle_emitter.h"
19
20#include "particle_system.h"
21
22using namespace std;
23
24
25/**
26   \brief standard constructor
27*/
28ParticleEmitter::ParticleEmitter(const Vector& direction, float angle, float emissionRate, 
29                  float velocity)
30{
31   this->setClassName ("ParticleEmitter");
32   this->direction = direction;
33   this->setSpread(angle);
34   this->emissionRate = emissionRate;
35   this->velocity = velocity;
36
37   this->saveTime = 0.0;
38}
39
40
41
42/**
43   \brief standard destructor
44
45*/
46ParticleEmitter::~ParticleEmitter () 
47{}
48
49
50/**
51   \brief this start the emitter
52*/
53void ParticleEmitter::start() {}
54
55
56/**
57   \brief this stops the emitter
58*/
59void ParticleEmitter::stop() {}
60
61
62
63
64/* these are Animation interfaces: so you can change spec values as you want */
65
66/**
67   \brief set the emission rate
68   \param sets the number of particles emitted per second
69   \param random A random emissionRate, the +- randomness of this option
70
71   if you want to change the value of this variable during emission time (to make it more dynamic)
72   you may want to use the animation class
73*/
74void ParticleEmitter::setEmissionRate(float emissionRate)
75{}
76
77/**
78   \brief set the angle of the emitter
79   \param angle around the direction in which there are particles to be emitted
80   \param randomAngle A random spread-angle, the +- randomness of this option
81
82   if you want to change the value of this variable during emission time (to make it more dynamic)
83   you may want to use the animation class
84*/
85void ParticleEmitter::setSpread(float angle, float randomAngle)
86{}
87
88
89
90
91/**
92   \brief sets the velocity of all particles emitted
93   \param velocity The starting velocity of the emitted particles
94   \param random A random starting velocity, the +- randomness of this option
95
96   if you want to change the value of this variable during emission time (to make it more dynamic)
97   you may want to use the animation class
98*/
99void ParticleEmitter::setVelocity(float velocity, float random)
100{}
101
102/**
103   \brief this set the time to life of a particle, after which it will die
104   \param the time to live in seconds
105
106   if you want to change the value of this variable during emission time (to make it more dynamic)
107   you may want to use the animation class
108*/
109
110void ParticleEmitter::tick(float dt, ParticleSystem* system)
111{
112  // saving the time
113  float countF = (dt+this->saveTime) / emissionRate;
114  int count = (int)round(countF);
115  this->saveTime = countF - (float)count;
116
117  for (int i = 0; i <= count; i++)
118    // emmits from EMITTER_DOT,
119    system->addParticle(this->getAbsCoor(), direction * velocity );
120}
Note: See TracBrowser for help on using the repository browser.