Back to index

kdeartwork  4.3.2
firesaverparticle.h
Go to the documentation of this file.
00001 //     This file is part of KFireSaver3D.
00002 
00003 //     KFireSaver3D is free software; you can redistribute it and/or modify
00004 //     it under the terms of the GNU General Public License as published by
00005 //     the Free Software Foundation; either version 2 of the License, or
00006 //     (at your option) any later version.
00007 
00008 //     KFireSaver3D is distributed in the hope that it will be useful,
00009 //     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //     GNU General Public License for more details.
00012 
00013 //     You should have received a copy of the GNU General Public License
00014 //     along with KFireSaver3D; if not, write to the Free Software
00015 //     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00016 
00017 
00018 //     Author: Enrico Ros, based on the great work of David Sansome (kfiresaver)
00019 //     Email:  asy@libero.it
00020 
00021 #ifndef KFIRESAVER_PARTICLE_H
00022 #define KFIRESAVER_PARTICLE_H
00023 
00024 #include <qgl.h>
00025 
00026 #define FLICKER_FRAMES_DELAY 8
00027 #define DRAND ((float)rand() / (float)RAND_MAX)  /*random float between 0 and 1*/
00028 
00029 /* -- Particle class.
00030  * Sets initial parameters and takes care of updating physics for a single 
00031  * fireworks particle. The physics model is the Newtonian one.
00032  */
00033 class Particle
00034 {
00035     public:
00036        //enum definitions for type of particle
00037        enum ParticleType
00038        {
00039               FireParticle,
00040               FireWorkLeaderParticle,
00041               FireWorkDebrisParticle,
00042               LogoParticle,
00043               StarParticle
00044        };
00045 
00046        Particle( ParticleType pT );
00047 
00048        //public methods for initializing default parameters and update them
00049        virtual void initializeValues (
00050               int color_scheme = 0,
00051               Particle* leader = 0L,
00052               GLfloat powermin = 5.0,
00053               GLfloat powermax = 10.0,
00054               bool flickers = false,
00055               GLfloat *displace = 0L );
00056 
00057        virtual void updateParameters ( float timeGap );
00058 
00059        //public accessible variables of the class
00060        ParticleType particleType;
00061        int explosionsDepth;
00062        unsigned int texture;
00063 
00064        GLfloat       xpos,  ypos,  zpos,
00065               xspeed,       yspeed,       zspeed,
00066               zacc;
00067 
00068        GLfloat colour[4],
00069               life, startLife,
00070               pixelSize;
00071 
00072        bool useLife;
00073        int flicker;
00074 
00075     private:
00076        Particle();
00077 };
00078 
00079 
00080 /* -- TurningParticle class.
00081  * Randomize initial parameters similar to a standard 'spherical' particle 
00082  * and takes care of updating physics. The physics model is a funny 'bees'
00083  * (vectorial-product) one.
00084  */
00085 class TurningParticle : public Particle
00086 {
00087     public:
00088        TurningParticle( ParticleType pT );
00089 
00090        virtual void initializeValues (
00091               int color_scheme = 0,
00092               Particle* leader = 0L,
00093               GLfloat powermin = 5.0,
00094               GLfloat powermax = 10.0,
00095               bool flickers = false,
00096               GLfloat *displace = 0L );
00097 
00098        virtual void updateParameters ( float dT );
00099 
00100     private:
00101        float wx, wy, wz;
00102        TurningParticle();
00103 };
00104 
00105 #endif