Minetest  5.4.0
Sky Class Reference

#include <sky.h>

+ Inheritance diagram for Sky:
+ Collaboration diagram for Sky:

Public Member Functions

 Sky (s32 id, ITextureSource *tsrc, IShaderSource *ssrc)
 constructor More...
 
virtual void OnRegisterSceneNode ()
 
virtual void render ()
 renders the node. More...
 
virtual const aabb3fgetBoundingBox () const
 
virtual video::SMaterial & getMaterial (u32 i)
 
virtual u32 getMaterialCount () const
 
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 ()
 
const video::SColor & getBgColor () const
 
const video::SColor & getSkyColor () const
 
void setSunVisible (bool sun_visible)
 
void setSunTexture (std::string sun_texture, std::string sun_tonemap, ITextureSource *tsrc)
 
void setSunScale (f32 sun_scale)
 
void setSunriseVisible (bool glow_visible)
 
void setSunriseTexture (std::string sunglow_texture, ITextureSource *tsrc)
 
void setMoonVisible (bool moon_visible)
 
void setMoonTexture (std::string moon_texture, std::string moon_tonemap, ITextureSource *tsrc)
 
void setMoonScale (f32 moon_scale)
 
void setStarsVisible (bool stars_visible)
 
void setStarCount (u16 star_count, bool force_update)
 
void setStarColor (video::SColor star_color)
 
void setStarScale (f32 star_scale)
 
bool getCloudsVisible () const
 
const video::SColorf & getCloudColor () const
 
void setVisible (bool visible)
 
void setCloudsEnabled (bool clouds_enabled)
 
void setFallbackBgColor (const video::SColor &fallback_bg_color)
 
void overrideColors (const video::SColor &bgcolor, const video::SColor &skycolor)
 
void setSkyColors (const SkyColor &sky_color)
 
void setHorizonTint (video::SColor sun_tint, video::SColor moon_tint, std::string use_sun_tint)
 
void setInClouds (bool clouds)
 
void clearSkyboxTextures ()
 
void addTextureToSkybox (std::string texture, int material_id, ITextureSource *tsrc)
 
const video::SColorf & getCurrentStarColor () const
 

Private Member Functions

float m_horizon_blend ()
 
video::SColor m_mix_scolor (video::SColor col1, video::SColor col2, f32 factor)
 
video::SColorf m_mix_scolorf (video::SColorf col1, video::SColorf col2, f32 factor)
 
void updateStars ()
 
void draw_sun (video::IVideoDriver *driver, float sunsize, const video::SColor &suncolor, const video::SColor &suncolor2, float wicked_time_of_day)
 
void draw_moon (video::IVideoDriver *driver, float moonsize, const video::SColor &mooncolor, const video::SColor &mooncolor2, float wicked_time_of_day)
 
void draw_sky_body (std::array< video::S3DVertex, 4 > &vertices, float pos_1, float pos_2, const video::SColor &c)
 
void draw_stars (video::IVideoDriver *driver, float wicked_time_of_day)
 
void place_sky_body (std::array< video::S3DVertex, 4 > &vertices, float horizon_position, float day_position)
 
void setSkyDefaults ()
 

Private Attributes

aabb3f m_box
 
video::SMaterial m_materials [SKY_MATERIAL_COUNT]
 
bool m_visible = true
 
video::SColor m_fallback_bg_color = video::SColor(255, 255, 255, 255)
 
bool m_first_update = true
 
float m_time_of_day
 
float m_time_brightness
 
bool m_sunlight_seen
 
float m_brightness = 0.5f
 
float m_cloud_brightness = 0.5f
 
bool m_clouds_visible
 
bool m_clouds_enabled = true
 
bool m_directional_colored_fog
 
bool m_in_clouds = true
 
bool m_enable_shaders = false
 
video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
 
video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
 
video::SColorf m_cloudcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
 
video::SColor m_bgcolor
 
video::SColor m_skycolor
 
video::SColorf m_cloudcolor_f
 
video::SColorf m_cloudcolor_day_f = video::SColorf(1, 1, 1, 1)
 
video::SColorf m_cloudcolor_dawn_f
 
SkyboxParams m_sky_params
 
SunParams m_sun_params
 
MoonParams m_moon_params
 
StarParams m_star_params
 
bool m_default_tint = true
 
u64 m_seed = 0
 
irr_ptr< scene::SMeshBuffer > m_stars
 
video::SColorf m_star_color
 
video::ITexture * m_sun_texture
 
video::ITexture * m_moon_texture
 
video::ITexture * m_sun_tonemap
 
