From 9a94b266093e056aff3cca74f7e64b215322dada Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 3 Nov 2009 12:41:00 +0100 Subject: [PATCH] Changes for animated effects --- src/Main/main.cxx | 21 +++++++++++---------- src/Time/light.cxx | 18 ++++++++++++++++++ src/Time/light.hxx | 6 ++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index f4d7d4046..cbdc0ba60 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -164,7 +165,7 @@ void fgUpdateTimeDepCalcs() { // normal playback replay_time->setDoubleValue( replay_time->getDoubleValue() + ( delta_time_sec - * fgGetInt("/sim/speed-up") ) ); + * fgGetInt("/sim/speed-up") ) ); } else if ( replay_state->getIntValue() == 2 ) { // paused playback (don't advance replay time) } @@ -341,14 +342,14 @@ static void fgMainLoop( void ) { // probably move eventually /* printf("Before - ground = %.2f runway = %.2f alt = %.2f\n", - scenery.get_cur_elev(), - cur_fdm_state->get_Runway_altitude() * SG_FEET_TO_METER, - cur_fdm_state->get_Altitude() * SG_FEET_TO_METER); */ + scenery.get_cur_elev(), + cur_fdm_state->get_Runway_altitude() * SG_FEET_TO_METER, + cur_fdm_state->get_Altitude() * SG_FEET_TO_METER); */ /* printf("Adjustment - ground = %.2f runway = %.2f alt = %.2f\n", - scenery.get_cur_elev(), - cur_fdm_state->get_Runway_altitude() * SG_FEET_TO_METER, - cur_fdm_state->get_Altitude() * SG_FEET_TO_METER); */ + scenery.get_cur_elev(), + cur_fdm_state->get_Runway_altitude() * SG_FEET_TO_METER, + cur_fdm_state->get_Altitude() * SG_FEET_TO_METER); */ // cout << "Warp = " << globals->get_warp() << endl; @@ -420,7 +421,7 @@ static void fgMainLoop( void ) { general.set_frame_rate( frames ); fgSetInt("/sim/frame-rate", frames); SG_LOG( SG_ALL, SG_DEBUG, - "--> Frame rate is = " << general.get_frame_rate() ); + "--> Frame rate is = " << general.get_frame_rate() ); frames = 0; } last_time = t->get_cur_time(); @@ -449,7 +450,7 @@ static void fgMainLoop( void ) { fgUpdateTimeDepCalcs(); } else { SG_LOG( SG_ALL, SG_DEBUG, - "Elapsed time is zero ... we're zinging" ); + "Elapsed time is zero ... we're zinging" ); } globals->get_subsystem_mgr()->update(delta_time_sec); @@ -491,7 +492,7 @@ static void fgMainLoop( void ) { fgSetFloat("/sim/sound/volume", init_volume); globals->get_soundmgr()->set_volume(init_volume); } - + simgear::AtomicChangeListener::fireChangeListeners(); fgRequestRedraw(); SG_LOG( SG_ALL, SG_DEBUG, "" ); diff --git a/src/Time/light.cxx b/src/Time/light.cxx index ba835932f..cb5469a7f 100644 --- a/src/Time/light.cxx +++ b/src/Time/light.cxx @@ -69,6 +69,7 @@ FGLight::FGLight () _scene_ambient(0, 0, 0, 0), _scene_diffuse(0, 0, 0, 0), _scene_specular(0, 0, 0, 0), + _scene_chrome(0, 0, 0, 0), _sky_color(0, 0, 0, 0), _fog_color(0, 0, 0, 0), _cloud_color(0, 0, 0, 0), @@ -151,6 +152,15 @@ void FGLight::bind () { 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[2])); + // Properties used directly by effects + _chromeProps[0] = prop->getNode("/rendering/scene/chrome-light/red", true); + _chromeProps[1] = prop->getNode("/rendering/scene/chrome-light/green", + true); + _chromeProps[2] = prop->getNode("/rendering/scene/chrome-light/blue", true); + _chromeProps[3] = prop->getNode("/rendering/scene/chrome-light/alpha", + true); + for (int i = 0; i < 4; ++i) + _chromeProps[i]->setValue(0.0); } void FGLight::unbind () { @@ -265,6 +275,14 @@ void FGLight::update_sky_color () { _scene_diffuse[3] = 1.0; gamma_correct_rgb( _scene_diffuse.data() ); + SGVec4f chrome = _scene_ambient * .4f + _scene_diffuse; + chrome[3] = 1.0f; + if (chrome != _scene_chrome) { + _scene_chrome = chrome; + for (int i = 0; i < 4; ++i) + _chromeProps[i]->setValue(static_cast(_scene_chrome[i])); + } + color = thesky->get_sun_color(); _scene_specular[0] = color[0] * specular; _scene_specular[1] = color[1] * specular; diff --git a/src/Time/light.hxx b/src/Time/light.hxx index 6a7500c9a..f3ecb32e1 100644 --- a/src/Time/light.hxx +++ b/src/Time/light.hxx @@ -36,6 +36,7 @@ #include +#include #include #include @@ -85,6 +86,7 @@ private: SGVec4f _scene_ambient; SGVec4f _scene_diffuse; SGVec4f _scene_specular; + SGVec4f _scene_chrome; // clear sky, fog and cloud color SGVec4f _sky_color; @@ -100,6 +102,9 @@ private: void update_sky_color (); void update_adj_fog_color (); + // properties for chrome light; not a tie because I want to fire + // property listeners when the values change. + SGPropertyNode_ptr _chromeProps[4]; public: FGLight (); @@ -117,6 +122,7 @@ public: 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 const SGVec4f& scene_chrome () const { return _scene_chrome; } inline const SGVec4f& sky_color () const { return _sky_color; } inline const SGVec4f& cloud_color () const { return _cloud_color; }