Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/single_player_map/src/lib/graphics/effects/cloud_effect.h @ 8927

Last change on this file since 8927 was 8793, checked in by patrick, 18 years ago

trunk: merged the weather engine branche to the trunk

File size: 3.2 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
35class CloudEffect : public WeatherEffect
36{
37public:
38  CloudEffect(const TiXmlElement* root = NULL);
39  virtual ~CloudEffect();
40
41  virtual void loadParams(const TiXmlElement* root);
42
43  virtual void init();
44
45  virtual void activate();
46  virtual void deactivate();
47
48  inline void activateCloud()
49  { this->activate(); }
50
51  inline void deactivateCloud()
52  { this->deactivate(); }
53
54  inline void setCloudOption(const std::string& option)
55  {
56    if (option == "activate")
57      this->cloudActivate = true;
58  }
59
60  inline void setAnimationSpeed(float speed)
61{ this->animationSpeed = speed; }
62
63  inline void setCloudScale(float scale)
64  { this->scale = scale; }
65
66  inline void setCloudColor(float colorX, float colorY, float colorZ)
67  { this->cloudColor = Vector(colorX, colorY, colorZ); }
68
69  inline void setSkyColor(float colorX, float colorY, float colorZ)
70  { this->skyColor = Vector(colorX, colorY, colorZ); }
71
72  inline void setPlanetRadius(float planetRadius)
73  { this->planetRadius = planetRadius; }
74
75  inline void setAtmosphericRadius(float atmosphericRadius)
76  { this->atmosphericRadius = atmosphericRadius; }
77
78  inline void setDivisions(int divs)
79  { this->divs = divs; }
80
81  virtual void draw() const;
82  virtual void tick(float dt);
83
84  static void changeSkyColor(Vector color);
85  static void changeCloudColor(Vector color);
86 
87  static Vector    cloudColor;
88  static Vector    skyColor;
89
90  void make3DNoiseTexture();
91  void initNoise();
92  void SetNoiseFrequency(int frequency);
93  double noise3(double vec[3]);
94  void normalize2(double v[2]);
95  void normalize3(double v[3]);
96
97  void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
98                        float hTile, float vTile);
99private:
100
101  bool             cloudActivate;
102  float            animationSpeed;
103  float            fadeTime;
104 
105  static Vector           newSkyColor;
106  static Vector           newCloudColor;
107
108  // Material                 cloudMaterial;
109  Skydome*         skydome;
110
111  // SHADER STUFF
112  Shader*          shader;
113  Shader::Uniform* offset;
114  Shader::Uniform* skycolor;
115  Shader::Uniform* cloudcolor;
116  float            offsetZ;
117  float            scale;
118  float            planetRadius;
119  float            atmosphericRadius;
120  int              divs;
121
122  // NOISE STUFF
123  int              noise3DTexSize;
124  GLuint           noise3DTexName;
125  GLubyte          *noise3DTexPtr;
126
127  int              p[MAXB + MAXB + 2];
128  double           g3[MAXB + MAXB + 2][3];
129  double           g2[MAXB + MAXB + 2][2];
130  double           g1[MAXB + MAXB + 2];
131
132  int              start;
133  int              B;
134  int              BM;
135};
136
137#endif  /* _CLOUD_EFFECT */
Note: See TracBrowser for help on using the repository browser.