video::ITexture * m_moon_tonemap
 

Constructor & Destructor Documentation

◆ Sky()

Member Function Documentation

◆ addTextureToSkybox()

void Sky::addTextureToSkybox ( std::string  texture,
int  material_id,
ITextureSource tsrc 
)

References baseMaterial(), ITextureSource::getTextureForMesh(), m_materials, m_sky_params, SKY_MATERIAL_COUNT, and SkyboxParams::textures.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearSkyboxTextures()

void Sky::clearSkyboxTextures ( )
inline

References m_sky_params, and SkyboxParams::textures.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ draw_moon()

void Sky::draw_moon ( video::IVideoDriver *  driver,
float  moonsize,
const video::SColor &  mooncolor,
const video::SColor &  mooncolor2,
float  wicked_time_of_day 
)
private

References draw_sky_body(), m_materials, m_moon_params, m_moon_texture, m_moon_tonemap, place_sky_body(), and MoonParams::scale.

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ draw_sky_body()

void Sky::draw_sky_body ( std::array< video::S3DVertex, 4 > &  vertices,
float  pos_1,
float  pos_2,
const video::SColor &  c 
)
private

Referenced by draw_moon(), and draw_sun().

+ Here is the caller graph for this function:

◆ draw_stars()

void Sky::draw_stars ( video::IVideoDriver *  driver,
float  wicked_time_of_day 
)
private

References irr_ptr< ReferenceCounted, class >::get(), m_materials, m_star_color, m_star_params, m_stars, and StarParams::starcolor.

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ draw_sun()

void Sky::draw_sun ( video::IVideoDriver *  driver,
float  sunsize,
const video::SColor &  suncolor,
const video::SColor &  suncolor2,
float  wicked_time_of_day 
)
private

References draw_sky_body(), m_materials, m_sun_params, m_sun_texture, m_sun_tonemap, place_sky_body(), and SunParams::scale.

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBgColor()

const video::SColor& Sky::getBgColor ( ) const
inline

References m_bgcolor, m_fallback_bg_color, and m_visible.

Referenced by GameGlobalShaderConstantSetter::onSetConstants(), and Game::updateFrame().

+ Here is the caller graph for this function:

◆ getBoundingBox()

virtual const aabb3f& Sky::getBoundingBox ( ) const
inlinevirtual

References m_box.

◆ getBrightness()

float Sky::getBrightness ( )
inline

References m_brightness.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ getCloudColor()

const video::SColorf& Sky::getCloudColor ( ) const
inline

References m_cloudcolor_f.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ getCloudsVisible()

bool Sky::getCloudsVisible ( ) const
inline

References m_clouds_enabled, and m_clouds_visible.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ getCurrentStarColor()

const video::SColorf& Sky::getCurrentStarColor ( ) const
inline

References m_star_color.

Referenced by GameGlobalShaderConstantSetter::onSetConstants().

+ Here is the caller graph for this function:

◆ getMaterial()

virtual video::SMaterial& Sky::getMaterial ( u32  i)
inlinevirtual

References m_materials.

◆ getMaterialCount()

virtual u32 Sky::getMaterialCount ( ) const
inlinevirtual

References SKY_MATERIAL_COUNT.

◆ getSkyColor()

const video::SColor& Sky::getSkyColor ( ) const
inline

References m_fallback_bg_color, m_skycolor, and m_visible.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ m_horizon_blend()

float Sky::m_horizon_blend ( )
inlineprivate

References m_sunlight_seen, and m_time_of_day.

Referenced by update().

+ Here is the caller graph for this function:

◆ m_mix_scolor()

video::SColor Sky::m_mix_scolor ( video::SColor  col1,
video::SColor  col2,
f32  factor 
)
inlineprivate

Referenced by update().

+ Here is the caller graph for this function:

◆ m_mix_scolorf()

video::SColorf Sky::m_mix_scolorf ( video::SColorf  col1,
video::SColorf  col2,
f32  factor 
)
inlineprivate

Referenced by update().

+ Here is the caller graph for this function:

◆ OnRegisterSceneNode()

void Sky::OnRegisterSceneNode ( )
virtual

◆ overrideColors()

void Sky::overrideColors ( const video::SColor &  bgcolor,
const video::SColor &  skycolor 
)
inline

References m_bgcolor, and m_skycolor.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ place_sky_body()

void Sky::place_sky_body ( std::array< video::S3DVertex, 4 > &  vertices,
float  horizon_position,
float  day_position 
)
private

Referenced by draw_moon(), and draw_sun().

