From 25a99a241795d11a79e05dad50caaa359b7d71cf Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 16 Aug 2009 19:35:24 +0000 Subject: [PATCH] Expose the color of the sun (which is not the scene specular color anymore) --- src/Time/light.cxx | 27 +++++++++++++++++++++++++-- src/Time/light.hxx | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Time/light.cxx b/src/Time/light.cxx index 88a215f98..5050aad3c 100644 --- a/src/Time/light.cxx +++ b/src/Time/light.cxx @@ -71,6 +71,7 @@ FGLight::FGLight () _scene_ambient(0, 0, 0, 0), _scene_diffuse(0, 0, 0, 0), _scene_specular(0, 0, 0, 0), + _sun_color(1, 1, 1, 1), _sky_color(0, 0, 0, 0), _fog_color(0, 0, 0, 0), _cloud_color(0, 0, 0, 0), @@ -147,6 +148,15 @@ void FGLight::bind () { prop->tie("/rendering/scene/specular/red",SGRawValuePointer(&_scene_specular[0])); prop->tie("/rendering/scene/specular/green",SGRawValuePointer(&_scene_specular[1])); prop->tie("/rendering/scene/specular/blue",SGRawValuePointer(&_scene_specular[2])); + prop->tie("/rendering/dome/sun/red",SGRawValuePointer(&_sun_color[0])); + prop->tie("/rendering/dome/sun/green",SGRawValuePointer(&_sun_color[1])); + prop->tie("/rendering/dome/sun/blue",SGRawValuePointer(&_sun_color[2])); + prop->tie("/rendering/dome/sky/red",SGRawValuePointer(&_sky_color[0])); + prop->tie("/rendering/dome/sky/green",SGRawValuePointer(&_sky_color[1])); + prop->tie("/rendering/dome/sky/blue",SGRawValuePointer(&_sky_color[2])); + prop->tie("/rendering/dome/fog/red",SGRawValuePointer(&_fog_color[0])); + prop->tie("/rendering/dome/fog/green",SGRawValuePointer(&_fog_color[1])); + prop->tie("/rendering/dome/fog/blue",SGRawValuePointer(&_fog_color[1])); } void FGLight::unbind () { @@ -161,6 +171,12 @@ void FGLight::unbind () { prop->untie("/rendering/scene/specular/red"); prop->untie("/rendering/scene/specular/green"); prop->untie("/rendering/scene/specular/blue"); + prop->untie("/rendering/dome/sun/red"); + prop->untie("/rendering/dome/sun/green"); + prop->untie("/rendering/dome/sun/blue"); + prop->untie("/rendering/dome/skyred"); + prop->untie("/rendering/dome/sky/green"); + prop->untie("/rendering/dome/sky/blue"); } @@ -245,7 +261,7 @@ void FGLight::update_sky_color () { _scene_ambient[3] = 1.0; gamma_correct_rgb( _scene_ambient.data() ); - SGVec4f sun_color = thesky->get_sun_color(); + SGVec4f sun_color = thesky->get_scene_color(); float ndiff = (ambient + specular) / 2; float idiff = 1.0 - ndiff; _scene_diffuse[0] = (sun_color[0]*ndiff + _fog_color[0]*idiff) * diffuse; @@ -259,6 +275,13 @@ void FGLight::update_sky_color () { _scene_specular[2] = sun_color[2] * specular; _scene_specular[3] = 1.0; gamma_correct_rgb( _scene_specular.data() ); + + sun_color = thesky->get_sun_color(); + _sun_color[0] = sun_color[0]; + _sun_color[1] = sun_color[1]; + _sun_color[2] = sun_color[2]; + _sun_color[3] = sun_color[3]; + gamma_correct_rgb( _sun_color.data() ); } @@ -308,7 +331,7 @@ void FGLight::update_adj_fog_color () { // revert to unmodified values before usign them. // - SGVec4f sun_color = thesky->get_sun_color(); + SGVec4f sun_color = thesky->get_scene_color(); gamma_restore_rgb( _fog_color.data() ); gamma_restore_rgb( _sky_color.data() ); diff --git a/src/Time/light.hxx b/src/Time/light.hxx index ffffa5ab2..de84629b9 100644 --- a/src/Time/light.hxx +++ b/src/Time/light.hxx @@ -90,6 +90,7 @@ private: SGVec4f _scene_specular; // clear sky, fog and cloud color + SGVec4f _sun_color; SGVec4f _sky_color; SGVec4f _fog_color; SGVec4f _cloud_color;