diff options
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle_emitter.h')
-rw-r--r-- | src/libjin/Graphics/particles/je_particle_emitter.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/libjin/Graphics/particles/je_particle_emitter.h b/src/libjin/Graphics/particles/je_particle_emitter.h new file mode 100644 index 0000000..9200532 --- /dev/null +++ b/src/libjin/Graphics/particles/je_particle_emitter.h @@ -0,0 +1,112 @@ +#ifndef __JE_PARTICLE_EMITTER_H__ +#define __JE_PARTICLE_EMITTER_H__ + +#include "../../common/je_temporary.h" +#include "../../math/je_vector2.hpp" + +#include "je_particle.h" + +namespace JinEngine +{ + namespace Graphics + { + namespace Particles + { + + struct PositionDef + { + bool enableRandom = false; + union + { + struct + { + Math::Vector2<float> min; + Math::Vector2<float> max; + } random; + Math::Vector2<float> position; + } position; + }; + + struct DirectionDef + { + bool enableRandom = false; + union + { + struct + { + float min = 0; + float max = 0; + } random; + float direction = 0; + } direction; + }; + + /// + /// How many particles emitted per second. + /// + struct EmitRateDef + { + bool enableRandom = false; + union + { + struct + { + float min = 1; + float max = 1; + } random; + float rate = 1; + } rate; + }; + + /// + /// Definition of particle emitter. + /// + struct ParticleEmitterDef : public Temporary + { + PositionDef positionDef; ///< Emit position(relativily to the particle system center). + DirectionDef directionDef; ///< Emit direction. + EmitRateDef emitRateDef; ///< Emit rate. + }; + + class ParticleSystem; + + /// + /// Emit a single particle. + /// + class ParticleEmitter + { + public: + /// + /// + /// + ParticleEmitter(ParticleSystem& ps); + + /// + /// + /// + void update(float dt); + + private: + /// + /// + /// + ParticleSystem& mParticleSystem; + + /// + /// Emit a particle according to emitter definition and particle definition, particle system should + /// assign particle value to the particle in particle pool, but not use this return particle. + /// + void emit(); + + /// + /// + /// + float mTime; + + }; + + } // namespace Particles + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file |