Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h @ 8730

Last change on this file since 8730 was 8730, checked in by hdavid, 18 years ago

branches/atmospheric_engine: created skydome.[h,cc]

File size: 2.7 KB
Line 
1/**
2* @file cloud_effect.h
3*/
4
5#ifndef _CLOUD_EFFECT
6#define _CLOUD_EFFECT
7
8#include "weather_effect.h"
9
10#include "sound_buffer.h"
11#include "sound_source.h"
12
13#include "skydome.h"
14#include "material.h"
15#include "shader.h"
16
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
33
34class CloudEffect : public WeatherEffect
35{
36public:
37  CloudEffect(const TiXmlElement* root = NULL);
38  virtual ~CloudEffect();
39
40  virtual void loadParams(const TiXmlElement* root);
41
42  virtual void init();
43
44  virtual void activate();
45  virtual void deactivate();
46
47  inline void activateCloud()
48  { this->activate(); }
49 
50  inline void deactivateCloud()
51  { this->deactivate(); }
52 
53  inline void setCloudOption(const std::string& option)
54  {
55    if (option == "activate")
56      this->cloudActivate = true;
57  }
58 
59  inline void setAnimationSpeed(float speed)
60  { this->animationSpeed = speed; }
61
62  inline void setCloudScale(float scale)
63  { this->scale = scale; }
64 
65  inline void setPlanetRadius(float planetRadius)
66  { this->planetRadius = planetRadius; }
67 
68  inline void setAtmosphericRadius(float atmosphericRadius)
69  { this->atmosphericRadius = atmosphericRadius; }
70 
71  inline void setDivisions(int divs)
72  { this->divs = divs; }
73 
74  virtual void draw() const;
75  virtual void tick(float dt);
76
77  void make3DNoiseTexture();
78  void initNoise();
79  void SetNoiseFrequency(int frequency);
80  double noise3(double vec[3]);
81  void normalize2(double v[2]);
82  void normalize3(double v[3]);
83
84  void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
85                        float hTile, float vTile);
86private:
87
88  bool             cloudActivate;
89  float            animationSpeed;
90
91  // Material                 cloudMaterial;
92  Skydome*         skydome;
93 
94  // SHADER STUFF
95  Shader*          shader;
96  Shader::Uniform* offset;
97  float            offsetZ;
98  float            scale;
99  float            planetRadius;
100  float            atmosphericRadius;
101  int              divs;
102
103  // NOISE STUFF
104  int              noise3DTexSize;
105  GLuint           noise3DTexName;
106  GLubyte          *noise3DTexPtr;
107
108  int              p[MAXB + MAXB + 2];
109  double           g3[MAXB + MAXB + 2][3];
110  double           g2[MAXB + MAXB + 2][2];
111  double           g1[MAXB + MAXB + 2];
112
113  int              start;
114  int              B;
115  int              BM;
116};
117
118#endif  /* _CLOUD_EFFECT */
Note: See TracBrowser for help on using the repository browser.