OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sky.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_MWRENDER_SKY_H
2 #define OPENMW_MWRENDER_SKY_H
3 
4 #include <string>
5 #include <memory>
6 #include <vector>
7 
8 #include <osg/ref_ptr>
9 #include <osg/Vec4f>
10 
11 namespace osg
12 {
13  class Group;
14  class Node;
15  class Material;
16  class PositionAttitudeTransform;
17 }
18 
19 namespace osgParticle
20 {
21  class ParticleSystem;
22 }
23 
24 namespace Resource
25 {
26  class SceneManager;
27 }
28 
29 namespace MWRender
30 {
31  class AtmosphereUpdater;
32  class AtmosphereNightUpdater;
33  class CloudUpdater;
34  class Sun;
35  class Moon;
36  class RainShooter;
37  class RainFader;
38  class AlphaFader;
39  class UnderwaterSwitchCallback;
40 
42  {
43  std::string mCloudTexture;
44  std::string mNextCloudTexture;
46 
47  osg::Vec4f mFogColor;
48 
49  osg::Vec4f mAmbientColor;
50 
51  osg::Vec4f mSkyColor;
52 
53  // sun light color
54  osg::Vec4f mSunColor;
55 
56  // alpha is the sun transparency
57  osg::Vec4f mSunDiscColor;
58 
59  float mFogDepth;
60 
61  float mWindSpeed;
62 
63  float mCloudSpeed;
64 
65  float mGlareView;
66 
67  bool mNight; // use night skybox
68  float mNightFade; // fading factor for night skybox
69 
70  bool mIsStorm;
71 
72  std::string mAmbientLoopSoundID;
74 
75  std::string mParticleEffect;
76  std::string mRainEffect;
77  float mEffectFade;
78 
79  float mRainSpeed;
81  };
82 
83  struct MoonState
84  {
85  enum Phase
86  {
96  };
97 
102  float mMoonAlpha;
103  };
104 
108  {
109  public:
110  SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager);
111  ~SkyManager();
112 
113  void update(float duration);
114 
115  void setEnabled(bool enabled);
116 
117  void setHour (double hour);
119 
120  void setDate (int day, int month);
122 
123  int getMasserPhase() const;
126 
127  int getSecundaPhase() const;
130 
131  void setMoonColour (bool red);
133 
134  void setWeather(const WeatherResult& weather);
135 
136  void sunEnable();
137 
138  void sunDisable();
139 
140  void setRainSpeed(float speed);
141 
142  void setStormDirection(const osg::Vec3f& direction);
143 
144  void setSunDirection(const osg::Vec3f& direction);
145 
146  void setMasserState(const MoonState& state);
147  void setSecundaState(const MoonState& state);
148 
149  void setGlareTimeOfDayFade(float val);
150 
152  void setWaterEnabled(bool enabled);
153 
155  void setWaterHeight(float height);
156 
157  void listAssetsToPreload(std::vector<std::string>& models, std::vector<std::string>& textures);
158 
159  private:
160  void create();
162 
163  void createRain();
164  void destroyRain();
165  void updateRainParameters();
166 
168 
169  osg::ref_ptr<osg::Group> mRootNode;
170  osg::ref_ptr<osg::Group> mEarlyRenderBinRoot;
171 
172  osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
173  osg::ref_ptr<osg::Node> mParticleEffect;
174  std::vector<osg::ref_ptr<AlphaFader> > mParticleFaders;
175  osg::ref_ptr<UnderwaterSwitchCallback> mUnderwaterSwitch;
176 
177  osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
178 
179  osg::ref_ptr<CloudUpdater> mCloudUpdater;
180  osg::ref_ptr<CloudUpdater> mCloudUpdater2;
181  osg::ref_ptr<osg::Node> mCloudMesh;
182  osg::ref_ptr<osg::Node> mCloudMesh2;
183 
184  osg::ref_ptr<osg::Node> mAtmosphereDay;
185 
186  osg::ref_ptr<osg::PositionAttitudeTransform> mAtmosphereNightNode;
188  osg::ref_ptr<AtmosphereNightUpdater> mAtmosphereNightUpdater;
189 
190  osg::ref_ptr<AtmosphereUpdater> mAtmosphereUpdater;
191 
192  std::auto_ptr<Sun> mSun;
193  std::auto_ptr<Moon> mMasser;
194  std::auto_ptr<Moon> mSecunda;
195 
196  osg::ref_ptr<osg::Group> mRainNode;
197  osg::ref_ptr<osgParticle::ParticleSystem> mRainParticleSystem;
198  osg::ref_ptr<RainShooter> mRainShooter;
199  osg::ref_ptr<RainFader> mRainFader;
200 
201  bool mCreated;
202 
203  bool mIsStorm;
204 
205  int mDay;
206  int mMonth;
207 
209 
210  float mRainTimer;
211 
212  osg::Vec3f mStormDirection;
213 
214  // remember some settings so we don't have to apply them again if they didn't change
215  std::string mClouds;
216  std::string mNextClouds;
218  float mCloudSpeed;
220  osg::Vec4f mCloudColour;
221  osg::Vec4f mSkyColour;
222  osg::Vec4f mFogColour;
223 
225 
227 
229  std::string mRainEffect;
230  float mRainSpeed;
232  float mWindSpeed;
233 
234  bool mEnabled;
236 
237  osg::Vec4f mMoonScriptColor;
238  };
239 }
240 
241 #endif // GAME_RENDER_SKY_H
int getSecundaPhase() const
Definition: sky.cpp:1410
osg::ref_ptr< osg::Node > mCloudMesh2
Definition: sky.hpp:182
void setEnabled(bool enabled)
Definition: sky.cpp:1443
bool mCreated
Definition: sky.hpp:201
float mShadowBlend
Definition: sky.hpp:101
Phase mPhase
Definition: sky.hpp:100
osg::ref_ptr< osgParticle::ParticleSystem > mRainParticleSystem
Definition: sky.hpp:197
float mAmbientSoundVolume
Definition: sky.hpp:73
void setMoonColour(bool red)
change Secunda colour to red
Definition: sky.cpp:1453
osg::ref_ptr< UnderwaterSwitchCallback > mUnderwaterSwitch
Definition: sky.hpp:175
osg::ref_ptr< osg::Node > mCloudMesh
Definition: sky.hpp:181
std::auto_ptr< Sun > mSun
Definition: sky.hpp:192
void setRainSpeed(float speed)
float mCloudAnimationTimer
Definition: sky.hpp:208
osg::ref_ptr< osg::Group > mEarlyRenderBinRoot
Definition: sky.hpp:170
float mRainSpeed
Definition: sky.hpp:79
float mRainFrequency
Definition: sky.hpp:231
float mRainSpeed
Definition: sky.hpp:230
Definition: sky.hpp:41
void setDate(int day, int month)
will be called even when sky is disabled.
Definition: sky.cpp:1664
Handles loading and caching of scenes, e.g. .nif files or .osg files.
Definition: scenemanager.hpp:37
float mWindSpeed
Definition: sky.hpp:232
float mNightFade
Definition: sky.hpp:68
std::string mNextClouds
Definition: sky.hpp:216
osg::ref_ptr< AtmosphereNightUpdater > mAtmosphereNightUpdater
Definition: sky.hpp:188
void update(float duration)
Definition: sky.cpp:1416
float mCloudBlendFactor
Definition: sky.hpp:45
float mRemainingTransitionTime
Definition: sky.hpp:226
std::string mNextCloudTexture
Definition: sky.hpp:44
osg::ref_ptr< CloudUpdater > mCloudUpdater2
Definition: sky.hpp:180
void sunEnable()
Definition: sky.cpp:1624
void setWaterHeight(float height)
Set height of water plane (used to remove underwater weather particles)
Definition: sky.cpp:1675
float mCloudSpeed
Definition: sky.hpp:63
std::string mClouds
Definition: sky.hpp:215
The SkyManager handles rendering of the sky domes, celestial bodies as well as other objects that nee...
Definition: sky.hpp:107
void setWeather(const WeatherResult &weather)
Definition: sky.cpp:1470
osg::Vec3f mStormDirection
Definition: sky.hpp:212
osg::Vec4f mFogColour
Definition: sky.hpp:222
osg::Vec4f mSunColor
Definition: sky.hpp:54
float mWindSpeed
Definition: sky.hpp:61
float mRainFrequency
Definition: sky.hpp:80
std::string mAmbientLoopSoundID
Definition: sky.hpp:72
std::string mRainEffect
Definition: sky.hpp:76
osg::Vec4f mSkyColour
Definition: sky.hpp:221
bool mNight
Definition: sky.hpp:67
osg::ref_ptr< osg::Group > mRootNode
Definition: sky.hpp:169
int mDay
Definition: sky.hpp:205
float mRainTimer
Definition: sky.hpp:210
void setStormDirection(const osg::Vec3f &direction)
Definition: sky.cpp:1638
int mMonth
Definition: sky.hpp:206
std::string mCloudTexture
Definition: sky.hpp:43
Definition: sky.hpp:91
Definition: sky.hpp:83
osg::Vec4f mCloudColour
Definition: sky.hpp:220
float mCloudSpeed
Definition: sky.hpp:218
float mMoonAlpha
Definition: sky.hpp:102
std::string mCurrentParticleEffect
Definition: sky.hpp:224
void updateRainParameters()
Definition: sky.cpp:1459
float mStarsOpacity
Definition: sky.hpp:219
void destroyRain()
Definition: sky.cpp:1383
bool mSunEnabled
Definition: sky.hpp:235
osg::ref_ptr< CloudUpdater > mCloudUpdater
Definition: sky.hpp:179
osg::ref_ptr< RainShooter > mRainShooter
Definition: sky.hpp:198
std::auto_ptr< Moon > mMasser
Definition: sky.hpp:193
osg::ref_ptr< osg::PositionAttitudeTransform > mAtmosphereNightNode
Definition: sky.hpp:186
Phase
Definition: sky.hpp:85
osg::ref_ptr< osg::PositionAttitudeTransform > mParticleNode
Definition: sky.hpp:172
osg::Vec4f mAmbientColor
Definition: sky.hpp:49
float mAtmosphereNightRoll
Definition: sky.hpp:187
~SkyManager()
Definition: sky.cpp:1395
void setSunDirection(const osg::Vec3f &direction)
Definition: sky.cpp:1643
SkyManager(osg::Group *parentNode, Resource::SceneManager *sceneManager)
Definition: sky.cpp:1092
float mCloudBlendFactor
Definition: sky.hpp:217
osg::Vec4f mSunDiscColor
Definition: sky.hpp:57
void setGlareTimeOfDayFade(float val)
Definition: sky.cpp:1670
osg::Vec4f mSkyColor
Definition: sky.hpp:51
std::vector< osg::ref_ptr< AlphaFader > > mParticleFaders
Definition: sky.hpp:174
std::string mParticleEffect
Definition: sky.hpp:75
float mFogDepth
Definition: sky.hpp:59
void listAssetsToPreload(std::vector< std::string > &models, std::vector< std::string > &textures)
Definition: sky.cpp:1680
bool mRainEnabled
Definition: sky.hpp:228
osg::ref_ptr< osg::Node > mParticleEffect
Definition: sky.hpp:173
std::auto_ptr< Moon > mSecunda
Definition: sky.hpp:194
osg::ref_ptr< AtmosphereUpdater > mAtmosphereUpdater
Definition: sky.hpp:190
osg::ref_ptr< osg::Node > mAtmosphereDay
Definition: sky.hpp:184
osg::ref_ptr< RainFader > mRainFader
Definition: sky.hpp:199
float mRotationFromNorth
Definition: sky.hpp:99
void setSecundaState(const MoonState &state)
Definition: sky.cpp:1657
Definition: sky.hpp:87
bool mIsStorm
Definition: sky.hpp:203
osg::Vec4f mMoonScriptColor
Definition: sky.hpp:237
bool mEnabled
Definition: sky.hpp:234
float mGlareView
Definition: sky.hpp:65
void sunDisable()
Definition: sky.cpp:1631
osg::ref_ptr< osg::Group > mRainNode
Definition: sky.hpp:196
float mEffectFade
Definition: sky.hpp:77
void setHour(double hour)
will be called even when sky is disabled.
void setWaterEnabled(bool enabled)
Enable or disable the water plane (used to remove underwater weather particles)
Definition: sky.cpp:1720
void create()
no need to call this, automatically done on first enable()
Definition: sky.cpp:1135
bool mIsStorm
Definition: sky.hpp:70
std::string mRainEffect
Definition: sky.hpp:229
int getMasserPhase() const
Definition: sky.cpp:1404
osg::Vec4f mFogColor
Definition: sky.hpp:47
osg::ref_ptr< osg::PositionAttitudeTransform > mCloudNode
Definition: sky.hpp:177
void createRain()
Definition: sky.cpp:1322
float mRotationFromHorizon
Definition: sky.hpp:98
void setMasserState(const MoonState &state)
Definition: sky.cpp:1650
Resource::SceneManager * mSceneManager
Definition: sky.hpp:167