hx3d  1
2D/3D Simple Game Framework
particle_emitter.hpp
1 /*
2  Particle emitter.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_PARTICLEEMITTER
22 #define HX3D_GRAPHICS_PARTICLEEMITTER
23 
24 #include "hx3d/graphics/particle.hpp"
25 #include "hx3d/utils/pool.hpp"
26 
27 namespace hx3d {
28 namespace graphics {
29 
34 public:
35 
41  ParticleEmitter(const unsigned int maxParticles);
42 
48  void emit(const unsigned int qty);
49 
55  void update(const float delta);
56 
62  void draw(Batch& batch);
63 
69  void setTexture(const Ptr<Texture>& texture);
70 
76  unsigned int getParticleCount();
77 
79  glm::vec3 position;
81  glm::vec3 emitter_size;
83  glm::vec3 particle_size;
85  glm::vec3 gravity;
87  glm::vec3 velocity;
91  float life;
92 
93 private:
97  void emitOne();
98 
100  Pool<Particle> particles;
101 
103  Ptr<Texture> texture;
104 };
105 
106 } /* graphics */
107 } /* hx3d */
108 
109 #endif
float rotationSpeed
Particles Z-rotation speed.
void draw(Batch &batch)
Draw the particles.
Manage poolable elements.
Definition: pool.hpp:35
hx3d framework namespace
Definition: audio.hpp:26
glm::vec3 position
Emitter position.
void update(const float delta)
Update the emitter.
ParticleEmitter(const unsigned int maxParticles)
Construct an emitter with a max particle number.
Simple base batch implementation. Draw at each draw call.
Definition: batch.hpp:36
glm::vec3 particle_size
Particles size.
glm::vec3 emitter_size
Emitter size.
glm::vec3 velocity
Particles velocity.
Emit particles with parameters.
unsigned int getParticleCount()
Get the active particle count.
void emit(const unsigned int qty)
Emit particles.
glm::vec3 gravity
Particles gravity.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34
void setTexture(const Ptr< Texture > &texture)
Set the emitter texture.