SmokeVol.h

Go to the documentation of this file.
00001 //##################################################
00002 //# $Id: SmokeVol.h 359 2005-12-26 17:22:09Z herout $
00003 //##################################################
00004 
00005 #ifndef _SmokeVol_h_
00006 #define _SmokeVol_h_
00007 
00008 #define _rev_SmokeVol_h_ "$Id: SmokeVol.h 359 2005-12-26 17:22:09Z herout $" 
00009 
00010 
00016 #include "Transparency.h"
00017 #include "Effect.h"
00018 #include "Color.h"
00019 #include "TexNoise.h"
00020 #include "Environment.h"
00021 
00022 #define TEXTURE_SIZE                    128                     
00023 #define NUM_TEXTURES                    16                      
00024 
00025 
00029 class TNoiseTexture
00030 {
00031   private:
00032     float   textArr[NUM_TEXTURES][TEXTURE_SIZE][TEXTURE_SIZE];          
00033   public:
00034     TNoiseTexture( float density, int octaves ); 
00035     void createTextures( float density, int octaves ); 
00036     float getTexturePoint( int x, int y, int n );
00037 };
00038 
00039 
00043 class TSmokeVol : public TEffect 
00044 {
00045 public:
00049   class TParticle : TTransparent 
00050   {
00051     friend class TSmokeVol;
00052   private:
00053     TVector   position;                         
00054     TVector   direction;                        
00055     float     time2LiveInit;            
00056     float     time2Live;                        
00057     float     size;                                     
00058         float     sizeStart;                    
00059         float     sizeEnd;                              
00060     float     dsize;                            
00061     TColor    color;                            
00062     TColor    colorEnd;                         
00063         TColor    colorStart;                   
00064     TColor    dcolor;                           
00065     bool      free;                                     
00066     unsigned  texId;                            
00067     int       method;                           
00068         bool      wind;                                 
00069         bool      gravity;                              
00070         float     mass;                                 
00071 
00072   public:
00073     TParticle();
00074     ~TParticle();
00075     void UpdateTexture( const double &time, char * str, int texture );
00076         virtual void Render( TCamera *Camera );
00077     virtual void Schedule( TCamera *Camera );
00078 
00079         bool IsAlive() const { return ( ( time2Live > 0) && ( !free ) ); }                      
00080     void Move( const double &delta );
00081 //    void SetColor( const TColor &colorStart, const TColor &colorEnd, int method );
00082         void FireAt( const TVector &position, const TVector &direction, float time2Live,
00083                  float sizeStart, float sizeEnd, const TColor &colorStart,
00084                  const TColor &colorEnd,int method, int &lastText, bool wind,
00085                                  bool gravity, float mass );
00086   };
00087 
00091   class TInterpolation
00092   {
00093   public:
00096     enum eInterpolationMethod { Linear, Exponential };
00097 
00098   private:
00099     static eInterpolationMethod si_method;                              
00100 
00101   public:
00102     static void Init();
00103     static eInterpolationMethod getMethod();
00104     static void changeMethod( eInterpolationMethod method );
00105   };
00106 
00107 
00111   class TRendering
00112   {
00113   public:
00116     enum eRenderingMethod { ParticlesOnly, Billboards, TexturedBillboards };
00117 
00118   private:
00119     static eRenderingMethod sr_method;                                                                                  
00120 
00121   public:
00122     static void Init();
00123     static eRenderingMethod getMethod();
00124     static void changeMethod( eRenderingMethod method );
00125   };
00126   
00127 protected:
00128   bool        existent;                 
00129   TVector     position;                 
00130   TVector     dposition;                
00131   TVector     direction;                
00132   float       size;                             
00133   float       dispersion;               
00134   float       speed;                    
00135   int         maxCount;                 
00136   int         actCount;                 
00137   float       PPS;                              
00138   float       actPPS;                   
00139   float       partSizeStart;    
00140   float       partSizeEnd;              
00141   float       partTTL;                  
00142   float       duration;                 
00143   float       durationOld;              
00144   TParticle*  particles;                
00145   float       last_delta;               
00146   TColor      colorStart;               
00147   TColor      colorEnd;                 
00148   int         method;                   
00149   bool        wind;                             
00150   bool        gravity;                  
00151   int             lastTex;                      
00152   float       mass;                             
00153 
00154 public: 
00155   static TInterpolation Interpolation;          
00156   static TRendering             Rendering;                      
00157 
00158   TSmokeVol( float size, int maxCount, float duration, float PPS, float partSizeStart, float partSizeEnd, bool wind, bool gravity );
00159   virtual ~TSmokeVol();
00160   virtual void TimeTick( const double &time, const double &delta ); 
00161   virtual void Render( TCamera *Camera );
00162   virtual bool IsExistent() { return existent; }
00163   virtual void Move( const double &delta );
00164   virtual void GenerateParticles();  
00165   virtual void FireAt( const TVector &position, const TVector &dposition, float power, const TVector &direction, float partTTL, float disp, float mass );
00166   virtual void SetColor( const TColor &colorStart, const TColor &colorEnd, int method );
00167 };
00168 
00169 float GetRandomFloat(float mid, float delta);
00170 float interpolateNoise(int x, int y, float arr[TEXTURE_SIZE][TEXTURE_SIZE], int del );
00171 void updateField( float arrx[TEXTURE_SIZE][TEXTURE_SIZE], float arr[TEXTURE_SIZE][TEXTURE_SIZE], int del );
00172 
00173 #endif
00174 
00175 
00176 

Viewable With Any Browser   Valid HTML 4.01!   Generated on Fri Apr 14 08:04:17 2006 for TankGame by doxygen 1.4.6-NO