Back to index

kdeartwork  4.3.2
Public Types | Public Member Functions | Public Attributes | Private Member Functions
Particle Struct Reference

#include <firesaverparticle.h>

Inheritance diagram for Particle:
Inheritance graph
[legend]

List of all members.

Public Types

enum  ParticleType {
  FireParticle, FireWorkLeaderParticle, FireWorkDebrisParticle, LogoParticle,
  StarParticle
}

Public Member Functions

 Particle (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 timeGap)

Public Attributes

ParticleType particleType
int explosionsDepth
unsigned int texture
GLfloat xpos
GLfloat ypos
GLfloat zpos
GLfloat xspeed
GLfloat yspeed
GLfloat zspeed
GLfloat zacc
GLfloat colour [4]
GLfloat life
GLfloat startLife
GLfloat pixelSize
bool useLife
int flicker
float x
float y
float z
float r
float g
float b

Private Member Functions

 Particle ()

Detailed Description

Definition at line 33 of file firesaverparticle.h.


Member Enumeration Documentation

Enumerator:
FireParticle 
FireWorkLeaderParticle 
FireWorkDebrisParticle 
LogoParticle 
StarParticle 

Definition at line 37 of file firesaverparticle.h.


Constructor & Destructor Documentation

Definition at line 37 of file firesaverparticle.cpp.

    : particleType( pT ), explosionsDepth( 0 ), texture( 0 ),
    xpos( 0.0 ), ypos( 0.0 ), zpos( -9.9 ),
    xspeed( 0.0 ), yspeed( 0.0 ), zspeed( 0.0 ), zacc( -9.807 ),
    life( 0.0 ), startLife( 0.0 ),
    pixelSize( 5.0 ), useLife( true ), flicker( 0 )
{
       colour[0] = 0;
       colour[1] = 0;
       colour[2] = 0;
       colour[3] = 1;
}
Particle::Particle ( ) [private]

Member Function Documentation

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

Reimplemented in TurningParticle.

Definition at line 51 of file firesaverparticle.cpp.

{
       switch (particleType)
       {
//     -- FireParticle (params: [cs])
//            born in a rectangle centered in { 0, 0, -9.9 }
//            speed 3-6 [m/s] blue/cyan colored
//            this is only done at the beginning or when a particle dies
           case FireParticle:
              xpos = DRAND * FIELDWIDTH - FIELDW_2;
              ypos = DRAND - 2.0;

              xspeed = DRAND * 4.0 - 2.0;
              yspeed = DRAND * 2.0;
              zspeed = DRAND * 3.0 + 3.0;

              useLife = false;
              pixelSize = 2.0 + DRAND * 2.0;
              break;

//     -- FireWorkLeaderParticle (params: none)
//            they start in a rectangle at the same height but
//            with different power and the same 'orange' colour
           case FireWorkLeaderParticle:
              xpos = DRAND * 14.0 - 7.0;
              ypos = DRAND * 2.0 - 1.0;

              xspeed = DRAND * 8.0 - 4.0 - (xpos / 2.0)*DRAND;
              yspeed = DRAND * 8.0 - 4.0;
              zspeed = DRAND * 6.5 + 18.0;

              colour[0] = 0.6;
              colour[1] = DRAND * 0.4;
              colour[2] = 0.0;

              useLife = false;
              break;

//     -- LogoParticle (params: none)
//            they start in the middle of the screen.
//            little g-force, constant life, weavy-y
           case LogoParticle:
              yspeed = 3*(DRAND - DRAND);
              zacc = -9.807f / 5.0f;

              startLife = 0.7f;
              life = 1.7f;
              break;

//     -- StarParticle (params: none)
//            spherically distributed. xpos and ypos are the
//            transformed screen positions of the star.
           case StarParticle:
              colour[0] = DRAND * 0.2 + 0.5;
              colour[1] = DRAND * 0.2 + 0.5;
              colour[2] = DRAND * 0.2 + 0.5;

              {bool accepted = false;
              while (!accepted) {
                     float module = 30,
                           theta = DRAND * M_PI * 2.0,
                           u = DRAND * 2.0 - 1.0,
                           root = sqrt( 1 - u*u );
                     xpos = module * root * cos(theta);
                     ypos = fabs(module * root * sin(theta)) - 10.0;
                     zpos = fabs(module * u);

                     float sfactor = 256.0 / (256.0 + PERSP_MAG_FACTOR*ypos);
                     xpos *= sfactor;
                     ypos = sfactor * zpos - FIELDW_2;

                     pixelSize = sfactor * (2.0 + 3.0*DRAND);

                     accepted = xpos > -FIELDW_2 && xpos < FIELDW_2 &&
                               ypos > -FIELDW_2 && ypos < FIELDW_2;
              }}
              break;

//     -- FireWorkDebrisParticle (params: cs, parent, [powerm], [powerM], [flickers], [displace])
//            parameters are randomized for a 'spherical' explosion.
//            power{min,max}, flickers and displace applies only for that
//            kind of ParticleType.
           case FireWorkDebrisParticle:

              //same origin of the dead leader
              xpos = debrisParent->xpos;
              ypos = debrisParent->ypos;
              zpos = debrisParent->zpos;

              //true spherical randomization
              float module = powermin + DRAND * (powermax - powermin),
                    theta = DRAND * M_PI * 2.0,
                    u = DRAND * 2.0 - 1.0,
                    root = sqrt( 1 - u*u );
              xspeed = debrisParent->xspeed + module * root * cos(theta) * (1.0 + DRAND/3.0);
              yspeed = debrisParent->yspeed + module * root * sin(theta) * (1.0 + DRAND/3.0);
              zspeed = module * u * (1.0 + DRAND/3.0);  //was 0.9 + DRAND/3

              //if set add a displace to speed
              if ( displace ) {
                     xspeed += displace[0];
                     yspeed += displace[1];
                     zspeed += displace[2];
              }

              //randomize the color choosing on current palette
              colour[0] = c_red_min[cs] + (c_red_max[cs]-c_red_min[cs]) * DRAND;
              colour[1] = c_green_min[cs] + (c_green_max[cs]-c_green_min[cs]) * DRAND;
              colour[2] = c_blue_min[cs] + (c_blue_max[cs]-c_blue_min[cs]) * DRAND;

              pixelSize = DRAND * 2.0 + 2.0;
              zacc = -9.807 / (6.0 - pixelSize);

              life = startLife = pixelSize / 2.0;

              //if flickers is set the current visible delay is randomized
              if ( flickers )
                     flicker = (int) ((DRAND * 2.0 - 1.0) * (float)FLICKER_FRAMES_DELAY);
              break;
       }
}

