- osg::ref_ptr<osg::StateSet> lightStateSet = new osg::StateSet;
- {
- lightStateSet->setRenderBinDetails(9, "DepthSortedBin");
- lightStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
-// lightStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
-
- lightStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
-
- lightStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
- lightStateSet->setAttribute(new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.01));
- lightStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
-
- osg::CullFace* cullFace = new osg::CullFace;
- cullFace->setMode(osg::CullFace::BACK);
- lightStateSet->setAttributeAndModes(cullFace, osg::StateAttribute::ON);
-
- osg::BlendFunc* blendFunc = new osg::BlendFunc;
- blendFunc->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
- lightStateSet->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
-
- osg::PolygonMode* polygonMode = new osg::PolygonMode;
- polygonMode->setMode(osg::PolygonMode::FRONT, osg::PolygonMode::POINT);
- lightStateSet->setAttribute(polygonMode);
-
-// if (SGPointLightsUseSprites) {
- osg::PointSprite* pointSprite = new osg::PointSprite;
- lightStateSet->setTextureAttributeAndModes(0, pointSprite, osg::StateAttribute::ON);
-// }
-
-// if (SGPointLightsDistanceAttenuation) {
- osg::Point* point = new osg::Point;
- point->setMinSize(2);
- point->setSize(8);
- point->setDistanceAttenuation(osg::Vec3(1.0, 0.001, 0.000001));
- lightStateSet->setAttribute(point);
-// }
-
- osg::PolygonOffset* polygonOffset = new osg::PolygonOffset;
- polygonOffset->setFactor(-1);
- polygonOffset->setUnits(-1);
- lightStateSet->setAttributeAndModes(polygonOffset, osg::StateAttribute::ON);
-
- osg::TexGen* texGen = new osg::TexGen;
- texGen->setMode(osg::TexGen::SPHERE_MAP);
- lightStateSet->setTextureAttribute(0, texGen);
- lightStateSet->setTextureMode(0, GL_TEXTURE_GEN_S, osg::StateAttribute::ON);
- lightStateSet->setTextureMode(0, GL_TEXTURE_GEN_T, osg::StateAttribute::ON);
- osg::TexEnv* texEnv = new osg::TexEnv;
- texEnv->setMode(osg::TexEnv::MODULATE);
- lightStateSet->setTextureAttribute(0, texEnv);
-
- osg::Material* material = new osg::Material;
- lightStateSet->setAttribute(material);
- }
-
-
- // hard coded ground light state
- osg::StateSet *gnd_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
-// if (SGPointLightsDistanceAttenuation) {
- osg::Point* point = new osg::Point;
- point->setMinSize(1);
- point->setSize(2);
- point->setMaxSize(4);
- point->setDistanceAttenuation(osg::Vec3(1.0, 0.01, 0.0001));
- while (gnd_lights->getAttribute(osg::StateAttribute::POINT)) {
- gnd_lights->removeAttribute(osg::StateAttribute::POINT);
- }
- gnd_lights->setAttribute(point);
-// }
- m = new SGMaterial( gnd_lights );
- m->add_name("GROUND_LIGHTS");
- matlib["GROUND_LIGHTS"] = m;
-
- // hard coded runway white light state
- osg::Texture2D* texture;
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite(235, 235, 195, 255);
- } else {
- texture = gen_standard_dir_light_map(235, 235, 195, 255);
- }
- osg::StateSet *rwy_white_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_white_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
-
- m = new SGMaterial( rwy_white_lights );
- m->add_name("RWY_WHITE_LIGHTS");
- matlib["RWY_WHITE_LIGHTS"] = m;
- // For backwards compatibility ... remove someday
- m->add_name("RUNWAY_LIGHTS");
- matlib["RUNWAY_LIGHTS"] = m;
- m->add_name("RWY_LIGHTS");
- matlib["RWY_LIGHTS"] = m;
- // end of backwards compatitibilty
-
- // hard coded runway medium intensity white light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 235, 195, 205 );
- } else {
- texture = gen_standard_dir_light_map( 235, 235, 195, 205 );
- }
- osg::StateSet *rwy_white_medium_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_white_medium_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
-
- m = new SGMaterial( rwy_white_medium_lights );
- m->add_name("RWY_WHITE_MEDIUM_LIGHTS");
- matlib["RWY_WHITE_MEDIUM_LIGHTS"] = m;
-
- // hard coded runway low intensity white light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 235, 195, 155 );
- } else {
- texture = gen_standard_dir_light_map( 235, 235, 195, 155 );
- }
- osg::StateSet *rwy_white_low_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_white_medium_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_white_low_lights );
- m->add_name("RWY_WHITE_LOW_LIGHTS");
- matlib["RWY_WHITE_LOW_LIGHTS"] = m;
-
- // hard coded runway yellow light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 215, 20, 255 );
- } else {
- texture = gen_standard_dir_light_map( 235, 215, 20, 255 );
- }
- osg::StateSet *rwy_yellow_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_yellow_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_yellow_lights );
- m->add_name("RWY_YELLOW_LIGHTS");
- matlib["RWY_YELLOW_LIGHTS"] = m;
-
- // hard coded runway medium intensity yellow light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 215, 20, 205 );
- } else {
- texture = gen_standard_dir_light_map( 235, 215, 20, 205 );
- }
- osg::StateSet *rwy_yellow_medium_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_yellow_medium_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_yellow_medium_lights );
- m->add_name("RWY_YELLOW_MEDIUM_LIGHTS");
- matlib["RWY_YELLOW_MEDIUM_LIGHTS"] = m;
-
- // hard coded runway low intensity yellow light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 215, 20, 155 );
- } else {
- texture = gen_standard_dir_light_map( 235, 215, 20, 155 );
- }
- osg::StateSet *rwy_yellow_low_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_yellow_low_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_yellow_low_lights );
- m->add_name("RWY_YELLOW_LOW_LIGHTS");
- matlib["RWY_YELLOW_LOW_LIGHTS"] = m;
-
- // hard coded runway red light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 90, 90, 255 );
- } else {
- texture = gen_standard_dir_light_map( 235, 90, 90, 255 );
- }
- osg::StateSet *rwy_red_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_red_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_red_lights );
- m->add_name("RWY_RED_LIGHTS");
- matlib["RWY_RED_LIGHTS"] = m;
-
- // hard coded medium intensity runway red light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 90, 90, 205 );
- } else {
- texture = gen_standard_dir_light_map( 235, 90, 90, 205 );
- }
- osg::StateSet *rwy_red_medium_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_red_medium_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_red_medium_lights );
- m->add_name("RWY_RED_MEDIUM_LIGHTS");
- matlib["RWY_RED_MEDIUM_LIGHTS"] = m;
-
- // hard coded low intensity runway red light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 90, 90, 155 );
- } else {
- texture = gen_standard_dir_light_map( 235, 90, 90, 155 );
- }
- osg::StateSet *rwy_red_low_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_red_low_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_red_low_lights );
- m->add_name("RWY_RED_LOW_LIGHTS");
- matlib["RWY_RED_LOW_LIGHTS"] = m;
-
- // hard coded runway green light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 20, 235, 20, 255 );
- } else {
- texture = gen_standard_dir_light_map( 20, 235, 20, 255 );
- }
- osg::StateSet *rwy_green_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_green_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_green_lights );
- m->add_name("RWY_GREEN_LIGHTS");
- matlib["RWY_GREEN_LIGHTS"] = m;
-
- // hard coded medium intensity runway green light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 20, 235, 20, 205 );
- } else {
- texture = gen_standard_dir_light_map( 20, 235, 20, 205 );
- }
- osg::StateSet *rwy_green_medium_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_green_medium_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_green_medium_lights );
- m->add_name("RWY_GREEN_MEDIUM_LIGHTS");
- matlib["RWY_GREEN_MEDIUM_LIGHTS"] = m;
-
- // hard coded low intensity runway green light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 20, 235, 20, 155 );
- } else {
- texture = gen_standard_dir_light_map( 20, 235, 20, 155 );
- }
- osg::StateSet *rwy_green_low_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- rwy_green_low_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_green_low_lights );
- m->add_name("RWY_GREEN_LOW_LIGHTS");
- matlib["RWY_GREEN_LOW_LIGHTS"] = m;
- m->add_name("RWY_GREEN_TAXIWAY_LIGHTS");
- matlib["RWY_GREEN_TAXIWAY_LIGHTS"] = m;
-
- // hard coded low intensity taxiway blue light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 90, 90, 235, 205 );
- } else {
- texture = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
- }
- osg::StateSet *taxiway_blue_low_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
- taxiway_blue_low_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( taxiway_blue_low_lights );
- m->add_name("RWY_BLUE_TAXIWAY_LIGHTS");
- matlib["RWY_BLUE_TAXIWAY_LIGHTS"] = m;
-
- // hard coded runway vasi light state
- if ( sprite_lighting ) {
- texture = gen_standard_light_sprite( 235, 235, 195, 255 );
- } else {
- texture = gen_standard_dir_light_map( 235, 235, 195, 255 );
- }
- osg::StateSet *rwy_vasi_lights = static_cast<osg::StateSet*>(lightStateSet->clone(osg::CopyOp::DEEP_COPY_ALL));
-// if (SGPointLightsDistanceAttenuation) {
- point = new osg::Point;
- point->setMinSize(4);
- point->setSize(10);
- point->setDistanceAttenuation(osg::Vec3(1.0, 0.01, 0.0001));
- while (rwy_vasi_lights->getAttribute(osg::StateAttribute::POINT)) {
- rwy_vasi_lights->removeAttribute(osg::StateAttribute::POINT);
- }
- rwy_vasi_lights->setAttribute(point);
-// }
- rwy_vasi_lights->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
- m = new SGMaterial( rwy_vasi_lights );
- m->add_name("RWY_VASI_LIGHTS");
- matlib["RWY_VASI_LIGHTS"] = m;
-