X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fsky.h;h=5023cc68264581fac36cb021abfc93fe4b1afd12;hb=ad5ac39d8d1a8b8f6f0fe077e20bac914ddc624b;hp=9de9d9947075fbed21b618627ecbd55545ffc594;hpb=c120ea57c992ff2faf2fbf9e94846e912994e06f;p=oweals%2Fminetest.git diff --git a/src/sky.h b/src/sky.h index 9de9d9947..5023cc682 100644 --- a/src/sky.h +++ b/src/sky.h @@ -19,20 +19,23 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include -#include "localplayer.h" +#include "camera.h" #ifndef SKY_HEADER #define SKY_HEADER -#define SKY_MATERIAL_COUNT 3 +#define SKY_MATERIAL_COUNT 5 #define SKY_STAR_COUNT 200 +class ITextureSource; + // Skybox, rendered with zbuffer turned off, before all other nodes. class Sky : public scene::ISceneNode { public: //! constructor - Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlayer* player); + Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, + ITextureSource *tsrc); virtual void OnRegisterSceneNode(); @@ -50,15 +53,26 @@ public: { return SKY_MATERIAL_COUNT; } void update(float m_time_of_day, float time_brightness, - float direct_brightness, bool sunlight_seen); + float direct_brightness, bool sunlight_seen, CameraMode cam_mode, + float yaw, float pitch); float getBrightness(){ return m_brightness; } - video::SColor getBgColor(){ return m_bgcolor; } - video::SColor getSkyColor(){ return m_skycolor; } + + video::SColor getBgColor(){ + return m_visible ? m_bgcolor : m_fallback_bg_color; + } + video::SColor getSkyColor(){ + return m_visible ? m_skycolor : m_fallback_bg_color; + } - bool getCloudsVisible(){ return m_clouds_visible; } + bool getCloudsVisible(){ return m_clouds_visible && m_visible; } video::SColorf getCloudColor(){ return m_cloudcolor_f; } + void setVisible(bool visible){ m_visible = visible; } + void setFallbackBgColor(const video::SColor &fallback_bg_color){ + m_fallback_bg_color = fallback_bg_color; + } + private: core::aabbox3d Box; video::SMaterial m_materials[SKY_MATERIAL_COUNT]; @@ -68,7 +82,8 @@ private: { if (!m_sunlight_seen) return 0; - float x; m_time_of_day >= 0.5 ? x = (1 - m_time_of_day) * 2 : x = m_time_of_day * 2; + float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2 : m_time_of_day * 2; + if (x <= 0.3) return 0; if (x <= 0.4) // when the sun and moon are aligned @@ -98,6 +113,8 @@ private: return result; } + bool m_visible; + video::SColor m_fallback_bg_color; // Used when m_visible=false bool m_first_update; float m_time_of_day; float m_time_brightness; @@ -113,9 +130,11 @@ private: video::SColor m_skycolor; video::SColorf m_cloudcolor_f; v3f m_stars[SKY_STAR_COUNT]; - u16 m_star_indices[SKY_STAR_COUNT*4]; video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4]; - LocalPlayer* m_player; + video::ITexture* m_sun_texture; + video::ITexture* m_moon_texture; + video::ITexture* m_sun_tonemap; + video::ITexture* m_moon_tonemap; }; #endif