Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 20, 2006, 3:42:03 PM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: creating clouds with the shader works, animation of the clouds with the shader still not working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8495 r8636  
    1515#include "shader.h"
    1616
    17 class CloudEffect : public WeatherEffect {
     17#define MAXB 0x100
     18#define N 0x1000
     19#define NP 12   /* 2^N */
     20#define NM 0xfff
     21
     22#define s_curve(t) ( t * t * (3. - 2. * t) )
     23#define lerp(t, a, b) ( a + t * (b - a) )
     24#define setup(i,b0,b1,r0,r1)\
     25        t = vec[i] + N;\
     26        b0 = ((int)t) & BM;\
     27        b1 = (b0+1) & BM;\
     28        r0 = t - (int)t;\
     29        r1 = r0 - 1.;
     30#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
     31#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
     32
     33class CloudEffect : public WeatherEffect
     34{
    1835public:
    19     CloudEffect(const TiXmlElement* root = NULL);
    20     virtual ~CloudEffect();
     36  CloudEffect(const TiXmlElement* root = NULL);
     37  virtual ~CloudEffect();
    2138
    22     virtual void loadParams(const TiXmlElement* root);
     39  virtual void loadParams(const TiXmlElement* root);
    2340
    24     virtual void init();
     41  virtual void init();
    2542
    26     virtual void activate();
    27     virtual void deactivate();
     43  virtual void activate();
     44  virtual void deactivate();
    2845
    29     inline void activateCloud() {
    30         this->activate();
    31     }
    32     inline void deactivateCloud() {
    33         this->deactivate();
    34     }
     46  inline void activateCloud()
     47  {
     48    this->activate();
     49  }
     50  inline void deactivateCloud()
     51  {
     52    this->deactivate();
     53  }
    3554
    36     virtual void draw() const;
    37     virtual void tick(float dt);
     55  virtual void draw() const;
     56  virtual void tick(float dt);
    3857
    39     /*inline void setCloudOption(const std::string& option) {
    40         if (option == "activate")
    41     this->cloudActivate = true;
    42 }*/
     58  void make3DNoiseTexture();
     59  void initNoise();
     60  void SetNoiseFrequency(int frequency);
     61  double noise3(double vec[3]);
     62  void normalize2(double v[2]);
     63  void normalize3(double v[3]);
     64
     65  /*inline void setCloudOption(const std::string& option) {
     66      if (option == "activate")
     67  this->cloudActivate = true;
     68  }*/
    4369
    4470
    4571private:
    46     //void initialize(char* fileName);
     72  //void initialize(char* fileName);
    4773
    48     //bool        cloudActivate;
     74  //bool        cloudActivate;
    4975
    50     Material                 cloudMaterial;
    51     Shader*                 shader;
     76  // Material                 cloudMaterial;
     77  Shader*                 shader;
     78  Shader::Uniform*        offset;
     79 
     80  float coor;
     81
     82  int noise3DTexSize;
     83  GLuint noise3DTexName;
     84  GLubyte *noise3DTexPtr;
     85
     86  int p[MAXB + MAXB + 2];
     87  double g3[MAXB + MAXB + 2][3];
     88  double g2[MAXB + MAXB + 2][2];
     89  double g1[MAXB + MAXB + 2];
     90
     91  int start;
     92  int B;
     93  int BM;
    5294};
    5395
Note: See TracChangeset for help on using the changeset viewer.