Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 21, 2006, 1:56:41 PM (19 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: implemented a sky plane with the cloud shader on it

File:
1 edited

Legend:

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

    r8663 r8668  
    3131#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
    3232
     33
     34#define DTOR (PI/180.0f)
     35#define SQR(x) (x*x)
     36
     37typedef struct {
     38  float x,y,z;
     39  unsigned int color;
     40  float u, v;
     41} VERTEX;
     42
     43
    3344class CloudEffect : public WeatherEffect
    3445{
     
    4556
    4657  inline void activateCloud()
    47   {
    48     this->activate();
    49   }
     58  { this->activate(); }
     59 
    5060  inline void deactivateCloud()
    51   {
    52     this->deactivate();
    53   }
     61  { this->deactivate(); }
     62 
    5463  inline void setCloudOption(const std::string& option)
    5564  {
     
    5766      this->cloudActivate = true;
    5867  }
     68 
    5969  inline void setAnimationSpeed(float speed)
    60   {
    61     this->animationSpeed = speed;
    62   }
     70  { this->animationSpeed = speed; }
     71 
     72  inline void setLightPosition(float x, float y, float z)
     73  { this->lightPos = Vector(x,y,z); }
    6374
     75  inline void setCloudScale(float scale)
     76  { this->scale = scale; }
     77 
     78  inline void setPlanetRadius(float planetRadius)
     79  { this->planetRadius = planetRadius; }
     80 
     81  inline void setAtmosphericRadius(float atmosphericRadius)
     82  { this->atmosphericRadius = atmosphericRadius; }
     83 
     84  inline void setDivisions(int divs)
     85  { this->divs = divs; }
     86 
    6487  virtual void draw() const;
    6588  virtual void tick(float dt);
     
    7295  void normalize3(double v[3]);
    7396
     97  void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
     98                        float hTile, float vTile);
    7499private:
    75100
    76   bool        cloudActivate;
    77   float       animationSpeed;
     101  bool             cloudActivate;
     102  float            animationSpeed;
    78103
    79104  // Material                 cloudMaterial;
    80   Shader*                 shader;
    81   Shader::Uniform*        offset;
     105 
     106  // SHADER STUFF
     107  Shader*          shader;
     108  Shader::Uniform* offset;
     109  float            offsetZ;
     110  Vector           lightPos;
     111  float            scale;
     112  float            planetRadius;
     113  float            atmosphericRadius;
     114  int              divs;
    82115
    83   float offsetZ;
     116  // NOISE STUFF
     117  int              noise3DTexSize;
     118  GLuint           noise3DTexName;
     119  GLubyte          *noise3DTexPtr;
    84120
    85   int noise3DTexSize;
    86   GLuint noise3DTexName;
    87   GLubyte *noise3DTexPtr;
     121  int              p[MAXB + MAXB + 2];
     122  double           g3[MAXB + MAXB + 2][3];
     123  double           g2[MAXB + MAXB + 2][2];
     124  double           g1[MAXB + MAXB + 2];
    88125
    89   int p[MAXB + MAXB + 2];
    90   double g3[MAXB + MAXB + 2][3];
    91   double g2[MAXB + MAXB + 2][2];
    92   double g1[MAXB + MAXB + 2];
     126  int              start;
     127  int              B;
     128  int              BM;
     129 
     130  // SKYPLANE STUFF
     131  VERTEX *planeVertices;
     132  int numPlaneVertices;
    93133
    94   int start;
    95   int B;
    96   int BM;
     134  int *indices;
     135  int numIndices;
     136
     137  float pRadius;
     138 
     139  VERTEX *vertices;
     140  int numVertices;
    97141};
    98142
Note: See TracChangeset for help on using the changeset viewer.