Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/graphics/effects/fog_effect.h @ 9354

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

merged the presentation back

File size: 2.4 KB
Line 
1/**
2 * @file fog_effect.h
3 * Generates simple openGL fog
4*/
5
6#ifndef _FOG_EFFECT
7#define _FOG_EFFECT
8
9#include "weather_effect.h"
10#include "glincl.h"
11#include "vector.h"
12
13class CloudEffect;
14
15class FogEffect : public WeatherEffect
16{
17public:
18  FogEffect(const TiXmlElement* root = NULL);
19  virtual ~FogEffect();
20
21  virtual void loadParams(const TiXmlElement* root);
22
23  virtual void init();
24
25  virtual void activate();
26  virtual void deactivate();
27
28  void activateFog()
29  {
30    this->activate();
31  }
32
33  void deactivateFog()
34  {
35    this->deactivate();
36  }
37
38  virtual void draw() const;
39  virtual void tick(float dt);
40
41  inline void setFogMode(const std::string& mode)
42  {
43    this->fogMode = this->stringToFogMode(mode);
44  }
45
46  inline void setFogDensity(float density)
47  {
48    this->fogDensity = density;
49  }
50
51  inline void setFogRange(float start, float end)
52  {
53    this->fogStart = start;
54    this->fogEnd = end;
55  }
56
57  inline void setFogColor(float r, float g, float b)
58  {
59    this->colorVector = Vector(r, g, b);
60  }
61
62  inline void setFogFadeIn(float fadein)
63  {
64    this->fogFadeInDuration = fadein;
65  }
66
67  inline void setFogFadeOut(float fadeout)
68  {
69    this->fogFadeOutDuration = fadeout;
70  }
71
72  inline void setFogOption(const std::string& option)
73  {
74    if (option == "activate")
75      this->fogActivate = true;
76  }
77 
78  inline void setCloudColor(float colorX, float colorY, float colorZ)
79  {
80    this->cloudColor = Vector(colorX, colorY, colorZ);
81  }
82  inline void setSkyColor(float colorX, float colorY, float colorZ)
83  {
84    this->skyColor = Vector(colorX, colorY, colorZ);
85  }
86
87  void fadeInFog();
88  void fadeOutFog();
89
90
91private:
92  inline GLint stringToFogMode(const std::string& mode)
93  {
94    if(mode == "GL_LINEAR")
95      return GL_LINEAR;
96    else if(mode == "GL_EXP")
97      return GL_EXP;
98    else if(mode == "GL_EXP2" )
99      return GL_EXP2;
100    else
101      return -1;
102  }
103
104  bool          fogActivate;
105
106  bool          fogFadeInActivate;
107  bool          fogFadeOutActivate;
108
109  GLfloat       fogFadeInDuration;
110  GLfloat       fogFadeOutDuration;
111
112  GLint         fogMode;
113  GLfloat       fogDensity;
114  GLfloat       fogFadeDensity;
115
116  GLfloat       fogStart;
117  GLfloat       fogEnd;
118  GLfloat       fogFadeEnd;
119
120  Vector        colorVector;
121  float         localTimer; 
122 
123  Vector oldSkyColor;
124  Vector oldCloudColor;
125  Vector skyColor;
126  Vector cloudColor;
127};
128
129#endif  /* _FOG_EFFECT */
Note: See TracBrowser for help on using the repository browser.