2015-04-14 15:55:56 +02:00
|
|
|
#ifndef OPENMW_MWRENDER_SKY_H
|
|
|
|
#define OPENMW_MWRENDER_SKY_H
|
2013-12-07 20:12:03 +01:00
|
|
|
|
2015-08-04 21:07:42 -05:00
|
|
|
#include <string>
|
2015-08-07 00:08:18 -05:00
|
|
|
#include <memory>
|
2012-07-23 15:35:31 +02:00
|
|
|
|
2015-08-04 21:07:42 -05:00
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Vec4f>
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
2011-01-04 01:34:55 +01:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
|
|
|
class Node;
|
|
|
|
class Material;
|
|
|
|
}
|
|
|
|
|
2015-06-25 17:23:01 +02:00
|
|
|
namespace osgParticle
|
|
|
|
{
|
|
|
|
class ParticleSystem;
|
|
|
|
}
|
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
namespace Resource
|
2010-06-27 16:44:15 -07:00
|
|
|
{
|
2012-02-21 16:15:38 +01:00
|
|
|
class SceneManager;
|
2010-06-27 16:44:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
2015-04-14 15:55:56 +02:00
|
|
|
class AtmosphereUpdater;
|
2015-06-19 20:55:04 +02:00
|
|
|
class AtmosphereNightUpdater;
|
2015-04-15 18:50:50 +02:00
|
|
|
class CloudUpdater;
|
|
|
|
class Sun;
|
|
|
|
class Moon;
|
2015-06-25 17:23:01 +02:00
|
|
|
class RainShooter;
|
2015-06-25 17:38:08 +02:00
|
|
|
class RainFader;
|
2015-06-29 20:19:46 +02:00
|
|
|
class AlphaFader;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2015-08-04 21:07:42 -05:00
|
|
|
struct WeatherResult
|
|
|
|
{
|
|
|
|
std::string mCloudTexture;
|
|
|
|
std::string mNextCloudTexture;
|
|
|
|
float mCloudBlendFactor;
|
|
|
|
|
|
|
|
osg::Vec4f mFogColor;
|
|
|
|
|
|
|
|
osg::Vec4f mAmbientColor;
|
|
|
|
|
|
|
|
osg::Vec4f mSkyColor;
|
|
|
|
|
|
|
|
osg::Vec4f mSunColor;
|
|
|
|
|
|
|
|
osg::Vec4f mSunDiscColor;
|
|
|
|
|
|
|
|
float mFogDepth;
|
|
|
|
|
|
|
|
float mWindSpeed;
|
|
|
|
|
|
|
|
float mCloudSpeed;
|
|
|
|
|
|
|
|
float mGlareView;
|
|
|
|
|
|
|
|
bool mNight; // use night skybox
|
|
|
|
float mNightFade; // fading factor for night skybox
|
|
|
|
|
|
|
|
bool mIsStorm;
|
|
|
|
|
|
|
|
std::string mAmbientLoopSoundID;
|
|
|
|
float mAmbientSoundVolume;
|
|
|
|
|
|
|
|
std::string mParticleEffect;
|
|
|
|
std::string mRainEffect;
|
|
|
|
float mEffectFade;
|
|
|
|
|
|
|
|
float mRainSpeed;
|
|
|
|
float mRainFrequency;
|
|
|
|
};
|
|
|
|
|
2015-07-29 23:57:45 -05:00
|
|
|
struct MoonState
|
|
|
|
{
|
|
|
|
enum Phase
|
|
|
|
{
|
|
|
|
Phase_Full = 0,
|
|
|
|
Phase_WaningGibbous,
|
|
|
|
Phase_ThirdQuarter,
|
|
|
|
Phase_WaningCrescent,
|
|
|
|
Phase_New,
|
|
|
|
Phase_WaxingCrescent,
|
|
|
|
Phase_FirstQuarter,
|
|
|
|
Phase_WaxingGibbous,
|
|
|
|
Phase_Unspecified
|
|
|
|
};
|
|
|
|
|
|
|
|
float mRotationFromHorizon;
|
|
|
|
float mRotationFromNorth;
|
|
|
|
Phase mPhase;
|
|
|
|
float mShadowBlend;
|
|
|
|
float mMoonAlpha;
|
|
|
|
};
|
|
|
|
|
2010-06-27 16:44:15 -07:00
|
|
|
class SkyManager
|
|
|
|
{
|
|
|
|
public:
|
2015-04-14 15:55:56 +02:00
|
|
|
SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager);
|
2012-02-21 17:38:15 +01:00
|
|
|
~SkyManager();
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-21 17:38:15 +01:00
|
|
|
void update(float duration);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
void setEnabled(bool enabled);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-25 21:06:03 +01:00
|
|
|
void setHour (double hour);
|
2012-02-21 16:15:38 +01:00
|
|
|
///< will be called even when sky is disabled.
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-25 21:06:03 +01:00
|
|
|
void setDate (int day, int month);
|
2012-02-21 16:15:38 +01:00
|
|
|
///< will be called even when sky is disabled.
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-21 17:38:15 +01:00
|
|
|
int getMasserPhase() const;
|
2012-02-21 16:15:38 +01:00
|
|
|
///< 0 new moon, 1 waxing or waning cresecent, 2 waxing or waning half,
|
|
|
|
/// 3 waxing or waning gibbous, 4 full moon
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-21 17:38:15 +01:00
|
|
|
int getSecundaPhase() const;
|
2012-02-21 16:15:38 +01:00
|
|
|
///< 0 new moon, 1 waxing or waning cresecent, 2 waxing or waning half,
|
|
|
|
/// 3 waxing or waning gibbous, 4 full moon
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-21 17:38:15 +01:00
|
|
|
void setMoonColour (bool red);
|
2012-02-21 16:15:38 +01:00
|
|
|
///< change Secunda colour to red
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2015-08-04 21:07:42 -05:00
|
|
|
void setWeather(const WeatherResult& weather);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-24 18:30:16 +01:00
|
|
|
void sunEnable();
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2012-02-24 18:30:16 +01:00
|
|
|
void sunDisable();
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
void setRainSpeed(float speed);
|
|
|
|
|
2015-05-22 01:54:06 +02:00
|
|
|
void setStormDirection(const osg::Vec3f& direction);
|
2014-06-26 19:01:49 +02:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
void setSunDirection(const osg::Vec3f& direction);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
2015-07-29 23:57:45 -05:00
|
|
|
void setMasserState(const MoonState& state);
|
|
|
|
void setSecundaState(const MoonState& state);
|
2012-03-24 17:59:26 +01:00
|
|
|
|
|
|
|
void setGlare(const float glare);
|
2012-07-19 22:23:07 +02:00
|
|
|
void setGlareEnabled(bool enabled);
|
2012-04-01 15:07:41 +02:00
|
|
|
|
2012-02-21 16:15:38 +01:00
|
|
|
private:
|
2013-05-07 17:38:24 +02:00
|
|
|
void create();
|
|
|
|
///< no need to call this, automatically done on first enable()
|
|
|
|
|
2015-06-25 17:23:01 +02:00
|
|
|
void createRain();
|
|
|
|
void destroyRain();
|
|
|
|
void updateRainParameters();
|
2014-06-25 18:20:21 +02:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
Resource::SceneManager* mSceneManager;
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Group> mRootNode;
|
|
|
|
|
2015-06-16 16:33:31 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::ref_ptr<osg::Node> mParticleEffect;
|
2015-06-29 20:19:46 +02:00
|
|
|
osg::ref_ptr<AlphaFader> mParticleFader;
|
2015-04-14 15:55:56 +02:00
|
|
|
|
2015-06-16 16:33:31 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
|
2015-04-14 15:55:56 +02:00
|
|
|
|
2015-04-15 18:50:50 +02:00
|
|
|
osg::ref_ptr<CloudUpdater> mCloudUpdater;
|
2015-06-19 01:03:12 +02:00
|
|
|
osg::ref_ptr<CloudUpdater> mCloudUpdater2;
|
|
|
|
osg::ref_ptr<osg::Node> mCloudMesh;
|
|
|
|
osg::ref_ptr<osg::Node> mCloudMesh2;
|
2015-04-15 18:50:50 +02:00
|
|
|
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::ref_ptr<osg::Node> mAtmosphereDay;
|
|
|
|
|
2015-06-16 16:33:31 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mAtmosphereNightNode;
|
|
|
|
float mAtmosphereNightRoll;
|
2015-06-19 20:55:04 +02:00
|
|
|
osg::ref_ptr<AtmosphereNightUpdater> mAtmosphereNightUpdater;
|
2015-04-14 15:55:56 +02:00
|
|
|
|
|
|
|
osg::ref_ptr<AtmosphereUpdater> mAtmosphereUpdater;
|
|
|
|
|
2015-08-07 00:08:18 -05:00
|
|
|
std::auto_ptr<Sun> mSun;
|
|
|
|
std::auto_ptr<Moon> mMasser;
|
|
|
|
std::auto_ptr<Moon> mSecunda;
|
2015-04-14 15:55:56 +02:00
|
|
|
|
2015-06-25 17:23:01 +02:00
|
|
|
osg::ref_ptr<osg::Group> mRainNode;
|
|
|
|
osg::ref_ptr<osgParticle::ParticleSystem> mRainParticleSystem;
|
|
|
|
osg::ref_ptr<RainShooter> mRainShooter;
|
2015-06-25 17:38:08 +02:00
|
|
|
osg::ref_ptr<RainFader> mRainFader;
|
2015-06-25 17:23:01 +02:00
|
|
|
|
2012-04-01 15:07:41 +02:00
|
|
|
bool mCreated;
|
|
|
|
|
2014-06-26 19:01:49 +02:00
|
|
|
bool mIsStorm;
|
|
|
|
|
2012-02-25 21:06:03 +01:00
|
|
|
int mDay;
|
|
|
|
int mMonth;
|
2012-03-15 19:49:15 +01:00
|
|
|
|
2012-07-11 09:08:55 +02:00
|
|
|
float mCloudAnimationTimer;
|
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
float mRainTimer;
|
|
|
|
|
2015-05-22 01:54:06 +02:00
|
|
|
osg::Vec3f mStormDirection;
|
2014-06-26 19:01:49 +02:00
|
|
|
|
2012-02-24 23:26:38 +01:00
|
|
|
// remember some settings so we don't have to apply them again if they didnt change
|
2015-05-22 01:54:06 +02:00
|
|
|
std::string mClouds;
|
|
|
|
std::string mNextClouds;
|
2012-02-22 19:17:37 +01:00
|
|
|
float mCloudBlendFactor;
|
2012-02-23 20:33:34 +01:00
|
|
|
float mCloudSpeed;
|
2012-02-24 23:26:38 +01:00
|
|
|
float mStarsOpacity;
|
2015-04-14 15:55:56 +02:00
|
|
|
osg::Vec4f mCloudColour;
|
|
|
|
osg::Vec4f mSkyColour;
|
|
|
|
osg::Vec4f mFogColour;
|
2012-04-06 15:05:17 +02:00
|
|
|
|
2014-06-24 15:00:15 +02:00
|
|
|
std::string mCurrentParticleEffect;
|
|
|
|
|
2012-02-22 19:17:37 +01:00
|
|
|
float mRemainingTransitionTime;
|
2012-04-06 15:05:17 +02:00
|
|
|
|
2012-03-24 17:59:26 +01:00
|
|
|
float mGlare; // target
|
|
|
|
float mGlareFade; // actual
|
2012-04-06 15:05:17 +02:00
|
|
|
|
2014-06-25 18:20:21 +02:00
|
|
|
bool mRainEnabled;
|
|
|
|
std::string mRainEffect;
|
|
|
|
float mRainSpeed;
|
|
|
|
float mRainFrequency;
|
2015-06-25 17:23:01 +02:00
|
|
|
float mWindSpeed;
|
2014-06-25 18:20:21 +02:00
|
|
|
|
2012-02-24 16:12:43 +01:00
|
|
|
bool mEnabled;
|
2012-02-24 18:30:16 +01:00
|
|
|
bool mSunEnabled;
|
2015-06-19 02:51:01 +02:00
|
|
|
|
|
|
|
osg::Vec4f mMoonScriptColor;
|
2010-06-27 16:44:15 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-05-07 17:38:24 +02:00
|
|
|
#endif // GAME_RENDER_SKY_H
|