/* render/particles.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #error do not include this header #ifndef __INCLUDED_RENDER_PARTICLES_H__ #define __INCLUDED_RENDER_PARTICLES_H__ #include #include "math/axis.h" #include "math/color.h" #include "math/vector3f.h" #include "core/entity.h" #include "model/tags.h" namespace render { /* ---- class Particle --------------------------------------------- */ /// one particle class Particle { public: Particle(const math::Vector3f &location, float time); Particle(const math::Vector3f &location, const math::Axis &axis, float time); /// location of the particle, in world coordinates inline math::Vector3f &location() { return particle_location; } inline math::Axis &axis() { return particle_axis; } inline const float time() const { return particle_time; } protected: math::Vector3f particle_location; math::Axis particle_axis; float particle_time; }; /* ---- class ParticleSystem --------------------------------------- */ /// abstract base class for a particle system attached to an entity class ParticleSystem { public: ParticleSystem(const ParticleScript *script, const core::Entity *entity, const model::Particles *modelclass); virtual ~ParticleSystem(); /// index of the texture to use inline const size_t texture() const { return particlesystem_texture; } /// location of the particle system within the entity inline const math::Vector3f &location() const { return particlesystem_location; } /// axis of the particle system within the entity inline const math::Axis &axis() const { return particlesystem_axis; } inline const model::Cull cull() const { return particlesystem_cull; } /// color of the particles inline const math::Color & color() const { return particlesystem_color; } virtual void draw(const float elapsed); void set_timeout(float timeout); void set_eject(float eject); /// clear all particles void clear(); protected: typedef std::deque Stream; inline Stream & stream() { return particlesystem_stream; } Stream particlesystem_stream; math::Axis particlesystem_axis; math::Vector3f particlesystem_location; math::Vector3f ejector_location; math::Color particlesystem_color; model::Cull particlesystem_cull; bool ejector_active; float particlesystem_last_eject; float particlesystem_radius; float now; size_t particlesystem_texture; const model::Particles *particlesystem_modelclass; const ParticleScript *particlesystem_script; const core::Entity *particlesystem_entity; }; /* ---- class Flame ------------------------------------------------ */ /// flame style particles, like engine flames class Flame : public ParticleSystem { public: Flame(const ParticleScript *script, const core::Entity *entity, const model::Particles *modelclass); virtual ~Flame(); virtual void draw(const float elapsed); }; /* ---- class Jet -------------------------------------------------- */ /// jet style particles, like smoke class Jet : public ParticleSystem { public: Jet(const ParticleScript *script, const core::Entity *entity, const model::Particles *modelclass); virtual ~Jet(); virtual void draw(const float elapsed); }; /* ---- class Trail ------------------------------------------------ */ /// trail style particles, like an engine trail class Trail : public ParticleSystem { public: Trail(const ParticleScript *script, const core::Entity *entity, const model::Particles *modelclass); virtual ~Trail(); virtual void draw(float elapsed); }; /* ---- class Spray ----------------------------------------------- */ /** * @brief spray style particles * a spray is a sprite ejector * */ class Spray : public ParticleSystem { public: Spray(const ParticleScript *script, const core::Entity *entity, const model::Particles *modelclass); virtual ~Spray(); virtual void draw(const float elapsed); }; } // namespace render #endif // __INCLUDED_RENDER_PARTICLES_H__