]> git.mxchange.org Git - simgear.git/commitdiff
Implement runway guard lights and tweak the hold short lights animation a bit
authorChristian Schmitt <chris@ilovelinux.de>
Thu, 22 Nov 2012 15:42:56 +0000 (16:42 +0100)
committerChristian Schmitt <chris@ilovelinux.de>
Thu, 22 Nov 2012 15:42:56 +0000 (16:42 +0100)
simgear/scene/tgdb/obj.cxx
simgear/scene/tgdb/pt_lights.cxx
simgear/scene/tgdb/pt_lights.hxx

index e09ee3ff3896b3909e974ff2565feca9e5292af1..0361f74a21e4e0e3aa4083a3a08979f8cb02ac8a 100644 (file)
@@ -88,6 +88,7 @@ struct SGTileGeometryBin {
   SGDirectionalLightListBin rabitLights;
   SGLightListBin odalLights;
   SGDirectionalLightListBin holdshortLights;
+  SGDirectionalLightListBin guardLights;
   SGDirectionalLightListBin reilLights;
   SGMatModelBin randomModels;
   SGBuildingBinList randomBuildings;
@@ -172,6 +173,11 @@ struct SGTileGeometryBin {
         addPointGeometry(holdshortLights.back(), obj.get_wgs84_nodes(),
                          obj.get_normals(), color, obj.get_pts_v()[grp],
                          obj.get_pts_n()[grp]);
+      } else if (materialName == "RWY_GUARD_LIGHTS") {
+        guardLights.push_back(SGDirectionalLightBin());
+        addPointGeometry(guardLights.back(), obj.get_wgs84_nodes(),
+                         obj.get_normals(), color, obj.get_pts_v()[grp],
+                         obj.get_pts_n()[grp]);
       } else if (materialName == "RWY_REIL_LIGHTS") {
         reilLights.push_back(SGDirectionalLightBin());
         addPointGeometry(reilLights.back(), obj.get_wgs84_nodes(),
@@ -1091,7 +1097,8 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options
       || !tileGeometryBin.rabitLights.empty()
       || !tileGeometryBin.reilLights.empty()
       || !tileGeometryBin.odalLights.empty()
-      || !tileGeometryBin.holdshortLights.empty()) {
+      || !tileGeometryBin.holdshortLights.empty()
+      || !tileGeometryBin.guardLights.empty()) {
     osg::Group* rwyLights = new osg::Group;
     rwyLights->setStateSet(lightManager->getRunwayLightStateSet());
     rwyLights->setNodeMask(RUNWAYLIGHTS_BIT);
@@ -1115,6 +1122,10 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options
          i != tileGeometryBin.holdshortLights.end(); ++i) {
       rwyLights->addChild(SGLightFactory::getHoldShort(*i));
     }
+    for (i = tileGeometryBin.guardLights.begin();
+         i != tileGeometryBin.guardLights.end(); ++i) {
+      rwyLights->addChild(SGLightFactory::getGuard(*i));
+    }
     SGLightListBin::const_iterator j;
     for (j = tileGeometryBin.odalLights.begin();
          j != tileGeometryBin.odalLights.end(); ++j) {
index 47ce0ac8aef03e6e8833a119662d7283a2f1cba9..dc0c599a304cb8c47e0adf29742dc5a13f2c6c6e 100644 (file)
@@ -549,7 +549,7 @@ SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights)
     return 0;
 
   sg_srandom(unsigned(lights.getLight(0).position[0]));
-  float flashTime = 2 + 0.1 * sg_random();
+  float flashTime = 1 + 0.1 * sg_random();
   osg::Sequence* sequence = new osg::Sequence;
 
   // start with lights off
@@ -557,7 +557,7 @@ SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights)
   // ...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);
+                                      0.0f, i, true);
       EffectGeode* egeode = new EffectGeode;
       for (unsigned int j = 0; j < lights.getNumLights(); ++j) {
           egeode->addDrawable(getLightDrawable(lights.getLight(j)));
@@ -572,3 +572,30 @@ SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights)
 
   return sequence;
 }
+
+// Alternating runway guard lights ("wig-wag")
+osg::Node*
+SGLightFactory::getGuard(const SGDirectionalLightBin& lights)
+{
+  if (lights.getNumLights() < 2)
+    return 0;
+
+  // generate a repeatable random seed
+  sg_srandom(unsigned(lights.getLight(0).position[0]));
+  float flashTime = 1.0f + 1*sg_random();
+  osg::Sequence* sequence = new osg::Sequence;
+  sequence->setDefaultTime(flashTime);
+  Effect* effect = getLightEffect(10.0f, osg::Vec3(1.0, 0.001, 0.000002),
+                                  0.0f, 8.0f, true);
+  for (unsigned int i = 0; i < lights.getNumLights(); ++i) {
+    EffectGeode* egeode = new EffectGeode;
+    egeode->setEffect(effect);
+    egeode->addDrawable(getLightDrawable(lights.getLight(i)));
+    sequence->addChild(egeode, flashTime);
+  }
+  sequence->setInterval(osg::Sequence::LOOP, 0, -1);
+  sequence->setDuration(1.0f, -1);
+  sequence->setMode(osg::Sequence::START);
+  sequence->setSync(true);
+  return sequence;
+}
index af066f808cb75fead5e890f017a3f1517c1ea0bf..bbe28ad747dcf3d00072ced69dd6e52b8bb16f58 100644 (file)
@@ -92,6 +92,9 @@ public:
 
   static osg::Node*
   getHoldShort(const SGDirectionalLightBin& lights);
+
+  static osg::Node*
+  getGuard(const SGDirectionalLightBin& lights);
 };
 
 simgear::Effect* getLightEffect(float size, const osg::Vec3& attenuation,