]> git.mxchange.org Git - simgear.git/commitdiff
pt_lights: softly fade in and out the blinking lights
authorChristian Schmitt <chris@ilovelinux.de>
Fri, 14 Sep 2012 14:31:42 +0000 (16:31 +0200)
committerChristian Schmitt <chris@ilovelinux.de>
Fri, 14 Sep 2012 15:07:07 +0000 (17:07 +0200)
simgear/scene/tgdb/pt_lights.cxx

index c6dd87c65701a985dafc149154513f260edf796b..7e123a475da55583f31b65ba2dd59e28ae846fa8 100644 (file)
@@ -551,24 +551,24 @@ SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights)
   sg_srandom(unsigned(lights.getLight(0).position[0]));
   float flashTime = 2 + 0.1 * sg_random();
   osg::Sequence* sequence = new osg::Sequence;
-  sequence->setDefaultTime(flashTime);
-  Effect* effect = getLightEffect(6, osg::Vec3(1, 0.001, 0.000002),
-                                  0, 6, true);
-  // Lights on
-  EffectGeode* egeode = new EffectGeode;
-  for (int i = lights.getNumLights(); 0 <= i; --i) {
-    egeode->setEffect(effect);
-    egeode->addDrawable(getLightDrawable(lights.getLight(i)));
-  }
-  sequence->addChild(egeode, flashTime);
 
-  // Lights off
+  // start with lights off
   sequence->addChild(new osg::Group, flashTime);
+  // ...and increase the lights in steps
+  for (int i = 2; i < 7; i+=2) {
+      Effect* effect = getLightEffect(i, osg::Vec3(1, 0.001, 0.000002),
+                                      0, i, true);
+      EffectGeode* egeode = new EffectGeode;
+      for (unsigned int j = 0; j < lights.getNumLights(); ++j) {
+          egeode->addDrawable(getLightDrawable(lights.getLight(j)));
+          egeode->setEffect(effect);
+      }
+      sequence->addChild(egeode, (i==6) ? flashTime : 0.1);
+  }
 
-  sequence->setInterval(osg::Sequence::LOOP, 0, -1);
+  sequence->setInterval(osg::Sequence::SWING, 0, -1);
   sequence->setDuration(1.0f, -1);
   sequence->setMode(osg::Sequence::START);
-  sequence->setSync(true);
 
   return sequence;
 }