diff --git a/src/Airports/GenAirports850/CMakeLists.txt b/src/Airports/GenAirports850/CMakeLists.txt index 6d5d250f..92d0766e 100644 --- a/src/Airports/GenAirports850/CMakeLists.txt +++ b/src/Airports/GenAirports850/CMakeLists.txt @@ -12,6 +12,9 @@ add_executable(genapts850 point2d.cxx point2d.hxx poly_extra.cxx poly_extra.hxx runway.cxx runway.hxx + rwy_simple.cxx + rwy_gen.cxx + rwy_common.cxx texparams.hxx ) diff --git a/src/Airports/GenAirports850/airport.cxx b/src/Airports/GenAirports850/airport.cxx index e26d45d5..a7b64556 100644 --- a/src/Airports/GenAirports850/airport.cxx +++ b/src/Airports/GenAirports850/airport.cxx @@ -624,7 +624,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) pvmt_polys[i].set_tris( tri ); pvmt_polys[i].set_texcoords( tc ); - pvmt_polys[i].set_tri_mode( GL_TRIANGLES ); } // tesselate the polygons and prepair them for final output @@ -642,7 +641,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src ) line_polys[i].set_tris( tri ); line_polys[i].set_texcoords( tc ); - line_polys[i].set_tri_mode( GL_TRIANGLES ); } SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating base"); diff --git a/src/Airports/GenAirports850/runway.cxx b/src/Airports/GenAirports850/runway.cxx index 82a7f642..546ecab1 100644 --- a/src/Airports/GenAirports850/runway.cxx +++ b/src/Airports/GenAirports850/runway.cxx @@ -232,7 +232,7 @@ void Runway::gen_simple_rwy( double alt_m, const string& material, superpoly_lis } #endif -void Runway::gen_simple_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ) +/*void gen_simple_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ) { int j, k; @@ -327,7 +327,7 @@ void Runway::gen_simple_rwy( double alt_m, const string& material, superpoly_lis material, rwy_polys, texparams, accum ); #endif -} +}*/ #if 0 void Runway::gen_marked_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ) @@ -377,11 +377,11 @@ int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* te if ( rwy.surface == 1 /* Asphalt */ ) { - material = "pa_tiedown"; + material = "pa_"; } else if ( rwy.surface == 2 /* Concrete */ ) { - material = "pc_tiedown"; + material = "pc_"; } else if ( rwy.surface == 3 /* Turf/Grass */ ) { @@ -411,7 +411,7 @@ int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* te case 1: // asphalt: case 2: // concrete SG_LOG( SG_GENERAL, SG_ALERT, "Build Runway: asphalt or concrete" << rwy.surface); - gen_simple_rwy( alt_m, material, rwy_polys, texparams, accum ); + gen_rwy( alt_m, material, rwy_polys, texparams, accum ); break; case 3: // Grass diff --git a/src/Airports/GenAirports850/runway.hxx b/src/Airports/GenAirports850/runway.hxx index 6592448a..39242501 100644 --- a/src/Airports/GenAirports850/runway.hxx +++ b/src/Airports/GenAirports850/runway.hxx @@ -76,13 +76,49 @@ private: // Build Helpers TGPolygon gen_wgs84_area( Point3D origin, double length_m, double displ1, double displ2, double width_m, double heading_deg, double alt_m, bool add_mid ); TGPolygon gen_runway_w_mid( double alt_m, double length_extend_m, double width_extend_m ); -// void gen_runway_section( const TGPolygon& runway, double startl_pct, double endl_pct, double startw_pct, double endw_pct, double minu, double maxu, double minv, double maxv, double heading, -// const string& prefix, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ); -// void gen_runway_stopway( const TGPolygon& runway_a, const TGPolygon& runway_b, const string& prefix, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon* accum ); TGPolygon gen_runway_area_w_extend( double alt_m, double length_extend, double displ1, double displ2, double width_extend ); - void gen_simple_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ); - void gen_marked_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ); + void gen_number_block( const std::string& material, + TGPolygon poly, double heading, int num, + double start_pct, double end_pct, + superpoly_list *rwy_polys, + texparams_list *texparams, + TGPolygon *accum ); + + // generate the runway overrun area + void gen_runway_overrun( const TGPolygon& runway_half, + int rwhalf, + const std::string& prefix, + superpoly_list *rwy_polys, + texparams_list *texparams, + TGPolygon* accum ); + + // generate a section of runway + void gen_runway_section( const TGPolygon& runway, + double startl_pct, double endl_pct, + double startw_pct, double endw_pct, + double minu, double maxu, double minv, double maxv, + double heading, + const std::string& prefix, + const std::string& material, + superpoly_list *rwy_polys, + texparams_list *texparams, + TGPolygon *accum ); + + void gen_simple_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ); + void gen_rwy( double alt_m, + const std::string& material, + superpoly_list *rwy_polys, + texparams_list *texparams, + TGPolygon *accum ); + + void gen_rw_marking( const TGPolygon& runway, + double &start1_pct, double &end1_pct, + double heading, + const string& material, + superpoly_list *rwy_polys, + texparams_list *texparams, + TGPolygon *accum, int marking); }; typedef std::vector RunwayList; diff --git a/src/Airports/GenAirports850/rwy_common.cxx b/src/Airports/GenAirports850/rwy_common.cxx index 9dcf5c1a..920781fa 100644 --- a/src/Airports/GenAirports850/rwy_common.cxx +++ b/src/Airports/GenAirports850/rwy_common.cxx @@ -27,15 +27,14 @@ #include "global.hxx" #include "poly_extra.hxx" -#include "rwy_common.hxx" +#include "runway.hxx" #include using std::string; -void gen_number_block( const TGRunway& rwy_info, - const string& material, +void Runway::gen_number_block( const string& material, TGPolygon poly, double heading, int num, double start_pct, double end_pct, superpoly_list *rwy_polys, @@ -65,7 +64,7 @@ void gen_number_block( const TGRunway& rwy_info, // printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2); if ( num < 10 || num == 11 ) { - gen_runway_section( rwy_info, poly, + gen_runway_section( poly, start_pct, end_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -73,14 +72,14 @@ void gen_number_block( const TGRunway& rwy_info, material, tex1, rwy_polys, texparams, accum ); } else { - gen_runway_section( rwy_info, poly, + gen_runway_section( poly, start_pct, end_pct, 0.0, 0.5, 0.0, 1.0, 0.0, 1.0, heading, material, tex1, rwy_polys, texparams, accum ); - gen_runway_section( rwy_info, poly, + gen_runway_section( poly, start_pct, end_pct, 0.5, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -90,44 +89,42 @@ void gen_number_block( const TGRunway& rwy_info, } } -// generate the runway stopway -void gen_runway_stopway( const TGRunway& rwy_info, - const TGPolygon& runway_half, +// generate the runway overrun area +void Runway::gen_runway_overrun( const TGPolygon& runway_half, int rwhalf, const string& prefix, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon* accum ) { - const float length = rwy_info.length / 2.0 + 2.0 * SG_FEET_TO_METER; + const float length = rwy.length / 2.0 + 2.0 * SG_FEET_TO_METER; double start1_pct = 0.0; double end1_pct = 0.0; double part_len = 0.0; double heading = 0.0; - double stopway = 0.0; + double overrun = 0.0; int count=0; int i=0; if (rwhalf == 1) { - heading = rwy_info.heading + 180.0; - stopway = rwy_info.stopway1; + heading = rwy.heading + 180.0; + overrun = rwy.overrun[0]; } else if (rwhalf == 2) { - heading = rwy_info.heading; - stopway = rwy_info.stopway2; + heading = rwy.heading; + overrun = rwy.overrun[1]; } - if (stopway > 0.0) { - /* Generate approach end stopway */ - count = (int) (stopway * 2.0/ rwy_info.width); + if (overrun > 0.0) { + /* Generate approach end overrun */ + count = (int) (overrun * 2.0/ rwy.width); if(count < 1) count = 1; - part_len = stopway / (double) count; + part_len = overrun / (double) count; for(i=0;i #include #include - -#include "rwy_common.hxx" +#include "runway.hxx" #include @@ -35,8 +34,7 @@ struct sections int size; }; -void gen_rw_marking( const TGRunway& rwy_info, - const TGPolygon& runway, +void Runway::gen_rw_marking( const TGPolygon& runway, double &start1_pct, double &end1_pct, double heading, const string& material, @@ -111,7 +109,7 @@ void gen_rw_marking( const TGRunway& rwy_info, } //Now create the sections of the runway type - double length = rwy_info.length / 2.0 + 0.5; + double length = rwy.length / 2.0 + 0.5; for ( int i=0; i < rw_marking_list.size(); ++i) { SG_LOG(SG_GENERAL, SG_INFO, "Runway section texture = " << rw_marking_list[i].tex << " lenght: " << rw_marking_list[i].size); @@ -119,7 +117,7 @@ void gen_rw_marking( const TGRunway& rwy_info, if ( end1_pct < 1.0 ) { start1_pct = end1_pct; end1_pct = start1_pct + ( rw_marking_list[i].size / length ); - gen_runway_section( rwy_info, runway, + gen_runway_section( runway, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -137,14 +135,13 @@ void gen_rw_marking( const TGRunway& rwy_info, // dimensions of precision runway markings, please refer to FAA // document AC 150/5340-1H -void gen_rwy( const TGRunway& rwy_info, - double alt_m, +void Runway::gen_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, TGPolygon *accum ) { - SG_LOG( SG_GENERAL, SG_INFO, "Building runway = " << rwy_info.rwy_no1 << " / " << rwy_info.rwy_no2); + SG_LOG( SG_GENERAL, SG_INFO, "Building runway = " << rwy.rwnum[0] << " / " << rwy.rwnum[1]); // // Generate the basic runway outlines @@ -152,7 +149,7 @@ void gen_rwy( const TGRunway& rwy_info, int i; - TGPolygon runway = gen_runway_w_mid( rwy_info, alt_m, + TGPolygon runway = gen_runway_w_mid( alt_m, 2 * SG_FEET_TO_METER, 2 * SG_FEET_TO_METER ); @@ -190,11 +187,11 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // we add 0.5m to the length for texture overlap. This puts the // lines on the texture back to the edge of the runway where they // belong. - double length = rwy_info.length / 2.0 + 0.5; + double length = rwy.length / 2.0 + 0.5; if ( length < 3075 * SG_FEET_TO_METER ) { SG_LOG( SG_GENERAL, SG_ALERT, - "Runway " << rwy_info.rwy_no1 << " is not long enough (" - << rwy_info.length << ") for precision markings!"); + "Runway " << rwy.rwnum[0] << " is not long enough (" + << rwy.length << ") for precision markings!"); } int marking = 0; @@ -206,23 +203,23 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ string rwname; - // + // // Displaced threshold if it exists // if (rwhalf == 1) { - marking = rwy_info.marking_code1; - disp_thresh = rwy_info.disp_thresh1; - heading = rwy_info.heading + 180.0; - rwname = rwy_info.rwy_no1; - stopway = rwy_info.stopway1; + marking = rwy.marking[0]; + disp_thresh = rwy.threshold[0]; + heading = rwy.heading + 180.0; + rwname = rwy.rwnum[0]; + stopway = rwy.overrun[0]; } else if (rwhalf == 2) { - marking = rwy_info.marking_code2; - disp_thresh = rwy_info.disp_thresh2; - heading = rwy_info.heading; - rwname = rwy_info.rwy_no2; - stopway = rwy_info.stopway2; + marking = rwy.marking[1]; + disp_thresh = rwy.threshold[1]; + heading = rwy.heading; + rwname = rwy.rwnum[1]; + stopway = rwy.overrun[1]; } SG_LOG( SG_GENERAL, SG_INFO, "runway marking = " << marking ); if ( disp_thresh > 0.0 ) { @@ -242,7 +239,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // starting (possibly partial chunk) start1_pct = end1_pct; end1_pct = start1_pct + ( part_len / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, tex_pct, 1.0, @@ -254,7 +251,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ for ( i = 0; i < count; ++i ) { start1_pct = end1_pct; end1_pct = start1_pct + ( 200.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -266,7 +263,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // final arrows start1_pct = end1_pct; end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -282,7 +279,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ start1_pct = end1_pct; end1_pct = start1_pct + ( 10 / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -295,7 +292,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ start1_pct = end1_pct; end1_pct = start1_pct + ( 202.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -322,14 +319,13 @@ if (!marking == 0){ } } - SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation1 = " << rwname); SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter1 = " << letter); if ( !letter.empty() ) { start1_pct = end1_pct; end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -360,14 +356,14 @@ if (!marking == 0){ start1_pct = end1_pct; end1_pct = start1_pct + ( 80.0 * SG_FEET_TO_METER / length ); - gen_number_block( rwy_info, material, runway_half, heading, + gen_number_block( material, runway_half, heading, num, start1_pct, end1_pct, rwy_polys, texparams, accum ); } if (marking > 1){ // Generate remaining markings depending on type of runway - gen_rw_marking( rwy_info, runway_half, + gen_rw_marking( runway_half, start1_pct, end1_pct, heading, material, rwy_polys, texparams, accum, marking ); @@ -388,7 +384,7 @@ if (!marking == 0){ start1_pct = end1_pct; end1_pct = start1_pct + rest1_inc; - gen_runway_section( rwy_info, runway_half, + gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -397,7 +393,7 @@ if (!marking == 0){ rwy_polys, texparams, accum ); } - gen_runway_stopway( rwy_info, runway_half, rwhalf, + gen_runway_overrun( runway_half, rwhalf, material, rwy_polys, texparams, accum ); diff --git a/src/Airports/GenAirports850/rwy_simple.cxx b/src/Airports/GenAirports850/rwy_simple.cxx index 5c975fa9..7449f4ff 100644 --- a/src/Airports/GenAirports850/rwy_simple.cxx +++ b/src/Airports/GenAirports850/rwy_simple.cxx @@ -24,18 +24,16 @@ #include #include #include - -#include "poly_extra.hxx" -#include "rwy_common.hxx" +#include #include "texparams.hxx" +#include "runway.hxx" using std::string; // generate a simple runway. The routine modifies rwy_polys, // texparams, and accum -void gen_simple_rwy( const TGRunway& rwy_info, - double alt_m, +void Runway::gen_simple_rwy( double alt_m, const string& material, superpoly_list *rwy_polys, texparams_list *texparams, @@ -43,7 +41,7 @@ void gen_simple_rwy( const TGRunway& rwy_info, { int i; - TGPolygon runway = gen_runway_w_mid( rwy_info, alt_m, 0.0, 0.0 ); + TGPolygon runway = gen_runway_w_mid( alt_m, 0.0, 0.0 ); TGPolygon runway_half; @@ -72,7 +70,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // we add 0.5m to the length for texture overlap. This puts the // lines on the texture back to the edge of the runway where they // belong. - double length = rwy_info.length / 2.0 + 0.5; + double length = rwy.length / 2.0 + 0.5; int marking = 0; double start1_pct = 0.0; double end1_pct = 0.0; @@ -87,18 +85,18 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // if (rwhalf == 1) { - marking = rwy_info.marking_code1; - disp_thresh = rwy_info.disp_thresh1; - heading = rwy_info.heading + 180.0; - rwname = rwy_info.rwy_no1; - stopway = rwy_info.stopway1; + marking = rwy.marking[0]; + disp_thresh = rwy.threshold[0]; + heading = rwy.heading + 180.0; + rwname = rwy.rwnum[0]; + stopway = rwy.overrun[0]; } else if (rwhalf == 2) { - marking = rwy_info.marking_code2; - disp_thresh = rwy_info.disp_thresh2; - heading = rwy_info.heading; - rwname = rwy_info.rwy_no2; - stopway = rwy_info.stopway2; + marking = rwy.marking[1]; + disp_thresh = rwy.threshold[1]; + heading = rwy.heading; + rwname = rwy.rwnum[1]; + stopway = rwy.overrun[1]; } SG_LOG( SG_GENERAL, SG_INFO, "runway marking = " << marking ); if ( disp_thresh > 0.0 ) { @@ -118,7 +116,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // starting (possibly partial chunk) start1_pct = end1_pct; end1_pct = start1_pct + ( part_len / length ); - gen_runway_section( rwy_info, runway_half, + Runway::gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, tex_pct, 1.0, @@ -130,7 +128,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ for ( i = 0; i < count; ++i ) { start1_pct = end1_pct; end1_pct = start1_pct + ( 200.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + Runway::gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -142,7 +140,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ // final arrows start1_pct = end1_pct; end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length ); - gen_runway_section( rwy_info, runway_half, + Runway::gen_runway_section( runway_half, start1_pct, end1_pct, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -151,7 +149,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){ rwy_polys, texparams, accum ); } - gen_runway_section( rwy_info, runway_half, + Runway::gen_runway_section( runway_half, 0, 1, 0.0, 1.0, 0.0, 0.28, 0.0, 1.0, diff --git a/src/Airports/GenAirports850/rwy_simple.hxx b/src/Airports/GenAirports850/rwy_simple.hxx deleted file mode 100644 index 6b3183ab..00000000 --- a/src/Airports/GenAirports850/rwy_simple.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// rwy_simple.hxx -- Build a simple (non-marked) runway -// -// Written by Curtis Olson, started February 2002. -// -// Copyright (C) 2002 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 published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// $Id: rwy_simple.hxx,v 1.5 2004-11-19 22:25:49 curt Exp $ -// - - -#ifndef _RWY_SIMPLE_HXX -#define _RWY_SIMPLE_HXX - - -#include -#include - -#include "runway.hxx" -#include "texparams.hxx" - - -// generate a simple runway. The routine modifies rwy_polys, -// texparams, and accum -void gen_simple_rwy( const TGRunway& rwy_info, - double alt_m, - const std::string& material, - superpoly_list *rwy_polys, - texparams_list *texparams, - TGPolygon *accum ); - - -#endif // _RWY_SIMPLE_HXX