Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mountain_lake/src/lib/graphics/effects/cloud_effect.h @ 8896

Last change on this file since 8896 was 8837, checked in by hdavid, 19 years ago

branches/mountain_lake: fading sky/cloud colors works, RainEffect::stopRaining is a bit buggy

File size: 3.8 KB
Line 
1/**
2 * @file cloud_effect.h
3 * Creates clouds
4*/
5
6#ifndef _CLOUD_EFFECT
7#define _CLOUD_EFFECT
8
9#include "weather_effect.h"
10
11#include "sound_buffer.h"
12#include "sound_source.h"
13
14#include "skydome.h"
15#include "material.h"
16#include "shader.h"
17
18#define MAXB 0x100
19#define N 0x1000
20#define NP 12   /* 2^N */
21#define NM 0xfff
22
23#define s_curve(t) ( t * t * (3. - 2. * t) )
24#define lerp(t, a, b) ( a + t * (b - a) )
25#define setup(i,b0,b1,r0,r1)\
26        t = vec[i] + N;\
27        b0 = ((int)t) & BM;\
28        b1 = (b0+1) & BM;\
29        r0 = t - (int)t;\
30        r1 = r0 - 1.;
31#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
32#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
33
34// FORWARD DECLARATION
35template <class T> class tAnimation;
36
37
38class CloudEffect : public WeatherEffect
39{
40public:
41  CloudEffect(const TiXmlElement* root = NULL);
42  virtual ~CloudEffect();
43
44  virtual void loadParams(const TiXmlElement* root);
45
46  virtual void init();
47
48  virtual void activate();
49  virtual void deactivate();
50
51  inline void activateCloud()
52  { this->activate(); }
53
54  inline void deactivateCloud()
55  { this->deactivate(); }
56
57  inline void setCloudOption(const std::string& option)
58  {
59    if (option == "activate")
60      this->cloudActivate = true;
61  }
62
63  inline void setAnimationSpeed(float speed)
64{ this->animationSpeed = speed; }
65
66  inline void setCloudScale(float scale)
67  { this->scale = scale; }
68
69  inline void setCloudColor(float colorX, float colorY, float colorZ)
70  { this->cloudColor = Vector(colorX, colorY, colorZ); }
71
72  inline void setSkyColor(float colorX, float colorY, float colorZ)
73  { this->skyColor = Vector(colorX, colorY, colorZ); }
74
75  inline void setPlanetRadius(float planetRadius)
76  { this->planetRadius = planetRadius; }
77
78  inline void setAtmosphericRadius(float atmosphericRadius)
79  { this->atmosphericRadius = atmosphericRadius; }
80
81  inline void setDivisions(int divs)
82  { this->divs = divs; }
83
84  virtual void draw() const;
85  virtual void tick(float dt);
86
87  static void changeSkyColor(Vector color, float time);
88  static void changeCloudColor(Vector color, float time);
89 
90  void setColorSkyX(float color);
91  void setColorSkyY(float color);
92  void setColorSkyZ(float color);
93  void setColorCloudX(float color);
94  void setColorCloudY(float color);
95  void setColorCloudZ(float color);
96 
97  static Vector    cloudColor;
98  static Vector    skyColor;
99
100  void make3DNoiseTexture();
101  void initNoise();
102  void SetNoiseFrequency(int frequency);
103  double noise3(double vec[3]);
104  void normalize2(double v[2]);
105  void normalize3(double v[3]);
106
107  void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
108                        float hTile, float vTile);
109private:
110
111  bool             cloudActivate;
112  float            animationSpeed;
113 
114  static Vector           newSkyColor;
115  static Vector           newCloudColor;
116
117  // Material                 cloudMaterial;
118  Skydome*         skydome;
119 
120  tAnimation<CloudEffect>*  skyColorFadeX;
121  tAnimation<CloudEffect>*  skyColorFadeY;
122  tAnimation<CloudEffect>*  skyColorFadeZ;
123  tAnimation<CloudEffect>*  cloudColorFadeX;
124  tAnimation<CloudEffect>*  cloudColorFadeY;
125  tAnimation<CloudEffect>*  cloudColorFadeZ;
126  static bool fadeSky;
127  static bool fadeCloud;
128  static float fadeTime;
129
130  // SHADER STUFF
131  Shader*          shader;
132  Shader::Uniform* offset;
133  Shader::Uniform* skycolor;
134  Shader::Uniform* cloudcolor;
135  float            offsetZ;
136  float            scale;
137  float            planetRadius;
138  float            atmosphericRadius;
139  int              divs;
140
141  // NOISE STUFF
142  int              noise3DTexSize;
143  GLuint           noise3DTexName;
144  GLubyte          *noise3DTexPtr;
145
146  int              p[MAXB + MAXB + 2];
147  double           g3[MAXB + MAXB + 2][3];
148  double           g2[MAXB + MAXB + 2][2];
149  double           g1[MAXB + MAXB + 2];
150
151  int              start;
152  int              B;
153  int              BM;
154};
155
156#endif  /* _CLOUD_EFFECT */
Note: See TracBrowser for help on using the repository browser.