2015-04-14 13:55:56 +00:00
|
|
|
#ifndef OPENMW_MWRENDER_SKY_H
|
|
|
|
#define OPENMW_MWRENDER_SKY_H
|
2013-12-07 19:12:03 +00:00
|
|
|
|
2015-08-05 02:07:42 +00:00
|
|
|
#include <string>
|
2015-08-07 05:08:18 +00:00
|
|
|
#include <memory>
|
2016-03-10 11:59:17 +00:00
|
|
|
#include <vector>
|
2012-07-23 13:35:31 +00:00
|
|
|
|
2015-08-05 02:07:42 +00:00
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Vec4f>
|
2011-01-04 00:34:55 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
|
|
|
class Node;
|
|
|
|
class Material;
|
2016-03-10 11:59:17 +00:00
|
|
|
class PositionAttitudeTransform;
|
2015-04-14 13:55:56 +00:00
|
|
|
}
|
|
|
|
|
2015-06-25 15:23:01 +00:00
|
|
|
namespace osgParticle
|
|
|
|
{
|
|
|
|
class ParticleSystem;
|
|
|
|
}
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
namespace Resource
|
2010-06-27 23:44:15 +00:00
|
|
|
{
|
2012-02-21 15:15:38 +00:00
|
|
|
class SceneManager;
|
2010-06-27 23:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
2015-04-14 13:55:56 +00:00
|
|
|
class AtmosphereUpdater;
|
2015-06-19 18:55:04 +00:00
|
|
|
class AtmosphereNightUpdater;
|
2015-04-15 16:50:50 +00:00
|
|
|
class CloudUpdater;
|
|
|
|
class Sun;
|
|
|
|
class Moon;
|
2015-06-25 15:23:01 +00:00
|
|
|
class RainShooter;
|
2015-06-25 15:38:08 +00:00
|
|
|
class RainFader;
|
2015-06-29 18:19:46 +00:00
|
|
|
class AlphaFader;
|
2015-11-03 22:15:43 +00:00
|
|
|
class UnderwaterSwitchCallback;
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2015-08-05 02:07:42 +00:00
|
|
|
struct WeatherResult
|
|
|
|
{
|
|
|
|
std::string mCloudTexture;
|
|
|
|
std::string mNextCloudTexture;
|
|
|
|
float mCloudBlendFactor;
|
|
|
|
|
|
|
|
osg::Vec4f mFogColor;
|
|
|
|
|
|
|
|
osg::Vec4f mAmbientColor;
|
|
|
|
|
|
|
|
osg::Vec4f mSkyColor;
|
|
|
|
|
2015-09-21 17:43:48 +00:00
|
|
|
// sun light color
|
2015-08-05 02:07:42 +00:00
|
|
|
osg::Vec4f mSunColor;
|
|
|
|
|
2015-09-21 17:43:48 +00:00
|
|
|
// alpha is the sun transparency
|
2015-08-05 02:07:42 +00:00
|
|
|
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-30 04:57:45 +00: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;
|
|
|
|
};
|
|
|
|
|
2015-11-03 22:15:43 +00:00
|
|
|
///@brief The SkyManager handles rendering of the sky domes, celestial bodies as well as other objects that need to be rendered
|
|
|
|
/// relative to the camera (e.g. weather particle effects)
|
2010-06-27 23:44:15 +00:00
|
|
|
class SkyManager
|
|
|
|
{
|
|
|
|
public:
|
2015-04-14 13:55:56 +00:00
|
|
|
SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager);
|
2012-02-21 16:38:15 +00:00
|
|
|
~SkyManager();
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-21 16:38:15 +00:00
|
|
|
void update(float duration);
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void setEnabled(bool enabled);
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-25 20:06:03 +00:00
|
|
|
void setHour (double hour);
|
2012-02-21 15:15:38 +00:00
|
|
|
///< will be called even when sky is disabled.
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-25 20:06:03 +00:00
|
|
|
void setDate (int day, int month);
|
2012-02-21 15:15:38 +00:00
|
|
|
///< will be called even when sky is disabled.
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-21 16:38:15 +00:00
|
|
|
int getMasserPhase() const;
|
2012-02-21 15:15:38 +00: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 16:59:26 +00:00
|
|
|
|
2012-02-21 16:38:15 +00:00
|
|
|
int getSecundaPhase() const;
|
2012-02-21 15:15:38 +00: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 16:59:26 +00:00
|
|
|
|
2012-02-21 16:38:15 +00:00
|
|
|
void setMoonColour (bool red);
|
2012-02-21 15:15:38 +00:00
|
|
|
///< change Secunda colour to red
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2015-08-05 02:07:42 +00:00
|
|
|
void setWeather(const WeatherResult& weather);
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-24 17:30:16 +00:00
|
|
|
void sunEnable();
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2012-02-24 17:30:16 +00:00
|
|
|
void sunDisable();
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2014-06-25 16:20:21 +00:00
|
|
|
void setRainSpeed(float speed);
|
|
|
|
|
2015-05-21 23:54:06 +00:00
|
|
|
void setStormDirection(const osg::Vec3f& direction);
|
2014-06-26 17:01:49 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
void setSunDirection(const osg::Vec3f& direction);
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2015-07-30 04:57:45 +00:00
|
|
|
void setMasserState(const MoonState& state);
|
|
|
|
void setSecundaState(const MoonState& state);
|
2012-03-24 16:59:26 +00:00
|
|
|
|
2015-09-21 14:03:30 +00:00
|
|
|
void setGlareTimeOfDayFade(float val);
|
2012-04-01 13:07:41 +00:00
|
|
|
|
2015-11-03 22:15:43 +00:00
|
|
|
/// Enable or disable the water plane (used to remove underwater weather particles)
|
|
|
|
void setWaterEnabled(bool enabled);
|
|
|
|
|
|
|
|
/// Set height of water plane (used to remove underwater weather particles)
|
|
|
|
void setWaterHeight(float height);
|
|
|
|
|
2016-02-09 00:17:02 +00:00
|
|
|
void listAssetsToPreload(std::vector<std::string>& models, std::vector<std::string>& textures);
|
|
|
|
|
2012-02-21 15:15:38 +00:00
|
|
|
private:
|
2013-05-07 15:38:24 +00:00
|
|
|
void create();
|
|
|
|
///< no need to call this, automatically done on first enable()
|
|
|
|
|
2015-06-25 15:23:01 +00:00
|
|
|
void createRain();
|
|
|
|
void destroyRain();
|
|
|
|
void updateRainParameters();
|
2014-06-25 16:20:21 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
Resource::SceneManager* mSceneManager;
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Group> mRootNode;
|
2015-11-03 00:53:38 +00:00
|
|
|
osg::ref_ptr<osg::Group> mEarlyRenderBinRoot;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-06-16 14:33:31 +00:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
|
2015-04-14 13:55:56 +00:00
|
|
|
osg::ref_ptr<osg::Node> mParticleEffect;
|
2015-11-02 22:38:34 +00:00
|
|
|
std::vector<osg::ref_ptr<AlphaFader> > mParticleFaders;
|
2015-11-03 22:15:43 +00:00
|
|
|
osg::ref_ptr<UnderwaterSwitchCallback> mUnderwaterSwitch;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-06-16 14:33:31 +00:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-04-15 16:50:50 +00:00
|
|
|
osg::ref_ptr<CloudUpdater> mCloudUpdater;
|
2015-06-18 23:03:12 +00:00
|
|
|
osg::ref_ptr<CloudUpdater> mCloudUpdater2;
|
|
|
|
osg::ref_ptr<osg::Node> mCloudMesh;
|
|
|
|
osg::ref_ptr<osg::Node> mCloudMesh2;
|
2015-04-15 16:50:50 +00:00
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
osg::ref_ptr<osg::Node> mAtmosphereDay;
|
|
|
|
|
2015-06-16 14:33:31 +00:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mAtmosphereNightNode;
|
|
|
|
float mAtmosphereNightRoll;
|
2015-06-19 18:55:04 +00:00
|
|
|
osg::ref_ptr<AtmosphereNightUpdater> mAtmosphereNightUpdater;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
|
|
|
osg::ref_ptr<AtmosphereUpdater> mAtmosphereUpdater;
|
|
|
|
|
2015-08-07 05:08:18 +00:00
|
|
|
std::auto_ptr<Sun> mSun;
|
|
|
|
std::auto_ptr<Moon> mMasser;
|
|
|
|
std::auto_ptr<Moon> mSecunda;
|
2015-04-14 13:55:56 +00:00
|
|
|
|
2015-06-25 15:23:01 +00:00
|
|
|
osg::ref_ptr<osg::Group> mRainNode;
|
|
|
|
osg::ref_ptr<osgParticle::ParticleSystem> mRainParticleSystem;
|
|
|
|
osg::ref_ptr<RainShooter> mRainShooter;
|
2015-06-25 15:38:08 +00:00
|
|
|
osg::ref_ptr<RainFader> mRainFader;
|
2015-06-25 15:23:01 +00:00
|
|
|
|
2012-04-01 13:07:41 +00:00
|
|
|
bool mCreated;
|
|
|
|
|
2014-06-26 17:01:49 +00:00
|
|
|
bool mIsStorm;
|
|
|
|
|
2012-02-25 20:06:03 +00:00
|
|
|
int mDay;
|
|
|
|
int mMonth;
|
2012-03-15 18:49:15 +00:00
|
|
|
|
2012-07-11 07:08:55 +00:00
|
|
|
float mCloudAnimationTimer;
|
|
|
|
|
2014-06-25 16:20:21 +00:00
|
|
|
float mRainTimer;
|
|
|
|
|
2015-05-21 23:54:06 +00:00
|
|
|
osg::Vec3f mStormDirection;
|
2014-06-26 17:01:49 +00:00
|
|
|
|
2012-02-24 22:26:38 +00:00
|
|
|
// remember some settings so we don't have to apply them again if they didnt change
|
2015-05-21 23:54:06 +00:00
|
|
|
std::string mClouds;
|
|
|
|
std::string mNextClouds;
|
2012-02-22 18:17:37 +00:00
|
|
|
float mCloudBlendFactor;
|
2012-02-23 19:33:34 +00:00
|
|
|
float mCloudSpeed;
|
2012-02-24 22:26:38 +00:00
|
|
|
float mStarsOpacity;
|
2015-04-14 13:55:56 +00:00
|
|
|
osg::Vec4f mCloudColour;
|
|
|
|
osg::Vec4f mSkyColour;
|
|
|
|
osg::Vec4f mFogColour;
|
2012-04-06 13:05:17 +00:00
|
|
|
|
2014-06-24 13:00:15 +00:00
|
|
|
std::string mCurrentParticleEffect;
|
|
|
|
|
2012-02-22 18:17:37 +00:00
|
|
|
float mRemainingTransitionTime;
|
2012-04-06 13:05:17 +00:00
|
|
|
|
2014-06-25 16:20:21 +00:00
|
|
|
bool mRainEnabled;
|
|
|
|
std::string mRainEffect;
|
|
|
|
float mRainSpeed;
|
|
|
|
float mRainFrequency;
|
2015-06-25 15:23:01 +00:00
|
|
|
float mWindSpeed;
|
2014-06-25 16:20:21 +00:00
|
|
|
|
2012-02-24 15:12:43 +00:00
|
|
|
bool mEnabled;
|
2012-02-24 17:30:16 +00:00
|
|
|
bool mSunEnabled;
|
2015-06-19 00:51:01 +00:00
|
|
|
|
|
|
|
osg::Vec4f mMoonScriptColor;
|
2010-06-27 23:44:15 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-05-07 15:38:24 +00:00
|
|
|
#endif // GAME_RENDER_SKY_H
|