Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members

ssgaWaveSystem2.h

Go to the documentation of this file.
00001 /*
00002      PLIB - A Suite of Portable Game Libraries
00003      Copyright (C) 1998,2002  Steve Baker
00004  
00005      This library is free software; you can redistribute it and/or
00006      modify it under the terms of the GNU Library General Public
00007      License as published by the Free Software Foundation; either
00008      version 2 of the License, or (at your option) any later version.
00009  
00010      This library is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013      Library General Public License for more details.
00014  
00015      You should have received a copy of the GNU Library General Public
00016      License along with this library; if not, write to the Free Software
00017      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018  
00019      For further information visit http://plib.sourceforge.net                  */
00020 
00021 
00022 #ifndef WAVESYSTEM2_H
00023 #define WAVESYSTEM2_H
00024 
00025 #include <plib/ssgaShapes.h>
00026 
00027 typedef float (* ssgaWSDepthCallback ) ( float x, float y ) ;
00028 
00029 #define SSGA_MAX_WAVETRAIN  16
00030 
00031 class ssgaWaveTrain;
00032 
00033 class ssgaWaveSystem2 : public ssgaShape
00034 {
00035         protected:
00036  ssgaWSDepthCallback gridGetter ;
00037 
00038   sgVec3 *normals   ;
00039   sgVec4 *colours   ;
00040   sgVec2 *texcoords ;
00041   sgVec3 *vertices  ;
00042   sgVec3 *orig_vertices  ;
00043 
00044   ssgaWaveTrain *train [ SSGA_MAX_WAVETRAIN ] ;
00045 
00046   float windSpeed   ;
00047   float windHeading ;
00048   float edgeFlatten ;
00049 
00050   float tu, tv ;
00051 
00052   int nstrips ;
00053   int nstacks ;
00054 
00055   float roughness;
00056   float tex_noise;
00057   sgPerlinNoise_3D noiser;
00058   float time_iterator;
00059   bool active;
00060   virtual void copy_from ( ssgaWaveSystem2 *src, int clone_flags ) ;
00061 public:
00062 
00063   ssgaWaveSystem2 ( int ntri ) ;
00064   void set_active();
00065   virtual ~ssgaWaveSystem2 () ;
00066 
00067   virtual ssgBase    *clone       ( int clone_flags = 0 ) ;
00068   virtual void        regenerate  () ;
00069   virtual const char *getTypeName ( void ) ;
00070  
00071   virtual int load ( FILE * ) ;
00072   virtual int save ( FILE * ) ;
00073 
00074   inline void setNumTris ( int ntri ) { ntriangles = ntri ; regenerate () ; }
00075   inline void set_tex_noise(float tn) { tex_noise = tn;}
00076   inline void set_roughness (float r) { roughness = r;}
00077   inline float get_tex_noise() { return tex_noise;}
00078   inline float get_roughness() { return roughness;}
00079   
00080   ssgaWSDepthCallback getDepthCallback () { return gridGetter ; } 
00081 
00082   ssgaWaveTrain *getWaveTrain ( int i )
00083   {
00084     return ( i < 0 || i >= SSGA_MAX_WAVETRAIN ) ? NULL : train [ i ] ;
00085   }
00086 
00087   void setWaveTrain ( int i, ssgaWaveTrain *t )
00088   {
00089     assert ( i >= 0 && i < SSGA_MAX_WAVETRAIN ) ;
00090     train [ i ] = t ;
00091   }
00092 
00093   float getWindSpeed     () { return windSpeed   ; }
00094   float getWindDirn      () { return windHeading ; }
00095   float getEdgeFlatten   () { return edgeFlatten ; }
00096   float getTexScaleU () { return tu ; }
00097   float getTexScaleV () { return tv ; }
00098 
00099   void  setDepthCallback ( ssgaWSDepthCallback cb ) { gridGetter  = cb ; } 
00100   void  setWindSpeed     ( float speed            ) { windSpeed   = speed ; }
00101   void  setWindDirn      ( float dirn             ) { windHeading = dirn  ; }
00102   void  setEdgeFlatten   ( float dist             ) { edgeFlatten = dist ; }
00103   void  setTexScale      ( float u, float v       ) { tu = u ; tv = v ; }
00104 
00105   void updateAnimation ( float t ) ;
00106 } ;
00107 
00108 #endif

Generated on Sat Jul 12 04:29:21 2003 for glPirates by doxygen 1.3.2