From f712bc92941a1edbb24be103a8e8cfdcab3e0b68 Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Fri, 30 Mar 2012 19:17:59 +0200 Subject: [PATCH] Implement blinking hold-short line lights This is supported by the apt.dat 850 format and latest TG --- simgear/scene/tgdb/obj.cxx | 13 ++++++++++++- simgear/scene/tgdb/pt_lights.cxx | 31 +++++++++++++++++++++++++++++++ simgear/scene/tgdb/pt_lights.hxx | 3 +++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/simgear/scene/tgdb/obj.cxx b/simgear/scene/tgdb/obj.cxx index 29b78fba..3cef61ba 100644 --- a/simgear/scene/tgdb/obj.cxx +++ b/simgear/scene/tgdb/obj.cxx @@ -85,6 +85,7 @@ struct SGTileGeometryBin { SGDirectionalLightListBin vasiLights; SGDirectionalLightListBin rabitLights; SGLightListBin odalLights; + SGDirectionalLightListBin holdshortLights; SGDirectionalLightListBin reilLights; SGMatModelBin randomModels; SGBuildingBinList randomBuildings; @@ -164,6 +165,11 @@ struct SGTileGeometryBin { odalLights.push_back(SGLightBin()); addPointGeometry(odalLights.back(), obj.get_wgs84_nodes(), color, obj.get_pts_v()[grp]); + } else if (materialName == "RWY_YELLOW_PULSE_LIGHTS") { + holdshortLights.push_back(SGDirectionalLightBin()); + 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_REIL_LIGHTS") { reilLights.push_back(SGDirectionalLightBin()); addPointGeometry(reilLights.back(), obj.get_wgs84_nodes(), @@ -1044,7 +1050,8 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options if (tileGeometryBin.runwayLights.getNumLights() > 0 || !tileGeometryBin.rabitLights.empty() || !tileGeometryBin.reilLights.empty() - || !tileGeometryBin.odalLights.empty()) { + || !tileGeometryBin.odalLights.empty() + || !tileGeometryBin.holdshortLights.empty()) { osg::Group* rwyLights = new osg::Group; rwyLights->setStateSet(lightManager->getRunwayLightStateSet()); rwyLights->setNodeMask(RUNWAYLIGHTS_BIT); @@ -1064,6 +1071,10 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options i != tileGeometryBin.reilLights.end(); ++i) { rwyLights->addChild(SGLightFactory::getSequenced(*i)); } + for (i = tileGeometryBin.holdshortLights.begin(); + i != tileGeometryBin.holdshortLights.end(); ++i) { + rwyLights->addChild(SGLightFactory::getHoldShort(*i)); + } SGLightListBin::const_iterator j; for (j = tileGeometryBin.odalLights.begin(); j != tileGeometryBin.odalLights.end(); ++j) { diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index 2aa6606a..925d3e20 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -540,3 +540,34 @@ SGLightFactory::getOdal(const SGLightBin& lights) return sequence; } + +// Blinking hold short line lights +osg::Node* +SGLightFactory::getHoldShort(const SGDirectionalLightBin& lights) +{ + if (lights.getNumLights() < 2) + return 0; + + float flashTime = 2; + 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 + sequence->addChild(new osg::Group, flashTime); + + sequence->setInterval(osg::Sequence::LOOP, 0, -1); + sequence->setDuration(1.0f, -1); + sequence->setMode(osg::Sequence::START); + sequence->setSync(true); + + return sequence; +} diff --git a/simgear/scene/tgdb/pt_lights.hxx b/simgear/scene/tgdb/pt_lights.hxx index 6357c14c..af066f80 100644 --- a/simgear/scene/tgdb/pt_lights.hxx +++ b/simgear/scene/tgdb/pt_lights.hxx @@ -89,6 +89,9 @@ public: static osg::Node* getOdal(const SGLightBin& lights); + + static osg::Node* + getHoldShort(const SGDirectionalLightBin& lights); }; simgear::Effect* getLightEffect(float size, const osg::Vec3& attenuation, -- 2.39.5