- // hard coded ground light state
- ssgSimpleState *gnd_lights = new ssgSimpleState;
- gnd_lights->ref();
- gnd_lights->disable( GL_TEXTURE_2D );
- gnd_lights->enable( GL_CULL_FACE );
- gnd_lights->enable( GL_COLOR_MATERIAL );
- gnd_lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
- gnd_lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
- gnd_lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
- gnd_lights->enable( GL_BLEND );
- gnd_lights->disable( GL_ALPHA_TEST );
- gnd_lights->disable( GL_LIGHTING );
- matlib["GROUND_LIGHTS"] = new SGMaterial( gnd_lights, true, true );
-
- GLuint tex_name;
-
- // hard coded runway white light state
- tex_name = gen_standard_dir_light_map( 235, 235, 195, 255 );
- ssgSimpleState *rwy_white_lights = new ssgSimpleState();
- rwy_white_lights->ref();
- rwy_white_lights->disable( GL_LIGHTING );
- rwy_white_lights->enable ( GL_CULL_FACE ) ;
- rwy_white_lights->enable( GL_TEXTURE_2D );
- rwy_white_lights->enable( GL_BLEND );
- rwy_white_lights->enable( GL_ALPHA_TEST );
- rwy_white_lights->enable( GL_COLOR_MATERIAL );
- rwy_white_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_lights->setTexture( tex_name );
- matlib["RWY_WHITE_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
- // For backwards compatibility ... remove someday
- matlib["RUNWAY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
- matlib["RWY_LIGHTS"] = new SGMaterial( rwy_white_lights, true, true );
- // end of backwards compatitibilty
-
- // hard coded runway medium intensity white light state
- tex_name = gen_standard_dir_light_map( 235, 235, 195, 205 );
- ssgSimpleState *rwy_white_medium_lights = new ssgSimpleState();
- rwy_white_medium_lights->ref();
- rwy_white_medium_lights->disable( GL_LIGHTING );
- rwy_white_medium_lights->enable ( GL_CULL_FACE ) ;
- rwy_white_medium_lights->enable( GL_TEXTURE_2D );
- rwy_white_medium_lights->enable( GL_BLEND );
- rwy_white_medium_lights->enable( GL_ALPHA_TEST );
- rwy_white_medium_lights->enable( GL_COLOR_MATERIAL );
- rwy_white_medium_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_medium_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_medium_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_medium_lights->setTexture( tex_name );
- matlib["RWY_WHITE_MEDIUM_LIGHTS"]
- = new SGMaterial( rwy_white_medium_lights, true, true );
-
- // hard coded runway low intensity white light state
- tex_name = gen_standard_dir_light_map( 235, 235, 195, 155 );
- ssgSimpleState *rwy_white_low_lights = new ssgSimpleState();
- rwy_white_low_lights->ref();
- rwy_white_low_lights->disable( GL_LIGHTING );
- rwy_white_low_lights->enable ( GL_CULL_FACE ) ;
- rwy_white_low_lights->enable( GL_TEXTURE_2D );
- rwy_white_low_lights->enable( GL_BLEND );
- rwy_white_low_lights->enable( GL_ALPHA_TEST );
- rwy_white_low_lights->enable( GL_COLOR_MATERIAL );
- rwy_white_low_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_low_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_white_low_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_white_low_lights->setTexture( tex_name );
- matlib["RWY_WHITE_LOW_LIGHTS"]
- = new SGMaterial( rwy_white_low_lights, true, true );
-
- // hard coded runway yellow light state
- tex_name = gen_standard_dir_light_map( 235, 215, 20, 255 );
- ssgSimpleState *rwy_yellow_lights = new ssgSimpleState();
- rwy_yellow_lights->ref();
- rwy_yellow_lights->disable( GL_LIGHTING );
- rwy_yellow_lights->enable ( GL_CULL_FACE ) ;
- rwy_yellow_lights->enable( GL_TEXTURE_2D );
- rwy_yellow_lights->enable( GL_BLEND );
- rwy_yellow_lights->enable( GL_ALPHA_TEST );
- rwy_yellow_lights->enable( GL_COLOR_MATERIAL );
- rwy_yellow_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_lights->setTexture( tex_name );
- matlib["RWY_YELLOW_LIGHTS"] = new SGMaterial( rwy_yellow_lights, true, true );
-
- // hard coded runway medium intensity yellow light state
- tex_name = gen_standard_dir_light_map( 235, 215, 20, 205 );
- ssgSimpleState *rwy_yellow_medium_lights = new ssgSimpleState();
- rwy_yellow_medium_lights->ref();
- rwy_yellow_medium_lights->disable( GL_LIGHTING );
- rwy_yellow_medium_lights->enable ( GL_CULL_FACE ) ;
- rwy_yellow_medium_lights->enable( GL_TEXTURE_2D );
- rwy_yellow_medium_lights->enable( GL_BLEND );
- rwy_yellow_medium_lights->enable( GL_ALPHA_TEST );
- rwy_yellow_medium_lights->enable( GL_COLOR_MATERIAL );
- rwy_yellow_medium_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_medium_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_medium_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_medium_lights->setTexture( tex_name );
- matlib["RWY_YELLOW_MEDIUM_LIGHTS"]
- = new SGMaterial( rwy_yellow_medium_lights, true, true );
-
- // hard coded runway low intensity yellow light state
- tex_name = gen_standard_dir_light_map( 235, 215, 20, 155 );
- ssgSimpleState *rwy_yellow_low_lights = new ssgSimpleState();
- rwy_yellow_low_lights->ref();
- rwy_yellow_low_lights->disable( GL_LIGHTING );
- rwy_yellow_low_lights->enable ( GL_CULL_FACE ) ;
- rwy_yellow_low_lights->enable( GL_TEXTURE_2D );
- rwy_yellow_low_lights->enable( GL_BLEND );
- rwy_yellow_low_lights->enable( GL_ALPHA_TEST );
- rwy_yellow_low_lights->enable( GL_COLOR_MATERIAL );
- rwy_yellow_low_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_low_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_yellow_low_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_yellow_low_lights->setTexture( tex_name );
- matlib["RWY_YELLOW_LOW_LIGHTS"]
- = new SGMaterial( rwy_yellow_low_lights, true, true );
-
- // hard coded runway red light state
- tex_name = gen_standard_dir_light_map( 235, 90, 90, 255 );
- ssgSimpleState *rwy_red_lights = new ssgSimpleState();
- rwy_red_lights->ref();
- rwy_red_lights->disable( GL_LIGHTING );
- rwy_red_lights->enable ( GL_CULL_FACE ) ;
- rwy_red_lights->enable( GL_TEXTURE_2D );
- rwy_red_lights->enable( GL_BLEND );
- rwy_red_lights->enable( GL_ALPHA_TEST );
- rwy_red_lights->enable( GL_COLOR_MATERIAL );
- rwy_red_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_lights->setTexture( tex_name );
- matlib["RWY_RED_LIGHTS"]
- = new SGMaterial( rwy_red_lights, true, true );
-
- // hard coded medium intensity runway red light state
- tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
- ssgSimpleState *rwy_red_medium_lights = new ssgSimpleState();
- rwy_red_medium_lights->ref();
- rwy_red_medium_lights->disable( GL_LIGHTING );
- rwy_red_medium_lights->enable ( GL_CULL_FACE ) ;
- rwy_red_medium_lights->enable( GL_TEXTURE_2D );
- rwy_red_medium_lights->enable( GL_BLEND );
- rwy_red_medium_lights->enable( GL_ALPHA_TEST );
- rwy_red_medium_lights->enable( GL_COLOR_MATERIAL );
- rwy_red_medium_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_medium_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_medium_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_medium_lights->setTexture( tex_name );
- matlib["RWY_RED_MEDIUM_LIGHTS"]
- = new SGMaterial( rwy_red_medium_lights, true, true );
-
- // hard coded low intensity runway red light state
- tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
- ssgSimpleState *rwy_red_low_lights = new ssgSimpleState();
- rwy_red_low_lights->ref();
- rwy_red_low_lights->disable( GL_LIGHTING );
- rwy_red_low_lights->enable ( GL_CULL_FACE ) ;
- rwy_red_low_lights->enable( GL_TEXTURE_2D );
- rwy_red_low_lights->enable( GL_BLEND );
- rwy_red_low_lights->enable( GL_ALPHA_TEST );
- rwy_red_low_lights->enable( GL_COLOR_MATERIAL );
- rwy_red_low_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_low_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_red_low_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_red_low_lights->setTexture( tex_name );
- matlib["RWY_RED_LOW_LIGHTS"]
- = new SGMaterial( rwy_red_low_lights, true, true );
-
- // hard coded runway green light state
- tex_name = gen_standard_dir_light_map( 20, 235, 20, 255 );
- ssgSimpleState *rwy_green_lights = new ssgSimpleState();
- rwy_green_lights->ref();
- rwy_green_lights->disable( GL_LIGHTING );
- rwy_green_lights->enable ( GL_CULL_FACE ) ;
- rwy_green_lights->enable( GL_TEXTURE_2D );
- rwy_green_lights->enable( GL_BLEND );
- rwy_green_lights->enable( GL_ALPHA_TEST );
- rwy_green_lights->enable( GL_COLOR_MATERIAL );
- rwy_green_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_lights->setTexture( tex_name );
- matlib["RWY_GREEN_LIGHTS"]
- = new SGMaterial( rwy_green_lights, true, true );
-
- // hard coded medium intensity runway green light state
- tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
- ssgSimpleState *rwy_green_medium_lights = new ssgSimpleState();
- rwy_green_medium_lights->ref();
- rwy_green_medium_lights->disable( GL_LIGHTING );
- rwy_green_medium_lights->enable ( GL_CULL_FACE ) ;
- rwy_green_medium_lights->enable( GL_TEXTURE_2D );
- rwy_green_medium_lights->enable( GL_BLEND );
- rwy_green_medium_lights->enable( GL_ALPHA_TEST );
- rwy_green_medium_lights->enable( GL_COLOR_MATERIAL );
- rwy_green_medium_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_medium_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_medium_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_medium_lights->setTexture( tex_name );
- matlib["RWY_GREEN_MEDIUM_LIGHTS"]
- = new SGMaterial( rwy_green_medium_lights, true, true );
-
- // hard coded low intensity runway green light state
- tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
- ssgSimpleState *rwy_green_low_lights = new ssgSimpleState();
- rwy_green_low_lights->ref();
- rwy_green_low_lights->disable( GL_LIGHTING );
- rwy_green_low_lights->enable ( GL_CULL_FACE ) ;
- rwy_green_low_lights->enable( GL_TEXTURE_2D );
- rwy_green_low_lights->enable( GL_BLEND );
- rwy_green_low_lights->enable( GL_ALPHA_TEST );
- rwy_green_low_lights->enable( GL_COLOR_MATERIAL );
- rwy_green_low_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_low_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_green_low_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_green_low_lights->setTexture( tex_name );
- matlib["RWY_GREEN_LOW_LIGHTS"]
- = new SGMaterial( rwy_green_low_lights, true, true );
-
- // hard coded low intensity taxiway blue light state
- tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
- ssgSimpleState *taxiway_blue_low_lights = new ssgSimpleState();
- taxiway_blue_low_lights->ref();
- taxiway_blue_low_lights->disable( GL_LIGHTING );
- taxiway_blue_low_lights->enable ( GL_CULL_FACE ) ;
- taxiway_blue_low_lights->enable( GL_TEXTURE_2D );
- taxiway_blue_low_lights->enable( GL_BLEND );
- taxiway_blue_low_lights->enable( GL_ALPHA_TEST );
- taxiway_blue_low_lights->enable( GL_COLOR_MATERIAL );
- taxiway_blue_low_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- taxiway_blue_low_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- taxiway_blue_low_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- taxiway_blue_low_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- taxiway_blue_low_lights->setTexture( tex_name );
- matlib["RWY_BLUE_TAXIWAY_LIGHTS"]
- = new SGMaterial( taxiway_blue_low_lights, true, true );
-
- // hard coded runway vasi light state
- ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
- rwy_vasi_lights->ref();
- rwy_vasi_lights->disable( GL_LIGHTING );
- rwy_vasi_lights->enable ( GL_CULL_FACE ) ;
- rwy_vasi_lights->enable( GL_TEXTURE_2D );
- rwy_vasi_lights->enable( GL_BLEND );
- rwy_vasi_lights->enable( GL_ALPHA_TEST );
- rwy_vasi_lights->enable( GL_COLOR_MATERIAL );
- rwy_vasi_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
- rwy_vasi_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
- rwy_vasi_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
- rwy_vasi_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
- rwy_vasi_lights->setTexture( gen_vasi_light_map() );
- matlib["RWY_VASI_LIGHTS"] = new SGMaterial( rwy_vasi_lights, true, true );
-
- return true;
-}
-
-
-// Load a library of material properties
-bool SGMaterialLib::add_item ( const string &tex_path )
-{
- string material_name = tex_path;
- int pos = tex_path.rfind( "/" );
- material_name = material_name.substr( pos + 1 );
-
- return add_item( material_name, tex_path );
-}
-
-
-// Load a library of material properties
-bool SGMaterialLib::add_item ( const string &mat_name, const string &full_path )
-{
- int pos = full_path.rfind( "/" );
- string tex_name = full_path.substr( pos + 1 );
- string tex_path = full_path.substr( 0, pos );
-
- SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
- << mat_name << " (" << full_path << ")");
-
- material_lib.matlib[mat_name] = new SGMaterial( full_path, true, true );
-