]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/dome.cxx
warning fix: initializing members in the order they are declared keeps gcc happy
[simgear.git] / simgear / scene / sky / dome.cxx
index 5842af3fbf4efeb610099fe0fa751569e8b34f11..b0c0f6c4e124ebdacafcedb24eb4c46c5501175d 100644 (file)
 #  include <simgear_config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
 #include <math.h>
 
 #include <simgear/compiler.h>
@@ -67,6 +63,7 @@ struct DomeParam
 
 const int numRings = sizeof(domeParams) / sizeof(domeParams[0]);
 const int numBands = 12;
+const int halfBands = numBands/2;
 }
 
 static const float upper_radius = 0.9701; // (.6, 0.15)
@@ -193,7 +190,7 @@ SGSkyDome::build( double hscale, double vscale ) {
     geom->addPrimitiveSet(domeElements);
     geode->addDrawable(geom);
     // force a repaint of the sky colors with ugly defaults
-    repaint(SGVec3f(1, 1, 1), SGVec3f(1, 1, 1), 0.0, 5000.0 );
+    repaint(SGVec3f(1, 1, 1), SGVec3f(1, 1, 1), SGVec3f(1, 1, 1), 0.0, 5000.0 );
     dome_transform = new osg::MatrixTransform;
     dome_transform->addChild(geode);
 
@@ -221,8 +218,8 @@ inline void clampColor(osg::Vec3& color)
 // 90 degrees = sun rise/set
 // 180 degrees = darkest midnight
 bool
-SGSkyDome::repaint( const SGVec3f& sky_color, const SGVec3f& fog_color,
-                    double sun_angle, double vis )
+SGSkyDome::repaint( const SGVec3f& sun_color, const SGVec3f& sky_color,
+                    const SGVec3f& fog_color, double sun_angle, double vis )
 {
     SGVec3f outer_param, outer_diff;
     SGVec3f middle_param, middle_diff;
@@ -266,17 +263,17 @@ SGSkyDome::repaint( const SGVec3f& sky_color, const SGVec3f& fog_color,
     const double saif = sun_angle/SG_PI;
     static const SGVec3f blueShift(0.8, 1.0, 1.2);
     const SGVec3f skyFogDelta = sky_color - fog_color;
+    const SGVec3f sunSkyDelta = sun_color - sky_color;
     // For now the colors of the upper two rings are linearly
     // interpolated between the zenith color and the first horizon
     // ring color.
     
-    for (int i = 0; i < 7; i++) {
+    for (int i = 0; i < halfBands+1; i++) {
         SGVec3f diff = mult(skyFogDelta, blueShift);
-        diff *= (0.8 + saif - ((6-i)/10));
+        diff *= (0.8 + saif - ((halfBands-i)/10));
         colors(2, i) = (sky_color - upperVisFactor * diff).osg();
         colors(3, i) = (sky_color - middleVisFactor * diff + middle_amt).osg();
         colors(4, i) = (fog_color + outer_amt).osg();
-        // Interpolate using distance along dome segment
         colors(0, i) = simgear::math::lerp(sky_color.osg(), colors(2, i), .3942);
         colors(1, i) = simgear::math::lerp(sky_color.osg(), colors(2, i), .7885);
         for (int j = 0; j < numRings - 1; ++j)
@@ -285,9 +282,9 @@ SGSkyDome::repaint( const SGVec3f& sky_color, const SGVec3f& fog_color,
         middle_amt -= middle_diff;
     }
 
-    for (int i = 7; i < 12; ++i)
+    for (int i = halfBands+1; i < numBands; ++i)
         for (int j = 0; j < 5; ++j)
-            colors(j, i) = colors(j, 12 - i);
+            colors(j, i) = colors(j, numBands - i);
 
     fade_to_black(&(*dome_cl)[0], asl * center_elev, 1);
     for (int i = 0; i < numRings - 1; ++i)