Modified Files:
src/Time/tmp.cxx src/Time/light.hxx src/Time/light.cxx src/Main/renderer.cxx src/Cockpit/panel.cxx: Initialize sky colors
This commit is contained in:
parent
9148f9065a
commit
bb7c889bbb
5 changed files with 61 additions and 46 deletions
|
@ -368,7 +368,6 @@ FGPanel::draw(osg::State& state)
|
|||
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
|
||||
material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
|
||||
panelStateSet->setAttribute(material);
|
||||
panelStateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON);
|
||||
panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
|
||||
if ( _enable_depth_test )
|
||||
|
@ -380,7 +379,7 @@ FGPanel::draw(osg::State& state)
|
|||
state.apply();
|
||||
|
||||
FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
|
||||
sgCopyVec4( panel_color, l->scene_diffuse());
|
||||
sgCopyVec4( panel_color, l->scene_diffuse().data());
|
||||
if ( fgGetDouble("/systems/electrical/outputs/instrument-lights") > 1.0 ) {
|
||||
if ( panel_color[0] < 0.7 ) panel_color[0] = 0.7;
|
||||
if ( panel_color[1] < 0.2 ) panel_color[1] = 0.2;
|
||||
|
|
|
@ -112,16 +112,13 @@ public:
|
|||
osg::Light* light = static_cast<osg::Light*>(stateAttribute);
|
||||
|
||||
FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting"));
|
||||
SGVec4f ambient(l->scene_ambient());
|
||||
light->setAmbient(ambient.osg());
|
||||
SGVec4f diffuse(l->scene_diffuse());
|
||||
light->setDiffuse(diffuse.osg());
|
||||
SGVec4f specular(l->scene_specular());
|
||||
light->setSpecular(specular.osg());
|
||||
light->setAmbient(l->scene_ambient().osg());
|
||||
light->setDiffuse(l->scene_diffuse().osg());
|
||||
light->setSpecular(l->scene_specular().osg());
|
||||
SGVec4f position(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2], 0);
|
||||
light->setPosition(position.osg());
|
||||
|
||||
light->setDirection(osg::Vec3(0, 0, -1));
|
||||
SGVec3f direction(l->sun_vec()[0], l->sun_vec()[1], l->sun_vec()[2]);
|
||||
light->setDirection(direction.osg());
|
||||
light->setSpotExponent(0);
|
||||
light->setSpotCutoff(180);
|
||||
light->setConstantAttenuation(1);
|
||||
|
@ -554,9 +551,9 @@ FGRenderer::update( bool refresh_camera_settings ) {
|
|||
|
||||
static SGSkyColor scolor;
|
||||
|
||||
scolor.sky_color = SGVec3f(l->sky_color());
|
||||
scolor.fog_color = SGVec3f(l->adj_fog_color());
|
||||
scolor.cloud_color = SGVec3f(l->cloud_color());
|
||||
scolor.sky_color = SGVec3f(l->sky_color().data());
|
||||
scolor.fog_color = SGVec3f(l->adj_fog_color().data());
|
||||
scolor.cloud_color = SGVec3f(l->cloud_color().data());
|
||||
scolor.sun_angle = l->get_sun_angle();
|
||||
scolor.moon_angle = l->get_moon_angle();
|
||||
scolor.nplanets = globals->get_ephem()->getNumPlanets();
|
||||
|
|
|
@ -68,11 +68,30 @@ FGLight::FGLight ()
|
|||
_diffuse_tbl( NULL ),
|
||||
_specular_tbl( NULL ),
|
||||
_sky_tbl( NULL ),
|
||||
_sun_lon(0),
|
||||
_sun_gc_lat(0),
|
||||
_moon_lon(0),
|
||||
_moon_gc_lat(0),
|
||||
_sunpos(0, 0, 0),
|
||||
_moonpos(0, 0, 0),
|
||||
_sun_vec(0, 0, 0, 0),
|
||||
_moon_vec(0, 0, 0, 0),
|
||||
_sun_vec_inv(0, 0, 0, 0),
|
||||
_moon_vec_inv(0, 0, 0, 0),
|
||||
_sun_angle(0),
|
||||
_moon_angle(0),
|
||||
_prev_sun_angle(-9999.0),
|
||||
_sun_rotation( 0.0 ),
|
||||
_dt_total( 0.0 )
|
||||
_prev_sun_angle(0),
|
||||
_sun_rotation(0),
|
||||
_moon_rotation(0),
|
||||
_scene_ambient(0, 0, 0, 0),
|
||||
_scene_diffuse(0, 0, 0, 0),
|
||||
_scene_specular(0, 0, 0, 0),
|
||||
_sky_color(0, 0, 0, 0),
|
||||
_fog_color(0, 0, 0, 0),
|
||||
_cloud_color(0, 0, 0, 0),
|
||||
_adj_fog_color(0, 0, 0, 0),
|
||||
_adj_sky_color(0, 0, 0, 0),
|
||||
_dt_total(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -211,14 +230,14 @@ void FGLight::update_sky_color () {
|
|||
_sky_color[1] = base_sky_color[1] * sky_brightness;
|
||||
_sky_color[2] = base_sky_color[2] * sky_brightness;
|
||||
_sky_color[3] = base_sky_color[3];
|
||||
gamma_correct_rgb( _sky_color );
|
||||
gamma_correct_rgb( _sky_color.data() );
|
||||
|
||||
// set cloud and fog color
|
||||
_cloud_color[0] = _fog_color[0] = base_fog_color[0] * sky_brightness;
|
||||
_cloud_color[1] = _fog_color[1] = base_fog_color[1] * sky_brightness;
|
||||
_cloud_color[2] = _fog_color[2] = base_fog_color[2] * sky_brightness;
|
||||
_cloud_color[3] = _fog_color[3] = base_fog_color[3];
|
||||
gamma_correct_rgb( _fog_color );
|
||||
gamma_correct_rgb( _fog_color.data() );
|
||||
|
||||
// adjust the cloud colors for sunrise/sunset effects (darken them)
|
||||
if (_sun_angle > 1.0) {
|
||||
|
@ -227,7 +246,7 @@ void FGLight::update_sky_color () {
|
|||
_cloud_color[1] /= sun2;
|
||||
_cloud_color[2] /= sun2;
|
||||
}
|
||||
gamma_correct_rgb( _cloud_color );
|
||||
gamma_correct_rgb( _cloud_color.data() );
|
||||
|
||||
SGVec4f sun_color = thesky->get_sun_color();
|
||||
|
||||
|
@ -293,7 +312,7 @@ void FGLight::update_adj_fog_color () {
|
|||
//
|
||||
SGVec4f sun_color = thesky->get_sun_color();
|
||||
|
||||
gamma_restore_rgb( _fog_color );
|
||||
gamma_restore_rgb( _fog_color.data() );
|
||||
|
||||
// Calculate the fog color in the direction of the sun for
|
||||
// sunrise/sunset effects.
|
||||
|
@ -323,11 +342,11 @@ void FGLight::update_adj_fog_color () {
|
|||
_adj_fog_color[0] = rf3 * _fog_color[0] + rf2 * s_red;
|
||||
_adj_fog_color[1] = rf3 * _fog_color[1] + rf2 * s_green;
|
||||
_adj_fog_color[2] = rf3 * _fog_color[2] + rf2 * s_blue;
|
||||
gamma_correct_rgb( _adj_fog_color );
|
||||
gamma_correct_rgb( _adj_fog_color.data() );
|
||||
|
||||
// make sure the colors have their original value before they are being
|
||||
// used by the rest of the program.
|
||||
//
|
||||
gamma_correct_rgb( _fog_color );
|
||||
gamma_correct_rgb( _fog_color.data() );
|
||||
}
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ private:
|
|||
SGVec3d _sunpos, _moonpos;
|
||||
|
||||
// (in view coordinates)
|
||||
sgVec4 _sun_vec, _moon_vec;
|
||||
SGVec4f _sun_vec, _moon_vec;
|
||||
|
||||
// inverse (in view coordinates)
|
||||
sgVec4 _sun_vec_inv, _moon_vec_inv;
|
||||
SGVec4f _sun_vec_inv, _moon_vec_inv;
|
||||
|
||||
// the angle between the celestial object and the local horizontal
|
||||
// (in radians)
|
||||
|
@ -94,18 +94,18 @@ private:
|
|||
*/
|
||||
|
||||
// ambient, diffuse and specular component
|
||||
GLfloat _scene_ambient[4];
|
||||
GLfloat _scene_diffuse[4];
|
||||
GLfloat _scene_specular[4];
|
||||
SGVec4f _scene_ambient;
|
||||
SGVec4f _scene_diffuse;
|
||||
SGVec4f _scene_specular;
|
||||
|
||||
// clear sky, fog and cloud color
|
||||
GLfloat _sky_color[4];
|
||||
GLfloat _fog_color[4];
|
||||
GLfloat _cloud_color[4];
|
||||
SGVec4f _sky_color;
|
||||
SGVec4f _fog_color;
|
||||
SGVec4f _cloud_color;
|
||||
|
||||
// clear sky and fog color adjusted for sunset effects
|
||||
GLfloat _adj_fog_color[4];
|
||||
GLfloat _adj_sky_color[4];
|
||||
SGVec4f _adj_fog_color;
|
||||
SGVec4f _adj_sky_color;
|
||||
|
||||
double _dt_total;
|
||||
|
||||
|
@ -126,13 +126,13 @@ public:
|
|||
|
||||
// Color related functions
|
||||
|
||||
inline float *scene_ambient () const { return (float *)_scene_ambient; }
|
||||
inline float *scene_diffuse () const { return (float *)_scene_diffuse; }
|
||||
inline float *scene_specular () const { return (float *)_scene_specular; }
|
||||
inline const SGVec4f& scene_ambient () const { return _scene_ambient; }
|
||||
inline const SGVec4f& scene_diffuse () const { return _scene_diffuse; }
|
||||
inline const SGVec4f& scene_specular () const { return _scene_specular; }
|
||||
|
||||
inline float *sky_color () const { return (float *)_sky_color; }
|
||||
inline float *cloud_color () const { return (float *)_cloud_color; }
|
||||
inline float *adj_fog_color () const { return (float *)_adj_fog_color; }
|
||||
inline const SGVec4f& sky_color () const { return _sky_color; }
|
||||
inline const SGVec4f& cloud_color () const { return _cloud_color; }
|
||||
inline const SGVec4f& adj_fog_color () const { return _adj_fog_color; }
|
||||
|
||||
|
||||
// Sun related functions
|
||||
|
@ -152,8 +152,8 @@ public:
|
|||
inline const SGVec3d& get_sunpos () const { return _sunpos; }
|
||||
inline void set_sunpos (const SGVec3d& p) { _sunpos = p; }
|
||||
|
||||
inline float *sun_vec () const { return (float *)_sun_vec; }
|
||||
inline float *sun_vec_inv () const { return (float *)_sun_vec_inv; }
|
||||
inline SGVec4f& sun_vec () { return _sun_vec; }
|
||||
inline SGVec4f& sun_vec_inv () { return _sun_vec_inv; }
|
||||
|
||||
|
||||
// Moon related functions
|
||||
|
@ -173,8 +173,8 @@ public:
|
|||
inline const SGVec3d& get_moonpos () const { return _moonpos; }
|
||||
inline void set_moonpos (const SGVec3d& p) { _moonpos = p; }
|
||||
|
||||
inline float *moon_vec () const { return (float *)_moon_vec; }
|
||||
inline float *moon_vec_inv () const { return (float *)_moon_vec_inv; }
|
||||
inline const SGVec4f& moon_vec () const { return _moon_vec; }
|
||||
inline const SGVec4f& moon_vec_inv () const { return _moon_vec_inv; }
|
||||
};
|
||||
|
||||
#endif // _LIGHT_HXX
|
||||
|
|
|
@ -103,11 +103,11 @@ void fgUpdateSunPos( void ) {
|
|||
<< " Geocentric lat = " << l->get_sun_gc_lat() );
|
||||
|
||||
// update the sun light vector
|
||||
sgSetVec4( l->sun_vec(), l->get_sunpos().x(),
|
||||
sgSetVec4( l->sun_vec().data(), l->get_sunpos().x(),
|
||||
l->get_sunpos().y(), l->get_sunpos().z(), 0.0 );
|
||||
sgNormalizeVec4( l->sun_vec() );
|
||||
sgCopyVec4( l->sun_vec_inv(), l->sun_vec() );
|
||||
sgNegateVec4( l->sun_vec_inv() );
|
||||
sgNormalizeVec4( l->sun_vec().data() );
|
||||
sgCopyVec4( l->sun_vec_inv().data(), l->sun_vec().data() );
|
||||
sgNegateVec4( l->sun_vec_inv().data() );
|
||||
|
||||
// make sure these are directional light sources only
|
||||
l->sun_vec()[3] = l->sun_vec_inv()[3] = 0.0;
|
||||
|
|
Loading…
Reference in a new issue