Added necessary infrastructure to manage runway light generation.
This commit is contained in:
parent
4fb0ca1e2b
commit
69c741fd64
3 changed files with 116 additions and 76 deletions
|
@ -564,10 +564,9 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
}
|
||||
|
||||
// 5th pass: generate runway/taxiway lights
|
||||
point_list rwy_lights; rwy_lights.clear();
|
||||
point_list rwy_light_normals; rwy_light_normals.clear();
|
||||
superpoly_list rwy_lights; rwy_lights.clear();
|
||||
for ( i = 0; i < (int)runways.size(); ++i ) {
|
||||
gen_runway_lights( runways[i], alt_m, &rwy_lights, &rwy_light_normals );
|
||||
gen_runway_lights( runways[i], alt_m, rwy_lights );
|
||||
}
|
||||
|
||||
// generate convex hull (no longer)
|
||||
|
@ -956,37 +955,42 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
}
|
||||
|
||||
// add light points
|
||||
FGTriNodes light_nodes;
|
||||
light_nodes.clear();
|
||||
for ( i = 0; i < (int)rwy_lights.size(); ++i ) {
|
||||
p = rwy_lights[i];
|
||||
index = light_nodes.simple_add( p );
|
||||
FGTriNodes light_nodes;
|
||||
light_nodes.clear();
|
||||
point_list lights_v = rwy_lights[i].get_poly().get_contour(0);
|
||||
for ( j = 0; j < (int)lights_v.size(); ++j ) {
|
||||
p = lights_v[j];
|
||||
index = light_nodes.simple_add( p );
|
||||
}
|
||||
|
||||
// calculate light node elevations
|
||||
point_list geod_light_nodes
|
||||
= calc_elevations( root, light_nodes.get_node_list(), 0.5 );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with (light) calc_elevations()");
|
||||
|
||||
// this is a little round about, but what we want to calculate the
|
||||
// light node elevations as ground + an offset so we do them
|
||||
// seperately, then we add them back into nodes to get the index
|
||||
// out, but also add them to geod_nodes to maintain consistancy
|
||||
// between these two lists.
|
||||
point_list light_normals = rwy_lights[i].get_normals().get_contour(0);
|
||||
pt_v.clear();
|
||||
pt_n.clear();
|
||||
for ( j = 0; j < (int)geod_light_nodes.size(); ++j ) {
|
||||
p = geod_light_nodes[j];
|
||||
index = nodes.simple_add( p );
|
||||
pt_v.push_back( index );
|
||||
geod_nodes.push_back( p );
|
||||
|
||||
index = normals.unique_add( light_normals[j] );
|
||||
pt_n.push_back( index );
|
||||
}
|
||||
pts_v.push_back( pt_v );
|
||||
pts_n.push_back( pt_n );
|
||||
pt_materials.push_back( rwy_lights[i].get_material() );
|
||||
}
|
||||
|
||||
// calculate light node elevations
|
||||
point_list geod_light_nodes
|
||||
= calc_elevations( root, light_nodes.get_node_list(), 0.5 );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with (light) calc_elevations()");
|
||||
|
||||
// this is a little round about, but what we want to calculate the
|
||||
// light node elevations as ground + an offset so we do them
|
||||
// seperately, then we add them back into nodes to get the index
|
||||
// out, but also add them to geod_nodes to maintain consistancy
|
||||
// between these two lists.
|
||||
pt_v.clear();
|
||||
for ( i = 0; i < (int)geod_light_nodes.size(); ++i ) {
|
||||
p = geod_light_nodes[i];
|
||||
index = nodes.simple_add( p );
|
||||
pt_v.push_back( index );
|
||||
geod_nodes.push_back( p );
|
||||
|
||||
index = normals.unique_add( rwy_light_normals[i] );
|
||||
pt_n.push_back( index );
|
||||
}
|
||||
pts_v.push_back( pt_v );
|
||||
pts_n.push_back( pt_n );
|
||||
pt_materials.push_back( "RWY_LIGHTS" );
|
||||
|
||||
// calculate wgs84 mapping of nodes
|
||||
point_list wgs84_nodes;
|
||||
for ( i = 0; i < (int)geod_nodes.size(); ++i ) {
|
||||
|
|
|
@ -147,9 +147,11 @@ 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 void gen_runway_edge_lights( const FGRunway& rwy_info,
|
||||
point_list *lights, point_list *normals,
|
||||
bool recip ) {
|
||||
static FGSuperPoly gen_runway_edge_lights( const FGRunway& rwy_info,
|
||||
bool recip )
|
||||
{
|
||||
point_list lights; lights.clear();
|
||||
point_list normals; normals.clear();
|
||||
int i;
|
||||
|
||||
double len = rwy_info.length * SG_FEET_TO_METER;
|
||||
|
@ -181,26 +183,40 @@ static void gen_runway_edge_lights( const FGRunway& rwy_info,
|
|||
pt2 = corner[1];
|
||||
}
|
||||
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights->push_back( pt2 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
lights.push_back( pt2 );
|
||||
normals.push_back( normal );
|
||||
|
||||
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 );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
lights.push_back( pt2 );
|
||||
normals.push_back( normal );
|
||||
}
|
||||
|
||||
FGPolygon lights_poly; lights_poly.erase();
|
||||
FGPolygon normals_poly; normals_poly.erase();
|
||||
lights_poly.add_contour( lights, false );
|
||||
normals_poly.add_contour( normals, false );
|
||||
|
||||
FGSuperPoly result;
|
||||
result.set_poly( lights_poly );
|
||||
result.set_normals( normals_poly );
|
||||
result.set_material( "RWY_WHITE_LIGHTS" );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// generate a simple 2 bar VASI
|
||||
static void gen_vasi( const FGRunway& rwy_info, float alt_m,
|
||||
point_list *lights, point_list *normals,
|
||||
bool recip ) {
|
||||
static FGSuperPoly gen_vasi( const FGRunway& rwy_info, float alt_m,
|
||||
bool recip )
|
||||
{
|
||||
point_list lights; lights.clear();
|
||||
point_list normals; normals.clear();
|
||||
int i;
|
||||
|
||||
cout << "gen vasi " << rwy_info.rwy_no << endl;
|
||||
|
@ -220,7 +236,7 @@ static void gen_vasi( const FGRunway& rwy_info, float alt_m,
|
|||
Point3D ref;
|
||||
double length_hdg, left_hdg;
|
||||
double lon, lat, r;
|
||||
if ( recip ) {
|
||||
if ( recip ) {
|
||||
ref = corner[0];
|
||||
length_hdg = 360.0 - rwy_info.heading;
|
||||
} else {
|
||||
|
@ -244,37 +260,37 @@ static void gen_vasi( const FGRunway& rwy_info, float alt_m,
|
|||
|
||||
// unit1
|
||||
Point3D pt1 = ref;
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
// unit2
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
16 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
// unit3
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
16 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
// upwind bar
|
||||
normal = gen_runway_light_vector( rwy_info, 3.0, recip );
|
||||
|
@ -284,54 +300,74 @@ static void gen_vasi( const FGRunway& rwy_info, float alt_m,
|
|||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), length_hdg,
|
||||
700 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
// unit2
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
16 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
// unit3
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
16 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
geo_direct_wgs_84 ( alt_m, pt1.lat(), pt1.lon(), left_hdg,
|
||||
1 * SG_FEET_TO_METER, &lat, &lon, &r );
|
||||
pt1 = Point3D( lon, lat, 0.0 );
|
||||
lights->push_back( pt1 );
|
||||
normals->push_back( normal );
|
||||
lights.push_back( pt1 );
|
||||
normals.push_back( normal );
|
||||
|
||||
FGPolygon lights_poly; lights_poly.erase();
|
||||
FGPolygon normals_poly; normals_poly.erase();
|
||||
lights_poly.add_contour( lights, false );
|
||||
normals_poly.add_contour( normals, false );
|
||||
|
||||
FGSuperPoly result;
|
||||
result.set_poly( lights_poly );
|
||||
result.set_normals( normals_poly );
|
||||
result.set_material( "RWY_VASI_LIGHTS" );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void gen_runway_lights( const FGRunway& rwy_info, float alt_m,
|
||||
point_list *lights, point_list *normals ) {
|
||||
superpoly_list &lights ) {
|
||||
|
||||
cout << "gen runway lights " << rwy_info.rwy_no << " " << rwy_info.end1_flags << " " << rwy_info.end2_flags << endl;;
|
||||
|
||||
// Approach lighting
|
||||
if ( rwy_info.end1_flags.substr(2,1) == "V" ) {
|
||||
gen_vasi( rwy_info, alt_m, lights, normals, false );
|
||||
FGSuperPoly s = gen_vasi( rwy_info, alt_m, false );
|
||||
lights.push_back( s );
|
||||
}
|
||||
if ( rwy_info.end2_flags.substr(2,1) == "V" ) {
|
||||
gen_vasi( rwy_info, alt_m, lights, normals, true );
|
||||
FGSuperPoly s = gen_vasi( rwy_info, alt_m, true );
|
||||
lights.push_back( s );
|
||||
}
|
||||
|
||||
// Make edge lighting
|
||||
gen_runway_edge_lights( rwy_info, lights, normals, false );
|
||||
gen_runway_edge_lights( rwy_info, lights, normals, true );
|
||||
{
|
||||
FGSuperPoly s = gen_runway_edge_lights( rwy_info, false );
|
||||
lights.push_back( s );
|
||||
}
|
||||
{
|
||||
FGSuperPoly s = gen_runway_edge_lights( rwy_info, true );
|
||||
lights.push_back( s );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
// generate runway lighting
|
||||
void gen_runway_lights( const FGRunway& rwy_info, float alt_m,
|
||||
point_list *lights, point_list *normals );
|
||||
superpoly_list &lights );
|
||||
|
||||
|
||||
#endif // _RWY_LIGHTS_HXX
|
||||
|
|
Loading…
Add table
Reference in a new issue