Here is the caller graph for this function:

void Particle::updateParameters ( float  timeGap) [virtual]

Reimplemented in TurningParticle.

Definition at line 181 of file firesaverparticle.cpp.

{
       xpos += xspeed * dT;
       ypos += yspeed * dT;
       zpos += (zspeed + zacc*dT/2) * dT;

       zspeed += zacc * dT;

       xspeed *= 0.998;
       yspeed *= 0.998;
       zspeed *= 0.999;

       if (useLife)
           life -= dT;
}

Here is the caller graph for this function:


Member Data Documentation

float Particle::b

Definition at line 61 of file SolarWinds.cpp.

GLfloat Particle::colour[4]

Definition at line 68 of file firesaverparticle.h.

Definition at line 61 of file firesaverparticle.h.

Definition at line 73 of file firesaverparticle.h.

float Particle::g

Definition at line 61 of file SolarWinds.cpp.

GLfloat Particle::life

Definition at line 68 of file firesaverparticle.h.

Definition at line 60 of file firesaverparticle.h.

Definition at line 68 of file firesaverparticle.h.

float Particle::r

Definition at line 61 of file SolarWinds.cpp.

Definition at line 68 of file firesaverparticle.h.

unsigned int Particle::texture

Definition at line 62 of file firesaverparticle.h.

Definition at line 72 of file firesaverparticle.h.

float Particle::x

Definition at line 60 of file SolarWinds.cpp.

GLfloat Particle::xpos

Definition at line 64 of file firesaverparticle.h.

Definition at line 64 of file firesaverparticle.h.

float Particle::y

Definition at line 60 of file SolarWinds.cpp.

GLfloat Particle::ypos

Definition at line 64 of file firesaverparticle.h.

Definition at line 64 of file firesaverparticle.h.

float Particle::z

Definition at line 60 of file SolarWinds.cpp.

GLfloat Particle::zacc

Definition at line 64 of file firesaverparticle.h.

GLfloat Particle::zpos

Definition at line 64 of file firesaverparticle.h.

Definition at line 64 of file firesaverparticle.h.


The documentation for this struct was generated from the following files: