1 //
2 //  SuperTuxKart - a fun racing game with go-kart
3 //  Copyright (C) 2011-2015  Joerg Henrichs, Marianne Gagnon
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License
7 //  as published by the Free Software Foundation; either version 3
8 //  of the License, or (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 #ifndef HEADER_SMOKE_HPP
20 #define HEADER_SMOKE_HPP
21 
22 namespace irr
23 {
24     namespace scene { class ISceneNode; class IParticleEmitter; }
25 }
26 using namespace irr;
27 
28 #include "utils/leak_check.hpp"
29 #include "utils/no_copy.hpp"
30 #include "utils/vec3.hpp"
31 
32 class Material;
33 class ParticleKind;
34 class STKParticle;
35 class Track;
36 
37 /**
38  * \brief manages smoke particle effects
39  * \ingroup graphics
40  */
41 class ParticleEmitter : public NoCopy
42 {
43 private:
44     /** STK particle systems. */
45     STKParticle*                     m_node;
46 
47     Vec3                             m_position;
48 
49     scene::ISceneNode*               m_parent;
50 
51     /** The emitters. Access to these is needed to adjust the number of
52      *  particles per second. */
53     scene::IParticleEmitter         *m_emitter;
54 
55     const ParticleKind              *m_particle_type;
56 
57     unsigned int m_magic_number;
58 
59     /** Decay of emission rate, in particles per second */
60     int m_emission_decay_rate;
61 
62     /** The irrlicht emitter contains this info, but as an int. We want it as a float */
63     float m_min_rate, m_max_rate;
64 
65     bool m_randomize_initial_y;
66 
67     bool m_important;
68 
69 public:
70 
71     LEAK_CHECK()
72 
73     ParticleEmitter             (const ParticleKind* type,
74                                  const Vec3 &position,
75                                  scene::ISceneNode* parent = NULL,
76                                  bool randomize_initial_y =  false,
77                                  bool important = false);
78     virtual     ~ParticleEmitter();
79     virtual void update         (float dt);
80     void         setCreationRateAbsolute(float fraction);
81     void         setCreationRateRelative(float f);
82     int          getCreationRate();
getCreationRateFloat()83     float        getCreationRateFloat() {return m_min_rate;}
84 
85     void         setPosition(const Vec3 &pos);
86     void         setRotation(const Vec3 &rot);
87 
getParticlesInfo() const88     const ParticleKind* getParticlesInfo() const { return m_particle_type; }
89 
90     void         setParticleType(const ParticleKind* p);
91 
92     void         resizeBox(float size);
93 
getNode()94     STKParticle* getNode() { return m_node; }
95 
96     /** call this if the node was freed otherwise */
unsetNode()97     void         unsetNode() { m_node = NULL; }
98 
99     void         addHeightMapAffector(Track* t);
100 
randomizeInitialY() const101     bool         randomizeInitialY() const { return m_randomize_initial_y; }
102 };
103 #endif
104 
105 
106