20#ifndef HEADER_STK_PARTICLE_HPP
21#define HEADER_STK_PARTICLE_HPP
23#include "graphics/gl_headers.hpp"
24#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
32inline float glslSmoothstep(
float edge0,
float edge1,
float x)
34 float t = core::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
35 return t * t * (3.0f - 2.0f * t);
44 const std::vector<std::vector<float> > m_array;
51 float track_x,
float track_z,
float track_x_len,
53 : m_array(std::move(array)), m_x(track_x), m_z(track_z),
54 m_x_len(track_x_len), m_z_len(track_z_len) {}
59 core::vector3df m_position;
61 core::vector3df m_direction;
67 std::vector<ParticleData> m_particles_generating, m_initial_particles;
69 core::vector3df m_color_from, m_color_to;
71 float m_size_increase_factor;
73 bool m_first_execution, m_randomize_initial_y, m_flips, m_pre_generating;
81 static std::vector<float> m_flips_data;
83 static GLuint m_flips_buffer;
86 void generateParticlesFromPointEmitter(scene::IParticlePointEmitter*);
88 void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter*);
90 void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter*);
92 void stimulateHeightMap(
float,
unsigned int, std::vector<CPUParticle>*);
94 void stimulateNormal(
float,
unsigned int, std::vector<CPUParticle>*);
99 ISceneNode* parent = 0, s32
id = -1,
100 const core::vector3df& position = core::vector3df(0, 0, 0),
101 const core::vector3df& rotation = core::vector3df(0, 0, 0),
102 const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
109 void setColorFrom(
float r,
float g,
float b)
116 void setColorTo(
float r,
float g,
float b)
123 virtual void setEmitter(scene::IParticleEmitter* emitter);
125 virtual void OnRegisterSceneNode();
127 void setIncreaseFactor(
float val) { m_size_increase_factor = val; }
129 void setHeightmap(std::vector<std::vector<float> >& array,
float track_x,
130 float track_z,
float track_x_len,
float track_z_len)
132 m_hm =
new HeightMapData(array, track_x, track_z, track_x_len,
136 void generate(std::vector<CPUParticle>* out);
138 void setFlips() { m_flips =
true; }
140 virtual bool getFlips()
const {
return m_flips; }
142 unsigned getMaxCount()
const {
return m_max_count; }
144 void setPreGenerating(
bool val) { m_pre_generating = val; }
146 static void updateFlips(
unsigned maximum_particle_count);
148 static void destroyFlipsBuffer()
150 if (m_flips_buffer != 0)
152 glDeleteBuffers(1, &m_flips_buffer);
155 m_flips_data.clear();
158 static GLuint getFlipsBuffer()
160 assert(m_flips_buffer != 0);
161 return m_flips_buffer;
164 virtual bool isSkyParticle()
const {
return m_hm != NULL; }
Definition: stk_particle.hpp:39
unsigned m_max_count
Maximum count of particles.
Definition: stk_particle.hpp:79
core::matrix4 m_previous_frame_matrix
Previous frame particles emitter source matrix.
Definition: stk_particle.hpp:76
Definition: cpu_particle_manager.hpp:44
Definition: stk_particle.hpp:43
Definition: stk_particle.hpp:58