1
0
Fork 0

Added support for taxiway lights that are much more visible from the size

than from above.
This commit is contained in:
curt 2002-10-22 03:57:32 +00:00
parent 86d586e592
commit 13813f9143
2 changed files with 86 additions and 9 deletions

View file

@ -143,6 +143,44 @@ static int gen_standard_dir_light_map( int r, int g, int b, int alpha ) {
}
// generate standard colored directional light environment texture map
static int gen_taxiway_dir_light_map( int r, int g, int b, int alpha ) {
const int env_tex_res = 32;
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 tmp = sqrt(x*x + y*y);
double dist = tmp * tmp;
if ( dist > 1.0 ) { dist = 1.0; }
double bright = sin( dist * SGD_PI_2 );
if ( bright < 0.2 ) { bright = 0.2; }
env_map[i][j][0] = r;
env_map[i][j][1] = g;
env_map[i][j][2] = b;
env_map[i][j][3] = (int)(bright * alpha);
}
}
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;
}
// generate the directional vasi light environment texture map
static int gen_vasi_light_map() {
const int env_tex_res = 256;
@ -451,6 +489,24 @@ bool FGMaterialLib::load( const string& mpath ) {
rwy_green_low_lights->setTexture( tex_name );
matlib["RWY_GREEN_LOW_LIGHTS"] = new FGNewMat(rwy_green_low_lights);
// hard coded medium intensity taxiway blue light state
tex_name = gen_taxiway_dir_light_map( 20, 20, 235, 205 );
ssgSimpleState *taxiway_blue_medium_lights = new ssgSimpleState();
taxiway_blue_medium_lights->ref();
taxiway_blue_medium_lights->disable( GL_LIGHTING );
taxiway_blue_medium_lights->enable ( GL_CULL_FACE ) ;
taxiway_blue_medium_lights->enable( GL_TEXTURE_2D );
taxiway_blue_medium_lights->enable( GL_BLEND );
taxiway_blue_medium_lights->enable( GL_ALPHA_TEST );
taxiway_blue_medium_lights->enable( GL_COLOR_MATERIAL );
taxiway_blue_medium_lights->setMaterial ( GL_AMBIENT, 1.0, 1.0, 1.0, 1.0 );
taxiway_blue_medium_lights->setMaterial ( GL_DIFFUSE, 1.0, 1.0, 1.0, 1.0 );
taxiway_blue_medium_lights->setMaterial ( GL_SPECULAR, 0.0, 0.0, 0.0, 0.0 );
taxiway_blue_medium_lights->setMaterial ( GL_EMISSION, 0.0, 0.0, 0.0, 0.0 );
taxiway_blue_medium_lights->setTexture( tex_name );
matlib["RWY_BLUE_TAXIWAY_LIGHTS"]
= new FGNewMat(taxiway_blue_medium_lights);
// hard coded runway vasi light state
ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
rwy_vasi_lights->ref();

View file

@ -164,14 +164,30 @@ ssgTransform *gen_dir_light_group( const point_list &nodes,
const int_list &pnt_i,
const int_list &nml_i,
const string &material,
sgVec3 up )
sgVec3 up, bool vertical = false )
{
sgVec3 center;
calc_center_point( nodes, pnt_i, center );
// cout << center[0] << "," << center[1] << "," << center[2] << endl;
sgVec3 nup;
sgNormalizeVec3( nup, up );
// find a vector perpendicular to the normal.
sgVec3 perp1;
if ( !vertical ) {
// normal isn't vertical so we can use up as our first vector
sgNormalizeVec3( perp1, up );
} else {
// normal is vertical so we have to work a bit harder to
// determine our first vector
sgVec3 pt1, pt2;
sgSetVec3( pt1, nodes[pnt_i[0]][0], nodes[pnt_i[0]][1],
nodes[pnt_i[0]][2] );
sgSetVec3( pt2, nodes[pnt_i[1]][0], nodes[pnt_i[1]][1],
nodes[pnt_i[1]][2] );
sgSubVec3( perp1, pt2, pt1 );
sgNormalizeVec3( perp1 );
}
ssgVertexArray *vl = new ssgVertexArray( 3 * pnt_i.size() );
ssgNormalArray *nl = new ssgNormalArray( 3 * pnt_i.size() );
@ -187,18 +203,18 @@ ssgTransform *gen_dir_light_group( const point_list &nodes,
normals[nml_i[i]][2] );
// calculate a vector perpendicular to dir and up
sgVec3 perp;
sgVectorProductVec3( perp, normal, nup );
sgVec3 perp2;
sgVectorProductVec3( perp2, normal, perp1 );
// front face
sgVec3 tmp3;
sgCopyVec3( tmp3, pt );
vl->add( tmp3 );
sgAddVec3( tmp3, nup );
sgAddVec3( tmp3, perp1 );
vl->add( tmp3 );
sgAddVec3( tmp3, perp );
sgAddVec3( tmp3, perp2 );
vl->add( tmp3 );
// sgSubVec3( tmp3, nup );
// sgSubVec3( tmp3, perp1 );
// vl->add( tmp3 );
nl->add( normal );
@ -420,7 +436,7 @@ ssgTransform *gen_rabbit_lights( const point_list &nodes,
}
rabbit->setDuration( 10 );
rabbit->setLimits( 0, pnt_i.size() + 1 );
rabbit->setLimits( 0, pnt_i.size() - 1 );
rabbit->setMode( SSG_ANIM_SHUTTLE );
rabbit->control( SSG_ANIM_START );
@ -491,6 +507,11 @@ ssgBranch *gen_directional_lights( const point_list &nodes,
pnt_i, nml_i,
material, up );
return rabbit;
} else if ( material == "RWY_BLUE_TAXIWAY_LIGHTS" ) {
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
nml_i, material, up,
true );
return light_group;
} else {
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
nml_i, material, up );