|
@@ -17,9 +17,9 @@ with this program; if not, write to the Free Software Foundation, Inc., |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
|
*/ |
|
|
|
|
|
#include "irrlichttypes_extrabloated.h" |
|
|
#include <ISceneNode.h> |
|
|
#include "camera.h" |
|
|
#include "irrlichttypes_extrabloated.h" |
|
|
|
|
|
#ifndef SKY_HEADER |
|
|
#define SKY_HEADER |
|
@@ -34,30 +34,26 @@ class Sky : public scene::ISceneNode |
|
|
{ |
|
|
public: |
|
|
//! constructor |
|
|
Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, |
|
|
Sky(scene::ISceneNode *parent, scene::ISceneManager *mgr, s32 id, |
|
|
ITextureSource *tsrc); |
|
|
|
|
|
virtual void OnRegisterSceneNode(); |
|
|
|
|
|
//! renders the node. |
|
|
virtual void render(); |
|
|
|
|
|
virtual const aabb3f &getBoundingBox() const |
|
|
{ return m_box; } |
|
|
virtual const aabb3f &getBoundingBox() const { return m_box; } |
|
|
|
|
|
// Used by Irrlicht for optimizing rendering |
|
|
virtual video::SMaterial& getMaterial(u32 i) |
|
|
{ return m_materials[i]; } |
|
|
virtual video::SMaterial &getMaterial(u32 i) { return m_materials[i]; } |
|
|
|
|
|
// Used by Irrlicht for optimizing rendering |
|
|
virtual u32 getMaterialCount() const |
|
|
{ return SKY_MATERIAL_COUNT; } |
|
|
virtual u32 getMaterialCount() const { return SKY_MATERIAL_COUNT; } |
|
|
|
|
|
void update(float m_time_of_day, float time_brightness, |
|
|
float direct_brightness, bool sunlight_seen, CameraMode cam_mode, |
|
|
float yaw, float pitch); |
|
|
void update(float m_time_of_day, float time_brightness, float direct_brightness, |
|
|
bool sunlight_seen, CameraMode cam_mode, float yaw, float pitch); |
|
|
|
|
|
float getBrightness(){ return m_brightness; } |
|
|
float getBrightness() { return m_brightness; } |
|
|
|
|
|
const video::SColor &getBgColor() const |
|
|
{ |
|
@@ -72,8 +68,9 @@ class Sky : public scene::ISceneNode |
|
|
bool getCloudsVisible() { return m_clouds_visible && m_visible; } |
|
|
const video::SColorf &getCloudColor() { return m_cloudcolor_f; } |
|
|
|
|
|
void setVisible(bool visible){ m_visible = visible; } |
|
|
void setFallbackBgColor(const video::SColor &fallback_bg_color){ |
|
|
void setVisible(bool visible) { m_visible = visible; } |
|
|
void setFallbackBgColor(const video::SColor &fallback_bg_color) |
|
|
{ |
|
|
m_fallback_bg_color = fallback_bg_color; |
|
|
} |
|
|
|
|
@@ -86,7 +83,8 @@ class Sky : public scene::ISceneNode |
|
|
{ |
|
|
if (!m_sunlight_seen) |
|
|
return 0; |
|
|
float x = m_time_of_day >= 0.5 ? (1 - m_time_of_day) * 2 : 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; |
|
@@ -101,19 +99,19 @@ class Sky : public scene::ISceneNode |
|
|
video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor) |
|
|
{ |
|
|
video::SColor result = video::SColor( |
|
|
col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor, |
|
|
col1.getRed() * (1 - factor) + col2.getRed() * factor, |
|
|
col1.getGreen() * (1 - factor) + col2.getGreen() * factor, |
|
|
col1.getBlue() * (1 - factor) + col2.getBlue() * factor); |
|
|
col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor, |
|
|
col1.getRed() * (1 - factor) + col2.getRed() * factor, |
|
|
col1.getGreen() * (1 - factor) + col2.getGreen() * factor, |
|
|
col1.getBlue() * (1 - factor) + col2.getBlue() * factor); |
|
|
return result; |
|
|
} |
|
|
video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor) |
|
|
{ |
|
|
video::SColorf result = video::SColorf( |
|
|
col1.r * (1 - factor) + col2.r * factor, |
|
|
col1.g * (1 - factor) + col2.g * factor, |
|
|
col1.b * (1 - factor) + col2.b * factor, |
|
|
col1.a * (1 - factor) + col2.a * factor); |
|
|
video::SColorf result = |
|
|
video::SColorf(col1.r * (1 - factor) + col2.r * factor, |
|
|
col1.g * (1 - factor) + col2.g * factor, |
|
|
col1.b * (1 - factor) + col2.b * factor, |
|
|
col1.a * (1 - factor) + col2.a * factor); |
|
|
return result; |
|
|
} |
|
|
|
|
@@ -134,12 +132,11 @@ class Sky : public scene::ISceneNode |
|
|
video::SColor m_skycolor; |
|
|
video::SColorf m_cloudcolor_f; |
|
|
v3f m_stars[SKY_STAR_COUNT]; |
|
|
video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4]; |
|
|
video::ITexture* m_sun_texture; |
|
|
video::ITexture* m_moon_texture; |
|
|
video::ITexture* m_sun_tonemap; |
|
|
video::ITexture* m_moon_tonemap; |
|
|
video::S3DVertex m_star_vertices[SKY_STAR_COUNT * 4]; |
|
|
video::ITexture *m_sun_texture; |
|
|
video::ITexture *m_moon_texture; |
|
|
video::ITexture *m_sun_tonemap; |
|
|
video::ITexture *m_moon_tonemap; |
|
|
}; |
|
|
|
|
|
#endif |
|
|
|