Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 9e090d9c19cf490fd72b0b84a45c723d54b5e387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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 <deque>

#include "render/particleejectorscript.h"
#include "render/particle.h"

namespace render {
	
class ParticleEjector : public ParticleEjectorScript {
public:
	typedef std::deque<Particle *> 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, const math::Axis & ps_axis);
	
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, const math::Axis & ps_axis);
};

/**
 * @brief Trail particles
 * */
class ParticleEjectorTrail : public ParticleEjector {
public:
	ParticleEjectorTrail(const ParticleEjectorScript &script);
	virtual ~ParticleEjectorTrail();

protected:
	virtual void draw(const math::Vector3f & ps_location, const math::Axis & ps_axis);
};

} // namespace render

#endif // __INCLUDED_RENDER_PARTICLEEJECTOR_H__