From d4f9da2f3c19511b028da2569d7b6a8d1371e135 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Jan 2013 21:37:11 +0000 Subject: Major overhaul of the particle system back-end, support multiple ejectors per particle system. --- src/render/particleejector.h | 104 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/render/particleejector.h (limited to 'src/render/particleejector.h') diff --git a/src/render/particleejector.h b/src/render/particleejector.h new file mode 100644 index 0000000..f626f26 --- /dev/null +++ b/src/render/particleejector.h @@ -0,0 +1,104 @@ +/* + render/particleejector.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_RENDER_PARTICLEEJECTOR_H__ +#define __INCLUDED_RENDER_PARTICLEEJECTOR_H__ + +#include + +#include "render/particleejectorscript.h" +#include "render/particle.h" + +namespace render { + +class ParticleEjector : public ParticleEjectorScript { +public: + typedef std::deque Particles; + + /** + * @brief initialize an ejector from a ParticleEjectorScript + * */ + ParticleEjector(const ParticleEjectorScript &script); + virtual ~ParticleEjector(); + + /** + * @brief if false, no new particles are created + * */ + inline const bool enabled() + { + return ejector_enabled; + } + + /* ---- mutators ------------------------------------------- */ + + /** + * @brief enable or disable particle ejection + * */ + inline void enable(const bool enabled = true) + { + ejector_enabled = enabled; + } + + /** + * @brief disable or enable particle ejection + * */ + inline void disable(const bool disabled = true) + { + ejector_enabled = !disabled; + } + + /** + * @brief updated the particles attached to the ejector, and drawn them + * */ + void frame(const float seconds, const math::Vector3f & ps_location, const math::Axis & ps_axis); + + /** + * @brief remove all particles + * */ + void clear(); + +protected: + inline Particles &particles() + { + return ejector_particles; + } + + virtual void draw(const math::Vector3f & ps_location); + +private: + unsigned long ejector_last_eject; + Particles ejector_particles; + bool ejector_enabled; +}; + +/** + * @brief Spray particles + * */ +class ParticleEjectorSpray : public ParticleEjector { +public: + ParticleEjectorSpray(const ParticleEjectorScript &script); + virtual ~ParticleEjectorSpray(); + +protected: + virtual void draw(const math::Vector3f & ps_location); +}; + +/** + * @brief Trail particles + * */ +class ParticleEjectorTrail : public ParticleEjector { +public: + ParticleEjectorTrail(const ParticleEjectorScript &script); + virtual ~ParticleEjectorTrail(); + +protected: + virtual void draw(const math::Vector3f & ps_location); +}; + +} // namespace render + +#endif // __INCLUDED_RENDER_PARTICLEEJECTOR_H__ + -- cgit v1.2.3