[Plib-cvs] plib/src/ssgAux ssgaWaveSystem.cxx,NONE,1.1 ssgaWaveSystem.h,NONE,1.1 Makefile.am,1.7,1.8
Brought to you by:
sjbaker
Update of /cvsroot/plib/plib/src/ssgAux In directory usw-pr-cvs1:/tmp/cvs-serv1417/plib/src/ssgAux Modified Files: Makefile.am ssgAux.h ssgaPatch.cxx ssgaShapes.cxx ssgaShapes.h ssgaTeapot.cxx Added Files: ssgaWaveSystem.cxx ssgaWaveSystem.h Log Message: Added ssgaWaveSystem Fixed a bug in all ssgaShape's. --- NEW FILE: ssgaWaveSystem.cxx --- /* PLIB - A Suite of Portable Game Libraries Copyright (C) 2001 Steve Baker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA [...269 lines suppressed...] } int ssgaWaveSystem::save ( FILE *fp ) { return ( save_field ( fp, windSpeed ) && save_field ( fp, windHeading ) && save_field ( fp, waveHeight ) && save_field ( fp, kappa ) && save_field ( fp, lambda ) && save_field ( fp, omega ) && save_field ( fp, edgeFlatten ) && save_field ( fp, tu ) && save_field ( fp, tv ) && ssgaShape::save ( fp ) ) ; } --- NEW FILE: ssgaWaveSystem.h --- #include "ssgaShapes.h" typedef float (* ssgaWSDepthCallback ) ( float x, float y ) ; class ssgaWaveSystem : public ssgaShape { ssgaWSDepthCallback gridGetter ; sgVec3 *normals ; sgVec4 *colours ; sgVec2 *texcoords ; sgVec3 *vertices ; sgVec3 *orig_vertices ; float windSpeed ; float windHeading ; float waveHeight ; float kappa ; float lambda ; float omega ; float edgeFlatten ; float tu, tv ; int nstrips ; int nstacks ; protected: virtual void copy_from ( ssgaWaveSystem *src, int clone_flags ) ; public: ssgaWaveSystem ( int ntri ) ; virtual ~ssgaWaveSystem () ; virtual ssgBase *clone ( int clone_flags = 0 ) ; virtual void regenerate () ; virtual const char *getTypeName ( void ) ; virtual int load ( FILE * ) ; virtual int save ( FILE * ) ; ssgaWSDepthCallback getDepthCallback () { return gridGetter ; } float getWindSpeed () { return windSpeed ; } float getWindDirn () { return windHeading ; } float getWaveHeight () { return waveHeight ; } float getEdgeFlatten () { return edgeFlatten ; } void setDepthCallback ( ssgaWSDepthCallback cb ) { gridGetter = cb ; } void setWindSpeed ( float speed ) { windSpeed = speed ; } void setWindDirn ( float dirn ) { windHeading = dirn ; } void setWaveHeight ( float height ) { waveHeight = height ; } void setEdgeFlatten ( float dist ) { edgeFlatten = dist ; } void setTexScale ( float u, float v ) { tu = u ; tv = v ; } void updateAnimation ( float t ) ; } ; Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 13 Jan 2002 02:13:15 -0000 1.7 +++ Makefile.am 4 Aug 2002 05:53:44 -0000 1.8 @@ -1,12 +1,13 @@ lib_LIBRARIES = libplibssgaux.a -include_HEADERS = ssgAux.h ssgaShapes.h ssgaParticleSystem.h +include_HEADERS = ssgAux.h ssgaShapes.h ssgaParticleSystem.h ssgaWaveSystem.h libplibssgaux_a_SOURCES = ssgAux.cxx \ ssgaShapes.cxx \ ssgaPatch.cxx \ ssgaParticleSystem.cxx \ + ssgaWaveSystem.cxx \ ssgaTeapot.cxx INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/ssg Index: ssgAux.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgAux.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ssgAux.h 13 Jan 2002 02:13:15 -0000 1.10 +++ ssgAux.h 4 Aug 2002 05:53:44 -0000 1.11 @@ -29,6 +29,7 @@ #include "ssg.h" #include "ssgaShapes.h" #include "ssgaParticleSystem.h" +#include "ssgaWaveSystem.h" #define _SSGA_TYPE_SHAPE 0x00008000 @@ -38,6 +39,7 @@ #define _SSGA_TYPE_PATCH 0x00010000 #define _SSGA_TYPE_TEAPOT 0x00020000 #define _SSGA_TYPE_PARTICLESYSTEM 0x00040000 +#define _SSGA_TYPE_WAVESYSTEM 0x00080000 inline int ssgaTypeShape () { return _SSGA_TYPE_SHAPE | ssgTypeBranch ();} inline int ssgaTypeCube () { return _SSGA_TYPE_CUBE | ssgaTypeShape ();} @@ -47,6 +49,8 @@ inline int ssgaTypeTeapot () { return _SSGA_TYPE_TEAPOT | ssgaTypeShape ();} inline int ssgaTypeParticleSystem () { return _SSGA_TYPE_PARTICLESYSTEM | ssgaTypeShape ();} +inline int ssgaTypeWaveSystem () + { return _SSGA_TYPE_WAVESYSTEM | ssgaTypeShape ();} void ssgaInit () ; Index: ssgaPatch.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaPatch.cxx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ssgaPatch.cxx 7 Nov 2001 23:51:10 -0000 1.3 +++ ssgaPatch.cxx 4 Aug 2002 05:53:44 -0000 1.4 @@ -29,7 +29,9 @@ void ssgaPatch::regenerate () { + if ( kidState != NULL ) kidState -> ref () ; removeAllKids () ; + if ( kidState != NULL ) kidState -> deRef () ; if ( ntriangles <= 2 ) levels = -1 ; else if ( ntriangles <= 18 ) levels = 0 ; else Index: ssgaShapes.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaShapes.cxx,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ssgaShapes.cxx 10 Jun 2002 20:41:46 -0000 1.21 +++ ssgaShapes.cxx 4 Aug 2002 05:53:44 -0000 1.22 @@ -139,7 +139,7 @@ type = ssgaTypeSphere () ; latlong_style = TRUE ; regenerate () ; -} +} ssgaSphere ::ssgaSphere (int nt) : ssgaShape ( nt ) @@ -147,7 +147,7 @@ type = ssgaTypeSphere () ; latlong_style = TRUE ; regenerate () ; -} +} ssgaCylinder::ssgaCylinder ( void ) : ssgaShape () @@ -183,17 +183,24 @@ void ssgaCube ::regenerate () { + if ( kidState != NULL ) kidState -> ref () ; removeAllKids () ; + if ( kidState != NULL ) kidState -> deRef () ; if ( ntriangles == 0 ) return ; - ssgVtxTable *vt0 = new ssgVtxTable () ; ssgVtxTable *vt1 = new ssgVtxTable () ; + ssgVtxTable *vt0 = new ssgVtxTable () ; + ssgVtxTable *vt1 = new ssgVtxTable () ; - ssgVertexArray *v0 = new ssgVertexArray ( 8 ) ; ssgVertexArray *v1 = new ssgVertexArray ( 8 ) ; - ssgNormalArray *n0 = new ssgNormalArray ( 8 ) ; ssgNormalArray *n1 = new ssgNormalArray ( 8 ) ; - ssgColourArray *c0 = new ssgColourArray ( 8 ) ; ssgColourArray *c1 = new ssgColourArray ( 8 ) ; - ssgTexCoordArray *t0 = new ssgTexCoordArray ( 8 ) ; ssgTexCoordArray *t1 = new ssgTexCoordArray ( 8 ) ; + ssgVertexArray *v0 = new ssgVertexArray ( 8 ) ; + ssgVertexArray *v1 = new ssgVertexArray ( 8 ) ; + ssgNormalArray *n0 = new ssgNormalArray ( 8 ) ; + ssgNormalArray *n1 = new ssgNormalArray ( 8 ) ; + ssgColourArray *c0 = new ssgColourArray ( 8 ) ; + ssgColourArray *c1 = new ssgColourArray ( 8 ) ; + ssgTexCoordArray *t0 = new ssgTexCoordArray ( 8 ) ; + ssgTexCoordArray *t1 = new ssgTexCoordArray ( 8 ) ; vt0 -> setPrimitiveType ( GL_TRIANGLE_STRIP ) ; vt1 -> setPrimitiveType ( GL_TRIANGLE_STRIP ) ; @@ -629,7 +636,9 @@ void ssgaSphere::regenerate () { + if ( kidState != NULL ) kidState -> ref () ; removeAllKids () ; + if ( kidState != NULL ) kidState -> deRef () ; if ( ntriangles == 0 ) return ; @@ -644,7 +653,9 @@ void ssgaCylinder::regenerate () { + if ( kidState != NULL ) kidState -> ref () ; removeAllKids () ; + if ( kidState != NULL ) kidState -> deRef () ; if ( ntriangles == 0 ) return ; Index: ssgaShapes.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaShapes.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ssgaShapes.h 10 Jun 2002 20:41:49 -0000 1.10 +++ ssgaShapes.h 4 Aug 2002 05:53:44 -0000 1.11 @@ -59,11 +59,12 @@ virtual ~ssgaShape (void) ; virtual const char *getTypeName(void) ; - void makeCorrupt () { corrupted = TRUE ; } - int isCorrupt () { return corrupted ; } + void makeCorrupt () { corrupted = TRUE ; } + int isCorrupt () { return corrupted ; } - float *getCenter () { return center ; } - float *getSize () { return size ; } + float *getCenter () { return center ; } + float *getSize () { return size ; } + int getNumTris () { return ntriangles ; } void setColour ( sgVec4 c ) { sgCopyVec4 ( colour, c ) ; regenerate () ; } void setCenter ( sgVec3 c ) { sgCopyVec3 ( center, c ) ; regenerate () ; } Index: ssgaTeapot.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssgAux/ssgaTeapot.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ssgaTeapot.cxx 7 Nov 2001 23:51:10 -0000 1.4 +++ ssgaTeapot.cxx 4 Aug 2002 05:53:44 -0000 1.5 @@ -224,7 +224,9 @@ void ssgaTeapot::regenerate () { + if ( kidState != NULL ) kidState -> ref () ; removeAllKids () ; + if ( kidState != NULL ) kidState -> deRef () ; for ( int i = 0 ; patch[i][0] >= 0 ; i++ ) { |