summaryrefslogtreecommitdiffstats
path: root/kscreensaver/kdesavers/firesaverparticle.h
blob: e539adecdcb8d53add6647f9f27895d223b17495 (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
//     This file is part of KFireSaver3D.

//     KFireSaver3D is free software; you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation; either version 2 of the License, or
//     (at your option) any later version.

//     KFireSaver3D is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.

//     You should have received a copy of the GNU General Public License
//     along with KFireSaver3D; if not, write to the Free Software
//     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


//     Author: Enrico Ros, based on the great work of David Sansome (kfiresaver)
//     Email:  [email protected]

#ifndef KFIRESAVER_PARTICLE_H
#define KFIRESAVER_PARTICLE_H

#include <tqgl.h>

#define FLICKER_FRAMES_DELAY 8
#define DRAND ((float)rand() / (float)RAND_MAX)  /*random float between 0 and 1*/

/* -- Particle class.
 * Sets initial parameters and takes care of updating physics for a single 
 * fireworks particle. The physics model is the Newtonian one.
 */
class Particle
{
    public:
	//enum definitions for type of particle
	enum ParticleType
	{
		FireParticle,
		FireWorkLeaderParticle,
		FireWorkDebrisParticle,
		LogoParticle,
		StarParticle
	};

	Particle( ParticleType pT );

	//public methods for initializing default parameters and update them
	virtual void initializeValues (
		int color_scheme = 0,
		Particle* leader = 0L,
		GLfloat powermin = 5.0,
		GLfloat powermax = 10.0,
		bool flickers = false,
		GLfloat *displace = 0L );

	virtual void updateParameters ( float timeGap );

	//public accessible variables of the class
	ParticleType particleType;
	int explosionsDepth;
	unsigned int texture;

	GLfloat	xpos,	ypos,	zpos,
		xspeed,	yspeed,	zspeed,
		zacc;

	GLfloat colour[4],
		life, startLife,
		pixelSize;

	bool useLife;
	int flicker;

    private:
	Particle();
};


/* -- TurningParticle class.
 * Randomize initial parameters similar to a standard 'spherical' particle 
 * and takes care of updating physics. The physics model is a funny 'bees'
 * (vectorial-product) one.
 */
class TurningParticle : public Particle
{
    public:
	TurningParticle( ParticleType pT );

	virtual void initializeValues (
		int color_scheme = 0,
		Particle* leader = 0L,
		GLfloat powermin = 5.0,
		GLfloat powermax = 10.0,
		bool flickers = false,
		GLfloat *displace = 0L );

	virtual void updateParameters ( float dT );

    private:
	float wx, wy, wz;
	TurningParticle();
};

#endif