Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 838af124cb6452d22c9206351a87d9a98ea4aacb (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
   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_timestamp;
	unsigned long	ejector_last_eject;
	Particles	ejector_particles;
	bool		ejector_enabled;
};

/**
 * @brief Sprite particles
 * Sprites are rendered facing the camera
 * */
class ParticleEjectorSprite : public ParticleEjector {
public:
	ParticleEjectorSprite(const ParticleEjectorScript &script);
	virtual ~ParticleEjectorSprite();

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

/**
 * @brief Flare particles
 * Flare are rendered along the particle axis
 * */
class ParticleEjectorFlare : public ParticleEjector {
public:
	ParticleEjectorFlare(const ParticleEjectorScript &script);
	virtual ~ParticleEjectorFlare();

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);
};

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

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

} // namespace render

#endif // __INCLUDED_RENDER_PARTICLEEJECTOR_H__