[Plib-cvs] plib/src/ssgAux ssgaFire.cxx,1.1,1.2 ssgaFire.h,1.1,1.2 ssgaParticleSystem.cxx,1.7,1.8 ss
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-08-28 04:58:06
|
Update of /cvsroot/plib/plib/src/ssgAux In directory usw-pr-cvs1:/tmp/cvs-serv26519/plib/src/ssgAux Modified Files: ssgaFire.cxx ssgaFire.h ssgaParticleSystem.cxx ssgaParticleSystem.h Log Message: Added much tweakability and ease-of-setup to ssgaFire. Index: ssgaFire.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaFire.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ssgaFire.cxx 28 Aug 2002 00:14:34 -0000 1.1 +++ ssgaFire.cxx 28 Aug 2002 04:58:03 -0000 1.2 @@ -2,30 +2,101 @@ #include "ssg.h" #include "ssgAux.h" +#define EMBER_SCALE 3.0f + void _ssgaFireParticleCreate ( ssgaParticleSystem *ps, - int index, - ssgaParticle *p ) + int idx, ssgaParticle *p ) { - sgSetVec4 ( p -> col, 1.0f, 0.2f, 0.06f, 0.3 ) ; [...154 lines suppressed...] + colourTable = NULL ; + sizeTable = NULL ; + + sgSetVec4 ( hot_colour, 1.0f, 0.2f, 0.1f, 1.0f ) ; + + setHeight ( height ) ; /* Forces a reInit */ + setState ( fireState ) ; setCallback ( SSG_CALLBACK_PREDRAW , preFireDraw ) ; setCallback ( SSG_CALLBACK_POSTDRAW, postFireDraw ) ; @@ -94,6 +176,9 @@ ssgaFire::~ssgaFire () { + tableSize = 0 ; + delete [] colourTable ; + delete [] sizeTable ; } Index: ssgaFire.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaFire.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ssgaFire.h 28 Aug 2002 00:14:34 -0000 1.1 +++ ssgaFire.h 28 Aug 2002 04:58:03 -0000 1.2 @@ -4,16 +4,52 @@ class ssgaFire : public ssgaParticleSystem { + int tableSize ; + float *colourTable ; + float *sizeTable ; + + sgVec4 hot_colour ; + float max_ttl ; + float start_size ; + float upward_speed ; + float radius ; + + void reInit () ; + public: - ssgaFire ( int num, - int initial_num, - float _create_rate, - float bsphere_size ) ; + void createParticle ( int idx, ssgaParticle *p ) ; + void updateParticle ( int idx, ssgaParticle *p ) ; + + ssgaFire ( int num_tris, float _radius = 1.0f, + float height = 5.0f, + float speed = 2.0f ) ; virtual ~ssgaFire () ; virtual void update ( float t ) ; + + void setUpwardSpeed ( float spd ) + { + upward_speed = spd ; + } + + void setHeight ( float hgt ) + { + max_ttl = hgt / upward_speed ; + getBSphere () -> setRadius ( hgt * 2.0f ) ; + getBSphere () -> setCenter ( 0, 0, 0 ) ; + reInit () ; + } + + void setHotColour ( sgVec4 col ) + { + sgCopyVec4 ( hot_colour, col ) ; + reInit () ; + } + + void getHotColour ( sgVec4 col ) { sgCopyVec4 ( col, hot_colour ) ; } + } ; unsigned char *_ssgaGetFireTexture () ; Index: ssgaParticleSystem.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaParticleSystem.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ssgaParticleSystem.cxx 28 Aug 2002 00:14:34 -0000 1.7 +++ ssgaParticleSystem.cxx 28 Aug 2002 04:58:03 -0000 1.8 @@ -7,12 +7,11 @@ ssgaParticleCreateFunc _particle_create, ssgaParticleUpdateFunc _particle_update, ssgaParticleDeleteFunc _particle_delete ) : - ssgVtxArray ( GL_QUADS, + ssgVtxTable ( GL_QUADS, new ssgVertexArray ( num * 4, new sgVec3 [ num * 4 ] ), new ssgNormalArray ( num * 4, new sgVec3 [ num * 4 ] ), new ssgTexCoordArray ( num * 4, new sgVec2 [ num * 4 ] ), - new ssgColourArray ( num * 4, new sgVec4 [ num * 4 ] ), - new ssgIndexArray ( num * 4, new short [ num * 4 ] ) ) + new ssgColourArray ( num * 4, new sgVec4 [ num * 4 ] ) ) [...82 lines suppressed...] - (*particle_update) ( t, this, i, & particle [ i ] ) ; + if ( particle [ i ] . time_to_live > 0.0f ) + { + particle [ i ] . update ( t ) ; + (*particle_update) ( t, this, i, & particle [ i ] ) ; + } + } + else + for ( i = 0 ; i < num_particles ; i++ ) + if ( particle [ i ] . time_to_live > 0.0f ) + particle [ i ] . update ( t ) ; /* Check for death of particles */ for ( i = 0 ; i < num_particles ; i++ ) - if ( particle [ i ] . time_to_live < 0.0 ) + if ( particle [ i ] . time_to_live <= 0.0 ) { if ( particle_delete ) (*particle_delete) ( this, i, & particle [ i ] ) ; Index: ssgaParticleSystem.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaParticleSystem.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ssgaParticleSystem.h 27 Aug 2002 22:40:11 -0000 1.4 +++ ssgaParticleSystem.h 28 Aug 2002 04:58:03 -0000 1.5 @@ -50,7 +50,7 @@ int index, ssgaParticle *p ) ; -class ssgaParticleSystem : public ssgVtxArray +class ssgaParticleSystem : public ssgVtxTable { int num_particles ; int num_verts ; @@ -84,8 +84,11 @@ void draw_geometry () ; - int getNumActiveParticles () { return num_active ; } + void setCreationRate ( float cr ) { create_rate = cr ; } + float getCreationRate () { return create_rate ; } + int getNumParticles () { return num_particles ; } + int getNumActiveParticles () { return num_active ; } } ; |