1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(__INCLUDE_ParticleEngineh_INCLUDE__)
22 #define __INCLUDE_ParticleEngineh_INCLUDE__
23 
24 #include <graph/Particle.h>
25 #include <engine/GameStateI.h>
26 
27 class GLCamera;
28 class ParticleEngine : public GameStateI
29 {
30 public:
31 	ParticleEngine(GLCamera *camera, unsigned int maxParticles);
32 	virtual ~ParticleEngine();
33 
34 	void setMaxParticles(unsigned int maxParticles);
35 	unsigned int getMaxParticles();
36 	unsigned int getParticlesOnScreen();
getCamera()37 	GLCamera *getCamera() { return camera_; }
setAllowSorting(bool sorting)38 	void setAllowSorting(bool sorting) { allowSorting_ = sorting; }
39 
40 	void killAll();
41 
42 	Particle *getNextAliveParticle(unsigned int type);
43 
setFast(float speedMult)44 	static void setFast(float speedMult) { speed_ = speedMult; }
getFast()45 	static float getFast() { return speed_; }
46 
47 	// Inherited from GameStateI
48 	virtual void draw(const unsigned state);
49 	virtual void simulate(const unsigned int state, float simTime);
50 
51 protected:
52 	Particle *particles_;
53 	Particle **usedParticles_;
54 	Particle **freeParticles_;
55 	GLCamera *camera_;
56 
57 	float totalTime_;
58 	unsigned int maxParticles_;
59 	unsigned int particlesOnScreen_;
60 	bool allowSorting_;
61 
62 	static float speed_;
63 
64 	void normalizedSimulate(float time);
65 
66 };
67 
68 #endif // __INCLUDE_ParticleEngineh_INCLUDE__
69