1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 01:49:54 +00:00
openmw-tes3mp/apps/openmw/mwrender/sky.hpp

226 lines
5.9 KiB
C++
Raw Normal View History

#ifndef _GAME_RENDER_SKY_H
#define _GAME_RENDER_SKY_H
#include <OgreVector3.h>
#include <OgreString.h>
#include <OgreMaterial.h>
#include <OgreColourValue.h>
#include <OgreHighLevelGpuProgram.h>
#include "sky.hpp"
#include "../mwworld/weather.hpp"
namespace Ogre
{
class RenderWindow;
class SceneNode;
class Camera;
class Viewport;
class SceneManager;
class Entity;
class BillboardSet;
2012-02-25 12:46:17 +00:00
class TextureUnitState;
class Overlay;
}
namespace MWRender
{
2012-02-25 12:46:17 +00:00
class BillboardObject
{
public:
BillboardObject( const Ogre::String& textureName,
2012-02-25 15:36:45 +00:00
const float size,
const Ogre::Vector3& position,
Ogre::SceneNode* rootNode
);
BillboardObject();
virtual ~BillboardObject() {}
void setColour(const Ogre::ColourValue& pColour);
void setPosition(const Ogre::Vector3& pPosition);
void setVisible(const bool visible);
void setRenderQueue(unsigned int id);
2012-02-26 19:46:09 +00:00
void setSize(const float size);
Ogre::Vector3 getPosition() const;
void setVisibility(const float visibility);
Ogre::SceneNode* getNode();
protected:
virtual void init(const Ogre::String& textureName,
2012-02-25 15:36:45 +00:00
const float size,
const Ogre::Vector3& position,
Ogre::SceneNode* rootNode);
Ogre::SceneNode* mNode;
Ogre::MaterialPtr mMaterial;
Ogre::BillboardSet* mBBSet;
};
/*
* The moons need a seperate class because of their shader (which allows them to be partially transparent)
*/
class Moon : public BillboardObject
{
public:
Moon( const Ogre::String& textureName,
2012-02-25 15:36:45 +00:00
const float size,
const Ogre::Vector3& position,
Ogre::SceneNode* rootNode
);
virtual ~Moon() {}
2012-02-21 16:38:15 +00:00
enum Phase
{
Phase_New = 0,
Phase_WaxingCrescent,
Phase_WaxingHalf,
Phase_WaxingGibbous,
Phase_Full,
2012-02-21 16:38:15 +00:00
Phase_WaningGibbous,
Phase_WaningHalf,
Phase_WaningCrescent
2012-02-21 16:38:15 +00:00
};
2012-02-21 16:38:15 +00:00
enum Type
{
Type_Masser = 0,
Type_Secunda
};
void setPhase(const Phase& phase);
void setType(const Type& type);
2012-03-15 19:35:23 +00:00
void setSkyColour(const Ogre::ColourValue& colour);
2012-02-21 16:38:15 +00:00
Phase getPhase() const;
unsigned int getPhaseInt() const;
2012-02-21 16:38:15 +00:00
private:
Type mType;
Phase mPhase;
};
class SkyManager
{
public:
2012-03-16 18:02:33 +00:00
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env);
2012-02-21 16:38:15 +00:00
~SkyManager();
2012-02-21 16:38:15 +00:00
void update(float duration);
void create();
///< no need to call this, automatically done on first enable()
2012-02-21 16:38:15 +00:00
void enable();
2012-02-21 16:38:15 +00:00
void disable();
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
2012-02-21 21:11:41 +00:00
void setCloudsOpacity(float opacity);
///< change opacity of the clouds
void setWeather(const MWWorld::WeatherResult& weather);
Ogre::SceneNode* getSunNode();
void sunEnable();
void sunDisable();
void setSunDirection(const Ogre::Vector3& direction);
2012-02-25 15:36:45 +00:00
void setMasserDirection(const Ogre::Vector3& direction);
2012-02-25 15:36:45 +00:00
void setSecundaDirection(const Ogre::Vector3& direction);
2012-02-25 15:36:45 +00:00
void setMasserFade(const float fade);
2012-02-25 15:36:45 +00:00
void setSecundaFade(const float fade);
2012-02-25 15:36:45 +00:00
void masserEnable();
void masserDisable();
void secundaEnable();
void secundaDisable();
2012-02-25 12:46:17 +00:00
void setThunder(const float factor);
void setGlare(const float glare);
Ogre::Vector3 getRealSunPos();
private:
bool mCreated;
2012-03-16 18:02:33 +00:00
MWWorld::Environment* mEnvironment;
float mHour;
int mDay;
int mMonth;
2012-03-15 18:49:15 +00:00
BillboardObject* mSun;
BillboardObject* mSunGlare;
Moon* mMasser;
Moon* mSecunda;
Ogre::Viewport* mViewport;
Ogre::SceneNode* mRootNode;
Ogre::SceneManager* mSceneMgr;
Ogre::SceneNode* mAtmosphereDay;
Ogre::SceneNode* mAtmosphereNight;
Ogre::MaterialPtr mCloudMaterial;
Ogre::MaterialPtr mAtmosphereMaterial;
Ogre::MaterialPtr mStarsMaterials[7];
Ogre::HighLevelGpuProgramPtr mCloudFragmentShader;
// remember some settings so we don't have to apply them again if they didnt change
Ogre::String mClouds;
Ogre::String mNextClouds;
float mCloudBlendFactor;
float mCloudOpacity;
float mCloudSpeed;
float mStarsOpacity;
Ogre::ColourValue mCloudColour;
Ogre::ColourValue mSkyColour;
2012-02-25 12:46:17 +00:00
Ogre::Overlay* mThunderOverlay;
Ogre::TextureUnitState* mThunderTextureUnit;
float mRemainingTransitionTime;
float mGlare; // target
float mGlareFade; // actual
2012-02-26 19:46:09 +00:00
void ModVertexAlpha(Ogre::Entity* ent, unsigned int meshType);
bool mEnabled;
bool mSunEnabled;
2012-02-25 15:36:45 +00:00
bool mMasserEnabled;
bool mSecundaEnabled;
};
}
#endif // _GAME_RENDER_SKY_H