1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-12 03:36:32 +00:00
OpenMW/apps/openmw/mwrender/sky.hpp

242 lines
6.0 KiB
C++
Raw Normal View History

#ifndef OPENMW_MWRENDER_SKY_H
#define OPENMW_MWRENDER_SKY_H
#include <string>
#include <memory>
2016-03-10 11:59:17 +00:00
#include <vector>
#include <osg/ref_ptr>
#include <osg/Vec4f>
namespace osg
{
class Group;
class Node;
class Material;
2016-03-10 11:59:17 +00:00
class PositionAttitudeTransform;
}
2015-06-25 15:23:01 +00:00
namespace osgParticle
{
class ParticleSystem;
}
namespace Resource
{
class SceneManager;
}
namespace MWRender
{
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;
class UnderwaterSwitchCallback;
struct WeatherResult
{
std::string mCloudTexture;
std::string mNextCloudTexture;
float mCloudBlendFactor;
osg::Vec4f mFogColor;
osg::Vec4f mAmbientColor;
osg::Vec4f mSkyColor;
// sun light color
osg::Vec4f mSunColor;
// alpha is the sun transparency
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;
};
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;
};
///@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)
class SkyManager
{
public:
SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneManager);
2012-02-21 16:38:15 +00:00
~SkyManager();
2012-02-21 16:38:15 +00:00
void update(float duration);
void setEnabled(bool enabled);
void setHour (double hour);
///< will be called even when sky is disabled.
void setDate (int day, int month);
///< will be called even when sky is disabled.
2012-02-21 16:38:15 +00:00
int getMasserPhase() const;
///< 0 new moon, 1 waxing or waning cresecent, 2 waxing or waning half,
/// 3 waxing or waning gibbous, 4 full moon
2012-02-21 16:38:15 +00:00
int getSecundaPhase() const;
///< 0 new moon, 1 waxing or waning cresecent, 2 waxing or waning half,
/// 3 waxing or waning gibbous, 4 full moon
2012-02-21 16:38:15 +00:00
void setMoonColour (bool red);
///< change Secunda colour to red
void setWeather(const WeatherResult& weather);
void sunEnable();
void sunDisable();
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);
void setSunDirection(const osg::Vec3f& direction);
void setMasserState(const MoonState& state);
void setSecundaState(const MoonState& state);
2015-09-21 14:03:30 +00:00
void setGlareTimeOfDayFade(float val);
/// 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);
private:
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
Resource::SceneManager* mSceneManager;
osg::ref_ptr<osg::Group> mRootNode;
osg::ref_ptr<osg::Group> mEarlyRenderBinRoot;
2015-06-16 14:33:31 +00:00
osg::ref_ptr<osg::PositionAttitudeTransform> mParticleNode;
osg::ref_ptr<osg::Node> mParticleEffect;
std::vector<osg::ref_ptr<AlphaFader> > mParticleFaders;
osg::ref_ptr<UnderwaterSwitchCallback> mUnderwaterSwitch;
2015-06-16 14:33:31 +00:00
osg::ref_ptr<osg::PositionAttitudeTransform> mCloudNode;
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
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;
osg::ref_ptr<AtmosphereUpdater> mAtmosphereUpdater;
std::auto_ptr<Sun> mSun;
std::auto_ptr<Moon> mMasser;
std::auto_ptr<Moon> mSecunda;
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
bool mCreated;
bool mIsStorm;
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;
// 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;
float mCloudBlendFactor;
float mCloudSpeed;
float mStarsOpacity;
osg::Vec4f mCloudColour;
osg::Vec4f mSkyColour;
osg::Vec4f mFogColour;
std::string mCurrentParticleEffect;
float mRemainingTransitionTime;
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
bool mEnabled;
bool mSunEnabled;
2015-06-19 00:51:01 +00:00
osg::Vec4f mMoonScriptColor;
};
}
#endif // GAME_RENDER_SKY_H