OpenMW
|
00001 #ifndef GAME_RENDER_SKY_H 00002 #define GAME_RENDER_SKY_H 00003 00004 #include <vector> 00005 00006 #include <OgreVector3.h> 00007 #include <OgreString.h> 00008 #include <OgreMaterial.h> 00009 #include <OgreColourValue.h> 00010 #include <OgreHighLevelGpuProgram.h> 00011 00012 #include <extern/shiny/Main/Factory.hpp> 00013 00014 #include <components/nifogre/ogrenifloader.hpp> 00015 00016 00017 #include "../mwworld/weather.hpp" 00018 00019 namespace Ogre 00020 { 00021 class RenderWindow; 00022 class SceneNode; 00023 class Camera; 00024 class Viewport; 00025 class SceneManager; 00026 class Entity; 00027 class BillboardSet; 00028 class TextureUnitState; 00029 } 00030 00031 namespace MWRender 00032 { 00033 class BillboardObject : public sh::MaterialInstanceListener 00034 { 00035 public: 00036 BillboardObject( const Ogre::String& textureName, 00037 const float size, 00038 const Ogre::Vector3& position, 00039 Ogre::SceneNode* rootNode, 00040 const std::string& material 00041 ); 00042 BillboardObject(); 00043 00044 void requestedConfiguration (sh::MaterialInstance* m, const std::string& configuration); 00045 void createdConfiguration (sh::MaterialInstance* m, const std::string& configuration); 00046 00047 virtual ~BillboardObject() {} 00048 00049 void setColour(const Ogre::ColourValue& pColour); 00050 void setPosition(const Ogre::Vector3& pPosition); 00051 void setVisible(const bool visible); 00052 void setRenderQueue(unsigned int id); 00053 void setVisibilityFlags(int flags); 00054 void setSize(const float size); 00055 Ogre::Vector3 getPosition() const; 00056 00057 void setVisibility(const float visibility); 00058 00059 Ogre::SceneNode* getNode(); 00060 00061 protected: 00062 float mVisibility; 00063 Ogre::ColourValue mColour; 00064 Ogre::SceneNode* mNode; 00065 sh::MaterialInstance* mMaterial; 00066 Ogre::Entity* mEntity; 00067 }; 00068 00069 00070 /* 00071 * The moons need a seperate class because of their shader (which allows them to be partially transparent) 00072 */ 00073 class Moon : public BillboardObject 00074 { 00075 public: 00076 Moon( const Ogre::String& textureName, 00077 const float size, 00078 const Ogre::Vector3& position, 00079 Ogre::SceneNode* rootNode, 00080 const std::string& material 00081 ); 00082 00083 virtual ~Moon() {} 00084 00085 enum Phase 00086 { 00087 Phase_New = 0, 00088 Phase_WaxingCrescent, 00089 Phase_WaxingHalf, 00090 Phase_WaxingGibbous, 00091 Phase_Full, 00092 Phase_WaningGibbous, 00093 Phase_WaningHalf, 00094 Phase_WaningCrescent 00095 }; 00096 00097 enum Type 00098 { 00099 Type_Masser = 0, 00100 Type_Secunda 00101 }; 00102 00103 void setPhase(const Phase& phase); 00104 void setType(const Type& type); 00105 00106 Phase getPhase() const; 00107 unsigned int getPhaseInt() const; 00108 00109 private: 00110 Type mType; 00111 Phase mPhase; 00112 }; 00113 00114 class SkyManager 00115 { 00116 public: 00117 SkyManager(Ogre::SceneNode* root, Ogre::Camera* pCamera); 00118 ~SkyManager(); 00119 00120 void update(float duration); 00121 00122 void enable(); 00123 00124 void disable(); 00125 00126 void setHour (double hour); 00128 00129 void setDate (int day, int month); 00131 00132 int getMasserPhase() const; 00135 00136 int getSecundaPhase() const; 00139 00140 void setMoonColour (bool red); 00142 00143 void setWeather(const MWWorld::WeatherResult& weather); 00144 00145 Ogre::SceneNode* getSunNode(); 00146 00147 void sunEnable(); 00148 00149 void sunDisable(); 00150 00151 void setSunDirection(const Ogre::Vector3& direction); 00152 00153 void setMasserDirection(const Ogre::Vector3& direction); 00154 00155 void setSecundaDirection(const Ogre::Vector3& direction); 00156 00157 void setMasserFade(const float fade); 00158 00159 void setSecundaFade(const float fade); 00160 00161 void masserEnable(); 00162 void masserDisable(); 00163 00164 void secundaEnable(); 00165 void secundaDisable(); 00166 00167 void setLightningStrength(const float factor); 00168 void setLightningDirection(const Ogre::Vector3& dir); 00169 void setLightningEnabled(bool enabled); 00170 00171 void setGlare(const float glare); 00172 void setGlareEnabled(bool enabled); 00173 Ogre::Vector3 getRealSunPos(); 00174 00175 private: 00176 void create(); 00178 00179 bool mCreated; 00180 00181 bool mMoonRed; 00182 00183 float mHour; 00184 int mDay; 00185 int mMonth; 00186 00187 float mCloudAnimationTimer; 00188 00189 BillboardObject* mSun; 00190 BillboardObject* mSunGlare; 00191 Moon* mMasser; 00192 Moon* mSecunda; 00193 00194 Ogre::Camera* mCamera; 00195 Ogre::SceneNode* mRootNode; 00196 Ogre::SceneManager* mSceneMgr; 00197 00198 Ogre::SceneNode* mAtmosphereDay; 00199 Ogre::SceneNode* mAtmosphereNight; 00200 00201 std::vector<NifOgre::ObjectScenePtr> mObjects; 00202 00203 // remember some settings so we don't have to apply them again if they didnt change 00204 Ogre::String mClouds; 00205 Ogre::String mNextClouds; 00206 float mCloudBlendFactor; 00207 float mCloudOpacity; 00208 float mCloudSpeed; 00209 float mStarsOpacity; 00210 Ogre::ColourValue mCloudColour; 00211 Ogre::ColourValue mSkyColour; 00212 Ogre::ColourValue mFogColour; 00213 00214 Ogre::Light* mLightning; 00215 00216 float mRemainingTransitionTime; 00217 00218 float mGlare; // target 00219 float mGlareFade; // actual 00220 00221 bool mEnabled; 00222 bool mSunEnabled; 00223 bool mMasserEnabled; 00224 bool mSecundaEnabled; 00225 }; 00226 } 00227 00228 #endif // GAME_RENDER_SKY_H