#endif
#include <math.h>
+#include <iterator>
#include <simgear/compiler.h>
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)
const float upperVisFactor = 1.0 - vis_factor * (0.7 + 0.3 * cvf/45000);
const float middleVisFactor = 1.0 - vis_factor * (0.1 + 0.85 * cvf/45000);
- (*dome_cl)[0] = sky_color.osg();
+ (*dome_cl)[0] = toOsg(sky_color);
simgear::VectorArrayAdapter<Vec3Array> colors(*dome_cl, numBands, 1);
const double saif = sun_angle/SG_PI;
static const SGVec3f blueShift(0.8, 1.0, 1.2);
// interpolated between the zenith color and the first horizon
// ring color.
- int halfBands = numBands/2;
- float ialpha_init = 1.0/halfBands;
- float alpha = 1.0, ialpha = 0.0;
for (int i = 0; i < halfBands+1; i++) {
SGVec3f diff = mult(skyFogDelta, blueShift);
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
- SGVec3f trans_color;
- trans_color[0] = sun_color[0]*alpha + sky_color[0]*ialpha;
- trans_color[1] = sun_color[1]*alpha + sky_color[1]*ialpha;
- trans_color[2] = sun_color[2]*alpha + sky_color[2]*ialpha;
- ialpha += ialpha_init;
- alpha -= ialpha_init;
- colors(0, i) = simgear::math::lerp(trans_color.osg(), colors(2, i), .3942);
- colors(1, i) = simgear::math::lerp(trans_color.osg(), colors(2, i), .7885);
+ colors(2, i) = toOsg(sky_color - upperVisFactor * diff);
+ colors(3, i) = toOsg(sky_color - middleVisFactor * diff + middle_amt);
+ colors(4, i) = toOsg(fog_color + outer_amt);
+ colors(0, i) = simgear::math::lerp(toOsg(sky_color), colors(2, i), .3942);
+ colors(1, i) = simgear::math::lerp(toOsg(sky_color), colors(2, i), .7885);
for (int j = 0; j < numRings - 1; ++j)
clampColor(colors(j, i));
outer_amt -= outer_diff;
middle_amt -= middle_diff;
}
-printf("\n");
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)
numBands);
for ( int i = 0; i < numBands; i++ )
- colors(numRings - 1, i) = fog_color.osg();
+ colors(numRings - 1, i) = toOsg(fog_color);
dome_cl->dirty();
return true;
}
// Translate to view position
// Point3D zero_elev = current_view.get_cur_zero_elev();
// xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() );
- T.makeTranslate( p.osg() );
+ T.makeTranslate( toOsg(p) );
// printf(" Translated to %.2f %.2f %.2f\n",
// zero_elev.x, zero_elev.y, zero_elev.z );