Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weather_effects/cloud_effect.h @ 9869

Last change on this file since 9869 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 4.2 KB
RevLine 
[7679]1/**
[8793]2 * @file cloud_effect.h
[9006]3 * Create clouds
[7679]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
[8793]14#include "skydome.h"
[8495]15#include "material.h"
16#include "shader.h"
[8255]17
[8793]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
[9006]34// FORWARD DECLARATION
35template <class T>
36class tAnimation;
[8793]37
[9006]38class CloudEffect : public WeatherEffect {
[9715]39  ObjectListDeclaration(CloudEffect);
[9006]40
[8495]41public:
[8255]42
[9006]43    CloudEffect(const TiXmlElement* root = NULL);
44    virtual ~CloudEffect();
[8255]45
[9006]46    virtual void loadParams(const TiXmlElement* root);
[7679]47
[9006]48    virtual void init();
[7679]49
[9006]50    virtual void activate();
51    virtual void deactivate();
[7679]52
[9006]53    void activateCloud() {
54        this->activate();
55    }
56    void deactivateCloud() {
57        this->deactivate();
58    }
[7679]59
[9006]60    void setCloudOption(const std::string& option) {
61        if (option == "activate")
62            this->cloudActivate = true;
63    }
[7679]64
[9006]65    void setAnimationSpeed(float speed) {
66        this->animationSpeed = speed;
67    }
[7784]68
[9006]69    void setCloudScale(float scale) {
70        this->scale = scale;
71    }
[8793]72
[9006]73    void setCloudColor(float colorX, float colorY, float colorZ) {
74        this->cloudColor = Vector(colorX, colorY, colorZ);
75    }
[8793]76
[9006]77    void setSkyColor(float colorX, float colorY, float colorZ) {
78        this->skyColor = Vector(colorX, colorY, colorZ);
79    }
[8793]80
[9006]81    void setPlanetRadius(float planetRadius) {
82        this->planetRadius = planetRadius;
83    }
[8793]84
[9006]85    void setAtmosphericRadius(float atmosphericRadius) {
86        this->atmosphericRadius = atmosphericRadius;
87    }
[8793]88
[9006]89    void setDivisions(int divs) {
90        this->divs = divs;
91    }
[8793]92
[9006]93    virtual void draw() const;
94    virtual void tick(float dt);
[8793]95
[9006]96    static void changeSkyColor(Vector color, float time);
97    static void changeCloudColor(Vector color, float time);
[8793]98
[9006]99    void setColorSkyX(float color);
100    void setColorSkyY(float color);
101    void setColorSkyZ(float color);
102    void setColorCloudX(float color);
103    void setColorCloudY(float color);
104    void setColorCloudZ(float color);
[8793]105
[9006]106    static Vector cloudColor;
107    static Vector skyColor;
108
109    void make3DNoiseTexture();
110    void initNoise();
111    void SetNoiseFrequency(int frequency);
112    double noise3(double vec[3]);
113    void normalize2(double v[2]);
114    void normalize3(double v[3]);
115
116    void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
117                          float hTile, float vTile);
118
119    void shellSkyColor(float colorX, float colorY, float colorZ, float time);
120    void shellCloudColor(float colorX, float colorY, float colorZ, float time);
121
122
[8495]123private:
[8255]124
[9006]125    bool                    cloudActivate;
126    float                   animationSpeed;
[7768]127
[9006]128    static Vector           newSkyColor;
129    static Vector           newCloudColor;
[8793]130
[9006]131    // Material             cloudMaterial;
132    Skydome*                 skydome;
[8793]133
[9006]134    tAnimation<CloudEffect>*  skyColorFadeX;
135    tAnimation<CloudEffect>*  skyColorFadeY;
136    tAnimation<CloudEffect>*  skyColorFadeZ;
137    tAnimation<CloudEffect>*  cloudColorFadeX;
138    tAnimation<CloudEffect>*  cloudColorFadeY;
139    tAnimation<CloudEffect>*  cloudColorFadeZ;
140    static bool fadeSky;
141    static bool fadeCloud;
142    static float fadeTime;
[8793]143
[9006]144    // SHADER STUFF
[9818]145    Shader           shader;
[9006]146    Shader::Uniform* offset;
147    Shader::Uniform* skycolor;
148    Shader::Uniform* cloudcolor;
149    float            offsetZ;
150    float            scale;
151    float            planetRadius;
152    float            atmosphericRadius;
153    int              divs;
[8793]154
[9006]155    // NOISE STUFF
156    int              noise3DTexSize;
157    GLuint           noise3DTexName;
158    GLubyte          *noise3DTexPtr;
159
160    int              p[MAXB + MAXB + 2];
161    double           g3[MAXB + MAXB + 2][3];
162    double           g2[MAXB + MAXB + 2][2];
163    double           g1[MAXB + MAXB + 2];
164
165    int              start;
166    int              B;
167    int              BM;
168
169
[7679]170};
171
172#endif  /* _CLOUD_EFFECT */
Note: See TracBrowser for help on using the repository browser.