+ Here is the caller graph for this function:

◆ render()

void Sky::render ( )
virtual

◆ setCloudsEnabled()

void Sky::setCloudsEnabled ( bool  clouds_enabled)
inline

References m_clouds_enabled.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ setFallbackBgColor()

void Sky::setFallbackBgColor ( const video::SColor &  fallback_bg_color)
inline

References m_fallback_bg_color.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ setHorizonTint()

void Sky::setHorizonTint ( video::SColor  sun_tint,
video::SColor  moon_tint,
std::string  use_sun_tint 
)

References SkyboxParams::fog_moon_tint, SkyboxParams::fog_sun_tint, m_default_tint, and m_sky_params.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ setInClouds()

void Sky::setInClouds ( bool  clouds)
inline

References m_in_clouds.

Referenced by Game::updateFrame().

+ Here is the caller graph for this function:

◆ setMoonScale()

void Sky::setMoonScale ( f32  moon_scale)
inline

References m_moon_params, and MoonParams::scale.

Referenced by Game::handleClientEvent_SetMoon().

+ Here is the caller graph for this function:

◆ setMoonTexture()

void Sky::setMoonTexture ( std::string  moon_texture,
std::string  moon_tonemap,
ITextureSource tsrc 
)

References baseMaterial(), ITextureSource::getTexture(), ITextureSource::getTextureForMesh(), ITextureSource::isKnownSourceImage(), m_materials, m_moon_params, m_moon_texture, m_moon_tonemap, MoonParams::texture, and MoonParams::tonemap.

Referenced by Game::handleClientEvent_SetMoon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMoonVisible()

void Sky::setMoonVisible ( bool  moon_visible)
inline

References m_moon_params, and MoonParams::visible.

Referenced by Game::handleClientEvent_SetMoon().

+ Here is the caller graph for this function:

◆ setSkyColors()

void Sky::setSkyColors ( const SkyColor sky_color)

References m_sky_params, and SkyboxParams::sky_color.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ setSkyDefaults()

void Sky::setSkyDefaults ( )
private

References SkyboxDefaults::getMoonDefaults(), SkyboxDefaults::getSkyColorDefaults(), SkyboxDefaults::getStarDefaults(), SkyboxDefaults::getSunDefaults(), m_moon_params, m_sky_params, m_star_params, m_sun_params, and SkyboxParams::sky_color.

Referenced by Sky().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStarColor()

void Sky::setStarColor ( video::SColor  star_color)
inline

References m_star_params, and StarParams::starcolor.

Referenced by Game::handleClientEvent_SetStars().

+ Here is the caller graph for this function:

◆ setStarCount()

void Sky::setStarCount ( u16  star_count,
bool  force_update 
)

References StarParams::count, m_seed, m_star_params, myrand(), and updateStars().

Referenced by Sky(), and Game::handleClientEvent_SetStars().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStarScale()

void Sky::setStarScale ( f32  star_scale)
inline

References m_star_params, StarParams::scale, and updateStars().

Referenced by Game::handleClientEvent_SetStars().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStarsVisible()

void Sky::setStarsVisible ( bool  stars_visible)
inline

References m_star_params, and StarParams::visible.

Referenced by Game::handleClientEvent_SetStars().

+ Here is the caller graph for this function:

◆ setSunriseTexture()

void Sky::setSunriseTexture ( std::string  sunglow_texture,
ITextureSource tsrc 
)

References ITextureSource::getTextureForMesh(), m_materials, m_sun_params, and SunParams::sunrise.

Referenced by Game::handleClientEvent_SetSun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSunriseVisible()

void Sky::setSunriseVisible ( bool  glow_visible)
inline

References m_sun_params, and SunParams::sunrise_visible.

Referenced by Game::handleClientEvent_SetSun().

+ Here is the caller graph for this function:

◆ setSunScale()

void Sky::setSunScale ( f32  sun_scale)
inline

References m_sun_params, and SunParams::scale.

Referenced by Game::handleClientEvent_SetSun().

+ Here is the caller graph for this function:

◆ setSunTexture()

void Sky::setSunTexture ( std::string  sun_texture,
std::string  sun_tonemap,
ITextureSource tsrc 
)

References baseMaterial(), ITextureSource::getTexture(), ITextureSource::getTextureForMesh(), ITextureSource::isKnownSourceImage(), m_materials, m_sun_params, m_sun_texture, m_sun_tonemap, SunParams::texture, and SunParams::tonemap.

Referenced by Game::handleClientEvent_SetSun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSunVisible()

