3 #include <simgear/scene/util/RenderConstants.hxx>
4 #include "GroundLightManager.hxx"
12 StateSet* makeLightSS()
14 StateSet* ss = new StateSet;
16 fog->setMode(Fog::EXP2);
17 ss->setAttribute(fog);
18 ss->setDataVariance(Object::DYNAMIC);
25 GroundLightManager::GroundLightManager()
28 runwayLightSS = makeLightSS();
29 taxiLightSS = makeLightSS();
30 groundLightSS = makeLightSS();
33 GroundLightManager* GroundLightManager::instance()
35 static ref_ptr<GroundLightManager> manager = new GroundLightManager;
39 void GroundLightManager::update(const SGUpdateVisitor* updateVisitor)
42 SGVec4f fogColor = updateVisitor->getFogColor();
43 fog = static_cast<osg::Fog*>(runwayLightSS
44 ->getAttribute(StateAttribute::FOG));
45 fog->setColor(fogColor.osg());
46 fog->setDensity(updateVisitor->getRunwayFogExp2Density());
47 fog = static_cast<osg::Fog*>(taxiLightSS
48 ->getAttribute(StateAttribute::FOG));
49 fog->setColor(fogColor.osg());
50 fog->setDensity(updateVisitor->getTaxiFogExp2Density());
51 fog = static_cast<osg::Fog*>(groundLightSS
52 ->getAttribute(StateAttribute::FOG));
53 fog->setColor(fogColor.osg());
54 fog->setDensity(updateVisitor->getGroundLightsFogExp2Density());
57 unsigned GroundLightManager::getLightNodeMask(const SGUpdateVisitor* updateVisitor)
60 // The current sun angle in degree
61 float sun_angle = updateVisitor->getSunAngleDeg();
62 if (sun_angle > 85 || updateVisitor->getVisibility() < 5000)
63 mask |= RUNWAYLIGHTS_BIT;
66 mask |= GROUNDLIGHTS2_BIT;
68 mask |= GROUNDLIGHTS1_BIT;
70 mask |= GROUNDLIGHTS0_BIT;