Implement runway guard lights and tweak the hold short lights animation a bit
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user