void Sky::setSunVisible ( bool  sun_visible)
inline

References m_sun_params, and SunParams::visible.

Referenced by Game::handleClientEvent_SetSun().

+ Here is the caller graph for this function:

◆ setVisible()

void Sky::setVisible ( bool  visible)
inline

References m_visible.

Referenced by Game::handleClientEvent_SetSky().

+ Here is the caller graph for this function:

◆ update()

void Sky::update ( float  m_time_of_day,
float  time_brightness,
float  direct_brightness,
bool  sunlight_seen,
CameraMode  cam_mode,
float  yaw,
float  pitch 
)

◆ updateStars()

void Sky::updateStars ( )
private

References StarParams::count, m_seed, m_star_params, m_stars, p(), PcgRandom::range(), irr_ptr< ReferenceCounted, class >::reset(), StarParams::scale, StarParams::starcolor, and warningstream.

Referenced by setStarCount(), and setStarScale().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bgcolor

video::SColor Sky::m_bgcolor
private

◆ m_bgcolor_bright_f

video::SColorf Sky::m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
private

Referenced by update().

◆ m_box

aabb3f Sky::m_box
private

Referenced by Sky(), and getBoundingBox().

◆ m_brightness

float Sky::m_brightness = 0.5f
private

Referenced by getBrightness(), render(), and update().

◆ m_cloud_brightness

float Sky::m_cloud_brightness = 0.5f
private

Referenced by update().

◆ m_cloudcolor_bright_f

video::SColorf Sky::m_cloudcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
private

Referenced by update().

◆ m_cloudcolor_dawn_f

video::SColorf Sky::m_cloudcolor_dawn_f
private
Initial value:
= video::SColorf(
255.0f/240.0f,
223.0f/240.0f,
191.0f/255.0f
)

Referenced by update().

◆ m_cloudcolor_day_f

video::SColorf Sky::m_cloudcolor_day_f = video::SColorf(1, 1, 1, 1)
private

Referenced by update().

◆ m_cloudcolor_f

video::SColorf Sky::m_cloudcolor_f
private

Referenced by getCloudColor(), and update().

◆ m_clouds_enabled

bool Sky::m_clouds_enabled = true
private

◆ m_clouds_visible

bool Sky::m_clouds_visible
private

Referenced by getCloudsVisible(), and update().

◆ m_default_tint

bool Sky::m_default_tint = true
private

Referenced by setHorizonTint(), and update().

◆ m_directional_colored_fog

bool Sky::m_directional_colored_fog
private

Referenced by Sky(), and update().

◆ m_enable_shaders

bool Sky::m_enable_shaders = false
private

Referenced by Sky().

◆ m_fallback_bg_color

video::SColor Sky::m_fallback_bg_color = video::SColor(255, 255, 255, 255)
private

◆ m_first_update

bool Sky::m_first_update = true
private

Referenced by update().

◆ m_in_clouds

bool Sky::m_in_clouds = true
private

Referenced by render(), setInClouds(), and update().

◆ m_materials

◆ m_moon_params

◆ m_moon_texture

video::ITexture* Sky::m_moon_texture
private

Referenced by Sky(), draw_moon(), and setMoonTexture().

◆ m_moon_tonemap

video::ITexture* Sky::m_moon_tonemap
private

◆ m_seed

u64 Sky::m_seed = 0
private

Referenced by setStarCount(), and updateStars().

◆ m_sky_params

◆ m_skycolor

video::SColor Sky::m_skycolor
private

◆ m_skycolor_bright_f

video::SColorf Sky::m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f)
private

Referenced by update().

◆ m_star_color

video::SColorf Sky::m_star_color
private

Referenced by draw_stars(), and getCurrentStarColor().

◆ m_star_params

◆ m_stars

irr_ptr<scene::SMeshBuffer> Sky::m_stars
private

Referenced by draw_stars(), and updateStars().

◆ m_sun_params

◆ m_sun_texture

video::ITexture* Sky::m_sun_texture
private

Referenced by Sky(), draw_sun(), and setSunTexture().

◆ m_sun_tonemap

video::ITexture* Sky::m_sun_tonemap
private

◆ m_sunlight_seen

bool Sky::m_sunlight_seen
private

Referenced by m_horizon_blend(), render(), and update().

◆ m_time_brightness

float Sky::m_time_brightness
private

Referenced by render(), and update().

◆ m_time_of_day

float Sky::m_time_of_day
private

Referenced by m_horizon_blend(), render(), and update().

◆ m_visible

bool Sky::m_visible = true
private

The documentation for this class was generated from the following files: