]> git.mxchange.org Git - flightgear.git/commitdiff
Changes for animated effects
authorTim Moore <timoore@redhat.com>
Tue, 3 Nov 2009 11:41:00 +0000 (12:41 +0100)
committerTim Moore <timoore@redhat.com>
Sun, 20 Dec 2009 09:34:07 +0000 (10:34 +0100)
src/Main/main.cxx
src/Time/light.cxx
src/Time/light.hxx

index f4d7d4046a31592dad52e3d56102ab1177b78196..cbdc0ba60f1ece4c3d3cae8a07e1ee5e7ace94da 100644 (file)
@@ -47,6 +47,7 @@
 #include <simgear/scene/model/animation.hxx>
 #include <simgear/scene/sky/sky.hxx>
 #include <simgear/structure/event_mgr.hxx>
+#include <simgear/props/AtomicChangeListener.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/timing/sg_time.hxx>
 #include <simgear/math/sg_random.h>
@@ -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, "" );
index ba835932f29918430c89721fa52113728c06c1de..cb5469a7fc5d66311df35a44aa5fb64f43dad356 100644 (file)
@@ -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<float>(&_fog_color[0]));
     prop->tie("/rendering/dome/fog/green",SGRawValuePointer<float>(&_fog_color[1]));
     prop->tie("/rendering/dome/fog/blue",SGRawValuePointer<float>(&_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<double>(_scene_chrome[i]));
+    }
+
     color = thesky->get_sun_color();
     _scene_specular[0] = color[0] * specular;
     _scene_specular[1] = color[1] * specular;
index 6a7500c9a204d7e47224d0f1a06d04defb78e8c1..f3ecb32e16bf5f8f8c30c23ca2435ca6c36e38f3 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <simgear/compiler.h>
 
+#include <simgear/props/props.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/math/interpolater.hxx>
 
@@ -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; }