1
0
Fork 0

Update edge lighting so last 2000' are yellow.

Impliment center line lighting.
This commit is contained in:
curt 2002-10-16 22:23:34 +00:00
parent c9584384d3
commit 5e9e89596a

View file

@ -147,11 +147,13 @@ static Point3D gen_runway_left_vector( const FGRunway& rwy_info, bool recip )
// generate runway edge lighting
// 60 meters spacing or the next number down that divides evenly.
static FGSuperPoly gen_runway_edge_lights( const FGRunway& rwy_info,
bool recip )
static superpoly_list gen_runway_edge_lights( const FGRunway& rwy_info,
const string& kind, bool recip )
{
point_list lights; lights.clear();
point_list normals; normals.clear();
point_list w_lights; w_lights.clear();
point_list y_lights; y_lights.clear();
point_list w_normals; w_normals.clear();
point_list y_normals; y_normals.clear();
int i;
double len = rwy_info.length * SG_FEET_TO_METER;
@ -172,40 +174,174 @@ static FGSuperPoly gen_runway_edge_lights( const FGRunway& rwy_info,
Point3D pt1, pt2;
if ( recip ) {
inc1 = (corner[0] - corner[3]) / divs;
inc2 = (corner[1] - corner[2]) / divs;
pt1 = corner[3];
pt2 = corner[2];
} else {
inc1 = (corner[3] - corner[0]) / divs;
inc2 = (corner[2] - corner[1]) / divs;
pt1 = corner[0];
pt2 = corner[1];
} else {
inc1 = (corner[0] - corner[3]) / divs;
inc2 = (corner[1] - corner[2]) / divs;
pt1 = corner[3];
pt2 = corner[2];
}
lights.push_back( pt1 );
normals.push_back( normal );
lights.push_back( pt2 );
normals.push_back( normal );
double dist = rwy_info.length;
double step = dist / divs;
w_lights.push_back( pt1 );
w_normals.push_back( normal );
w_lights.push_back( pt2 );
w_normals.push_back( normal );
dist -= step;
for ( i = 0; i < divs; ++i ) {
pt1 += inc1;
pt2 += inc2;
lights.push_back( pt1 );
normals.push_back( normal );
lights.push_back( pt2 );
normals.push_back( normal );
if ( dist > 2000.0 ) {
w_lights.push_back( pt1 );
w_normals.push_back( normal );
w_lights.push_back( pt2 );
w_normals.push_back( normal );
} else {
y_lights.push_back( pt1 );
y_normals.push_back( normal );
y_lights.push_back( pt2 );
y_normals.push_back( normal );
}
dist -= step;
}
FGPolygon lights_poly; lights_poly.erase();
FGPolygon normals_poly; normals_poly.erase();
lights_poly.add_contour( lights, false );
normals_poly.add_contour( normals, false );
lights_poly.add_contour( w_lights, false );
normals_poly.add_contour( w_normals, false );
FGSuperPoly result;
result.set_poly( lights_poly );
result.set_normals( normals_poly );
result.set_material( "RWY_WHITE_LIGHTS" );
FGSuperPoly white;
white.set_poly( lights_poly );
white.set_normals( normals_poly );
if ( kind == "H" ) {
white.set_material( "RWY_WHITE_LIGHTS" );
} else if ( kind == "M" ) {
white.set_material( "RWY_WHITE_MEDIUM_LIGHTS" );
} else if ( kind == "L" ) {
white.set_material( "RWY_WHITE_LOW_LIGHTS" );
}
lights_poly.erase();
normals_poly.erase();
lights_poly.add_contour( y_lights, false );
normals_poly.add_contour( y_normals, false );
FGSuperPoly yellow;
yellow.set_poly( lights_poly );
yellow.set_normals( normals_poly );
if ( kind == "H" ) {
yellow.set_material( "RWY_YELLOW_LIGHTS" );
} else if ( kind == "M" ) {
yellow.set_material( "RWY_YELLOW_MEDIUM_LIGHTS" );
} else if ( kind == "L" ) {
yellow.set_material( "RWY_YELLOW_LOW_LIGHTS" );
}
superpoly_list result; result.clear();
result.push_back( white );
result.push_back( yellow );
return result;
}
// generate runway center line lighting, 50' spacing.
static superpoly_list gen_runway_center_line_lights( const FGRunway& rwy_info,
bool recip )
{
point_list w_lights; w_lights.clear();
point_list r_lights; r_lights.clear();
point_list w_normals; w_normals.clear();
point_list r_normals; r_normals.clear();
int i;
double len = rwy_info.length;
// this should be 25' technically but I'm trying 50' to space things out
int divs = (int)(len / (50.0*SG_FEET_TO_METER)) + 1;
Point3D normal = gen_runway_light_vector( rwy_info, 3.0, recip );
// using FGPolygon is a bit innefficient, but that's what the
// routine returns.
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
point_list corner;
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
corner.push_back( poly_corners.get_pt( 0, i ) );
}
Point3D inc;
Point3D pt1, pt2;
if ( recip ) {
pt1 = (corner[0] + corner[1] ) / 2.0;
pt2 = (corner[2] + corner[3] ) / 2.0;
} else {
pt1 = (corner[2] + corner[3] ) / 2.0;
pt2 = (corner[0] + corner[1] ) / 2.0;
}
inc = (pt2 - pt1) / divs;
double dist = len;
double step = len / divs;
pt1 += inc; // move 25' in
dist -= step;
bool use_white = true;
while ( dist > 0.0 ) {
if ( dist > 3000.0 ) {
w_lights.push_back( pt1 );
w_normals.push_back( normal );
} else if ( dist > 1000.0 ) {
if ( use_white ) {
w_lights.push_back( pt1 );
w_normals.push_back( normal );
} else {
r_lights.push_back( pt1 );
r_normals.push_back( normal );
}
use_white = !use_white;
} else {
r_lights.push_back( pt1 );
r_normals.push_back( normal );
}
pt1 += inc;
pt1 += inc;
dist -= step;
dist -= step;
}
FGPolygon lights_poly; lights_poly.erase();
FGPolygon normals_poly; normals_poly.erase();
lights_poly.add_contour( w_lights, false );
normals_poly.add_contour( w_normals, false );
FGSuperPoly white;
white.set_poly( lights_poly );
white.set_normals( normals_poly );
white.set_material( "RWY_WHITE_LIGHTS" );
lights_poly.erase();
normals_poly.erase();
lights_poly.add_contour( r_lights, false );
normals_poly.add_contour( r_normals, false );
FGSuperPoly red;
red.set_poly( lights_poly );
red.set_normals( normals_poly );
red.set_material( "RWY_RED_LIGHTS" );
superpoly_list result; result.clear();
result.push_back( white );
result.push_back( red );
return result;
}
@ -441,7 +577,10 @@ static FGSuperPoly gen_papi( const FGRunway& rwy_info, float alt_m,
void gen_runway_lights( const FGRunway& rwy_info, float alt_m,
superpoly_list &lights ) {
cout << "gen runway lights " << rwy_info.rwy_no << " " << rwy_info.end1_flags << " " << rwy_info.end2_flags << endl;;
cout << "gen runway lights " << rwy_info.rwy_no << " "
<< rwy_info.end1_flags << " " << rwy_info.end2_flags << endl;;
unsigned int i;
// PAPI lighting
if ( rwy_info.end1_flags.substr(2,1) == "P" ) {
@ -464,12 +603,35 @@ void gen_runway_lights( const FGRunway& rwy_info, float alt_m,
}
// Make edge lighting
{
FGSuperPoly s = gen_runway_edge_lights( rwy_info, false );
lights.push_back( s );
string edge_type = rwy_info.surface_flags.substr(3,1);
if ( edge_type != (string)"N" ) {
// forward direction
superpoly_list s;
s = gen_runway_edge_lights( rwy_info, edge_type, false );
for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] );
}
// reverse direction
s = gen_runway_edge_lights( rwy_info, edge_type, true );
for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] );
}
}
{
FGSuperPoly s = gen_runway_edge_lights( rwy_info, true );
lights.push_back( s );
// Centerline lighting
if ( rwy_info.surface_flags.substr(0,1) == "Y" ) {
// forward direction
superpoly_list s;
s = gen_runway_center_line_lights( rwy_info, false );
for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] );
}
// reverse direction
s = gen_runway_center_line_lights( rwy_info, true );
for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] );
}
}
}