]> git.mxchange.org Git - flightgear.git/blobdiff - src/Time/light.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Time / light.cxx
index 28a7553a265c5929cc98c8cc9120b5c337368f68..a6021b17480206367ff866dd01ee21c290313ad9 100644 (file)
@@ -52,6 +52,7 @@ SG_USING_STD(string);
 #include <simgear/math/interpolater.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/sky/sky.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Main/globals.hxx>
@@ -60,6 +61,7 @@ SG_USING_STD(string);
 #include "light.hxx"
 #include "sunpos.hxx"
 
+extern SGSky *thesky;           // FIXME: from main.cxx
 
 fgLIGHT cur_light_params;
 
@@ -105,9 +107,12 @@ void fgLIGHT::Update( void ) {
     // if the 4th field is 0.0, this specifies a direction ...
     GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
     // base sky color
-    GLfloat base_sky_color[4] = { 0.60, 0.60, 0.90, 1.0 };
-    // base fog color
-    GLfloat base_fog_color[4] = { 0.90, 0.90, 1.00, 1.0 };
+#if defined (sgi) || defined( macintosh )
+    GLfloat base_sky_color[4] = { 0.252, 0.403, 0.657, 1.0 };
+#else // default
+    GLfloat base_sky_color[4] = { 0.336, 0.406, 0.574, 1.0 };
+#endif
+    GLfloat base_fog_color[4] = { 0.80, 0.83, 1.0, 1.0 };
     double deg, ambient, diffuse, specular, sky_brightness;
 
     f = current_aircraft.fdm_state;
@@ -117,6 +122,14 @@ void fgLIGHT::Update( void ) {
     // calculate lighting parameters based on sun's relative angle to
     // local up
 
+    // base fog color
+    float *sun_color = thesky->get_sun_color();
+
+    base_fog_color[0] *= (1.25 - sun_color[0]/4.0);    // 100% red
+    base_fog_color[1] *= (0.48 + sun_color[1]/1.923);  //  40% green
+    base_fog_color[2] *= sun_color[2];                 //   0% blue
+
+
     deg = sun_angle * SGD_RADIANS_TO_DEGREES;
     SG_LOG( SG_EVENT, SG_INFO, "  Sun angle = " << deg );