From f58d81b1e955be21d934bd5d715345872f96c00f Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 23 Oct 2005 11:46:41 +0000 Subject: [PATCH] Harald JOHSEN: the sky color now fades to black with altitude --- simgear/scene/sky/dome.cxx | 15 ++++++++++++++- simgear/scene/sky/dome.hxx | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/simgear/scene/sky/dome.cxx b/simgear/scene/sky/dome.cxx index aeed23c1..a33b219b 100644 --- a/simgear/scene/sky/dome.cxx +++ b/simgear/scene/sky/dome.cxx @@ -95,6 +95,7 @@ static int sgSkyDomePostDraw( ssgEntity *e ) { // Constructor SGSkyDome::SGSkyDome( void ) { + asl = 0.0f; } @@ -273,6 +274,13 @@ ssgBranch * SGSkyDome::build( double hscale, double vscale ) { return dome_transform; } +static void fade_to_black( sgVec4 sky_color[], float asl, int count) { + const float ref_asl = 10000.0f; + const sgVec3 space_color = {0.0f, 0.0f, 0.0f}; + float d = exp( - asl / ref_asl ); + for(int i = 0; i < count ; i++) + sgLerpVec3( sky_color[i], sky_color[i], space_color, 1.0 - d); +} // repaint the sky colors based on current value of sun_angle, sky, // and fog colors. This updates the color arrays for ssgVtxTable. @@ -437,6 +445,11 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle, */ } + fade_to_black( (sgVec4 *) center_color, asl * center_elev, 1); + fade_to_black( upper_color, (asl+0.05f) * upper_elev, 12); + fade_to_black( middle_color, (asl+0.05f) * middle_elev, 12); + fade_to_black( lower_color, (asl+0.05f) * lower_elev, 12); + for ( i = 0; i < 12; i++ ) { sgCopyVec4( bottom_color[i], fog_color ); } @@ -555,6 +568,6 @@ bool SGSkyDome::reposition( sgVec3 p, double lon, double lat, double spin ) { sgSetCoord( &skypos, TRANSFORM ); dome_transform->setTransform( &skypos ); - + asl = - skypos.xyz[2]; return true; } diff --git a/simgear/scene/sky/dome.hxx b/simgear/scene/sky/dome.hxx index e30985ce..4cd2b877 100644 --- a/simgear/scene/sky/dome.hxx +++ b/simgear/scene/sky/dome.hxx @@ -51,6 +51,8 @@ class SGSkyDome { ssgVertexArray *lower_ring_vl; ssgColourArray *lower_ring_cl; + float asl; + public: // Constructor -- 2.39.5