X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmaterial%2Fmatlib.cxx;h=5ce238b5355da1c6f0407c8102a34e777579547c;hb=21c64dd60fbecf31eb2ccbf99b8fcbfde8892d14;hp=d3e49c8293c82baf5a44f73c04197a5dadfeb19e;hpb=a2c8cfb84ddcf99a5e2ebb240e78621fd11ee273;p=simgear.git diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index d3e49c82..5ce238b5 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started May 1998. // -// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu +// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -33,11 +33,11 @@ # include #endif -#include GLUT_H - #include #include -#include +#include + +#include SG_GL_H #include #include STL_STRING @@ -174,57 +174,8 @@ static int gen_taxiway_dir_light_map( int r, int g, int b, int alpha ) { } -// generate the directional vasi light environment texture map -static int gen_vasi_light_map() { - const int env_tex_res = 256; - int half_res = env_tex_res / 2; - unsigned char env_map[env_tex_res][env_tex_res][4]; - GLuint tex_name; - - for ( int i = 0; i < env_tex_res; ++i ) { - for ( int j = 0; j < env_tex_res; ++j ) { - double x = (i - half_res) / (double)half_res; - double y = (j - half_res) / (double)half_res; - double dist = sqrt(x*x + y*y); - if ( dist > 1.0 ) { dist = 1.0; } - double bright = cos( dist * SGD_PI_2 ); - - // top half white, bottom half red - env_map[i][j][0] = 255; - if ( i > half_res ) { - // white - env_map[i][j][1] = 255; - env_map[i][j][2] = 255; - } else if ( i == half_res - 1 || i == half_res ) { - // pink - env_map[i][j][1] = 127; - env_map[i][j][2] = 127; - } else { - // red - env_map[i][j][1] = 0; - env_map[i][j][2] = 0; - } - env_map[i][j][3] = (int)(bright * 255); - } - } - - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - glGenTextures( 1, &tex_name ); - glBindTexture( GL_TEXTURE_2D, tex_name ); - - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, env_tex_res, env_tex_res, 0, - GL_RGBA, GL_UNSIGNED_BYTE, env_map); - - return tex_name; -} - - // Load a library of material properties -bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { +bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char *season ) { SGPropertyNode materials; @@ -241,7 +192,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { for (int i = 0; i < nMaterials; i++) { const SGPropertyNode * node = materials.getChild(i); if (!strcmp(node->getName(), "material")) { - SGMaterial *m = new SGMaterial( fg_root, node ); + SGMaterial *m = new SGMaterial( fg_root, node, season ); vectornames = node->getChildren("name"); for ( unsigned int j = 0; j < names.size(); j++ ) { @@ -253,7 +204,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { << names[j]->getStringValue() ); } } else { - SG_LOG(SG_INPUT, SG_ALERT, + SG_LOG(SG_INPUT, SG_WARN, "Skipping bad material entry " << node->getName()); } } @@ -421,7 +372,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { = new SGMaterial( rwy_red_medium_lights ); // hard coded low intensity runway red light state - tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 ); + tex_name = gen_standard_dir_light_map( 235, 90, 90, 155 ); ssgSimpleState *rwy_red_low_lights = new ssgSimpleState(); rwy_red_low_lights->ref(); rwy_red_low_lights->disable( GL_LIGHTING ); @@ -475,7 +426,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { = new SGMaterial( rwy_green_medium_lights ); // hard coded low intensity runway green light state - tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 ); + tex_name = gen_standard_dir_light_map( 20, 235, 20, 155 ); ssgSimpleState *rwy_green_low_lights = new ssgSimpleState(); rwy_green_low_lights->ref(); rwy_green_low_lights->disable( GL_LIGHTING ); @@ -491,6 +442,8 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { rwy_green_low_lights->setTexture( tex_name ); matlib["RWY_GREEN_LOW_LIGHTS"] = new SGMaterial( rwy_green_low_lights ); + matlib["RWY_GREEN_TAXIWAY_LIGHTS"] + = new SGMaterial( rwy_green_low_lights ); // hard coded low intensity taxiway blue light state tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 ); @@ -511,6 +464,7 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { = new SGMaterial( taxiway_blue_low_lights ); // hard coded runway vasi light state + tex_name = gen_standard_dir_light_map( 235, 235, 195, 255 ); ssgSimpleState *rwy_vasi_lights = new ssgSimpleState(); rwy_vasi_lights->ref(); rwy_vasi_lights->disable( GL_LIGHTING ); @@ -523,7 +477,8 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath ) { 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() ); + // rwy_vasi_lights->setTexture( gen_vasi_light_map_old() ); + rwy_vasi_lights->setTexture( tex_name ); matlib["RWY_VASI_LIGHTS"] = new SGMaterial( rwy_vasi_lights ); return true;