water runway support
This commit is contained in:
parent
d1aece0be3
commit
dfd63f3fd8
3 changed files with 92 additions and 33 deletions
|
@ -236,46 +236,50 @@ static void build_runway( const TGRunway& rwy_info,
|
||||||
material = "grass_rwy";
|
material = "grass_rwy";
|
||||||
} else if ( surface_code == 4 /* Dirt */
|
} else if ( surface_code == 4 /* Dirt */
|
||||||
|| surface_code == 5 /* Gravel */
|
|| surface_code == 5 /* Gravel */
|
||||||
|| surface_code == 12 /* Dry lakebed */ ) {
|
|| surface_code == 12 /* Dry lakebed */
|
||||||
|
|| surface_code == 13 /* Water */
|
||||||
|
|| surface_code == 14 /* Snow/Ice */
|
||||||
|
|| surface_code == 15 /* Transparent */) {
|
||||||
material = "dirt_rwy";
|
material = "dirt_rwy";
|
||||||
} else {
|
} else {
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "surface_code = " << surface_code);
|
SG_LOG(SG_GENERAL, SG_WARN, "surface_code = " << surface_code);
|
||||||
throw sg_exception("unknown runway type!");
|
throw sg_exception("unknown runway type!");
|
||||||
}
|
}
|
||||||
if ( rwy_info.type == 102 ){
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Generating Helipad" );
|
if ( rwy_info.type == 102 ){
|
||||||
gen_heli( rwy_info, alt_m, material,
|
SG_LOG(SG_GENERAL, SG_INFO, "Generating Helipad" );
|
||||||
rwy_polys, texparams, accum );
|
gen_heli( rwy_info, alt_m, material,
|
||||||
}
|
rwy_polys, texparams, accum );
|
||||||
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "marking code = " << rwy_info.marking_code1 << " / " << rwy_info.marking_code2);
|
SG_LOG(SG_GENERAL, SG_DEBUG, "marking code = " << rwy_info.marking_code1 << " / " << rwy_info.marking_code2);
|
||||||
if ( rwy_info.type == 100 ){
|
if ( rwy_info.type == 100 ){
|
||||||
if ( surface_code == 3 /* Turf/Grass */
|
if ( surface_code == 3 /* Turf/Grass */
|
||||||
|| surface_code == 4 /* Dirt */
|
|| surface_code == 4 /* Dirt */
|
||||||
|| surface_code == 5 /* Gravel */ )
|
|| surface_code == 5 /* Gravel */ )
|
||||||
{
|
{
|
||||||
gen_simple_rwy( rwy_info, alt_m, material,
|
gen_simple_rwy( rwy_info, alt_m, material,
|
||||||
rwy_polys, texparams, accum );
|
rwy_polys, texparams, accum );
|
||||||
} else if (rwy_info.marking_code1 == 5 ||
|
} else if (rwy_info.marking_code1 == 5 ||
|
||||||
rwy_info.marking_code1 == 4 ||
|
rwy_info.marking_code1 == 4 ||
|
||||||
rwy_info.marking_code1 == 3 ||
|
rwy_info.marking_code1 == 3 ||
|
||||||
rwy_info.marking_code1 == 2 ||
|
rwy_info.marking_code1 == 2 ||
|
||||||
rwy_info.marking_code1 == 1 ||
|
rwy_info.marking_code1 == 1 ||
|
||||||
rwy_info.marking_code1 == 0 ) {
|
rwy_info.marking_code1 == 0 ) {
|
||||||
|
|
||||||
gen_rwy( rwy_info, alt_m, material,
|
gen_rwy( rwy_info, alt_m, material,
|
||||||
rwy_polys, texparams, accum );
|
rwy_polys, texparams, accum );
|
||||||
} else if ( surface_code == 13 /* Water buoys */ ) {
|
} else if ( surface_code == 13 /* Water buoys */ ) {
|
||||||
// do nothing for now.
|
// do nothing for now.
|
||||||
} else {
|
} else {
|
||||||
// unknown runway code ... hehe, I know, let's just die
|
// unknown runway code ... hehe, I know, let's just die
|
||||||
// right here so the programmer has to fix his code if a
|
// right here so the programmer has to fix his code if a
|
||||||
// new code ever gets introduced. :-)
|
// new code ever gets introduced. :-)
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown runway marking code = " <<
|
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown runway marking code = " <<
|
||||||
rwy_info.marking_code1 );
|
rwy_info.marking_code1 );
|
||||||
throw sg_exception("Unknown runway code in build.cxx:build_airport()");
|
throw sg_exception("Unknown runway code in build.cxx:build_airport()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TGPolygon base, safe_base;
|
TGPolygon base, safe_base;
|
||||||
if (rwy_info.type == 100){
|
if (rwy_info.type == 100){
|
||||||
|
@ -303,6 +307,7 @@ if ( rwy_info.type == 100 ){
|
||||||
// build 3d airport
|
// build 3d airport
|
||||||
void build_airport( string airport_id, float alt_m,
|
void build_airport( string airport_id, float alt_m,
|
||||||
string_list& runways_raw,
|
string_list& runways_raw,
|
||||||
|
string_list& water_raw,
|
||||||
string_list& beacons_raw,
|
string_list& beacons_raw,
|
||||||
string_list& towers_raw,
|
string_list& towers_raw,
|
||||||
string_list& windsocks_raw,
|
string_list& windsocks_raw,
|
||||||
|
@ -459,6 +464,38 @@ void build_airport( string airport_id, float alt_m,
|
||||||
SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count );
|
SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count );
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
|
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
|
||||||
|
|
||||||
|
point_list water_rw; water_rw.clear();
|
||||||
|
for ( i = 0; i < (int)water_raw.size(); ++i ) {
|
||||||
|
string water_str = water_raw[i];
|
||||||
|
vector<string> token = simgear::strutils::split( water_str );
|
||||||
|
|
||||||
|
//first runway end coordinates
|
||||||
|
double lat_1 = atof( token[4].c_str() );
|
||||||
|
double lon_1 = atof( token[5].c_str() );
|
||||||
|
SGGeod pos_1(SGGeod::fromDegFt(lon_1, lat_1, 0.0));
|
||||||
|
|
||||||
|
//opposite end coordinates
|
||||||
|
double lat_2 = atof( token[7].c_str() );
|
||||||
|
double lon_2 = atof( token[8].c_str() );
|
||||||
|
SGGeod pos_2(SGGeod::fromDegFt(lon_2, lat_2, 0.0));
|
||||||
|
|
||||||
|
//runway centerpoint
|
||||||
|
Point3D rw_center = Point3D( (lon_1 + lon_2) / 2 , (lat_1 + lat_2) / 2, 0);
|
||||||
|
|
||||||
|
double heading = (SGGeodesy::courseDeg(pos_1, pos_2));
|
||||||
|
|
||||||
|
double length = (SGGeodesy::distanceM(pos_1, pos_2));
|
||||||
|
double width = atoi( token[1].c_str() );
|
||||||
|
|
||||||
|
TGPolygon rw_outline = gen_wgs84_area(rw_center, length, 0, 0, width,
|
||||||
|
heading, 0, false);
|
||||||
|
|
||||||
|
for ( i = 0; i < rw_outline.contour_size( 0 ); ++i ) {
|
||||||
|
water_rw.push_back( rw_outline.get_pt( 0, i ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
point_list beacons; beacons.clear();
|
point_list beacons; beacons.clear();
|
||||||
for ( i = 0; i < (int)beacons_raw.size(); ++i ) {
|
for ( i = 0; i < (int)beacons_raw.size(); ++i ) {
|
||||||
string beacon_str = beacons_raw[i];
|
string beacon_str = beacons_raw[i];
|
||||||
|
@ -1050,6 +1087,8 @@ void build_airport( string airport_id, float alt_m,
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
|
||||||
|
|
||||||
|
SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations");
|
||||||
|
point_list water_buoys_nodes = calc_elevations( apt_surf, water_rw, 0.0 );
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations");
|
SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations");
|
||||||
point_list beacon_nodes = calc_elevations( apt_surf, beacons, 0.0 );
|
point_list beacon_nodes = calc_elevations( apt_surf, beacons, 0.0 );
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Computing tower node elevations");
|
SG_LOG(SG_GENERAL, SG_INFO, "Computing tower node elevations");
|
||||||
|
@ -1338,6 +1377,13 @@ void build_airport( string airport_id, float alt_m,
|
||||||
// write out airport object reference
|
// write out airport object reference
|
||||||
write_index( objpath, b, name );
|
write_index( objpath, b, name );
|
||||||
|
|
||||||
|
// write out water runway buoys references
|
||||||
|
for ( i = 0; i < (int)water_buoys_nodes.size(); ++i ) {
|
||||||
|
write_index_shared( objpath, b, water_buoys_nodes[i],
|
||||||
|
"Models/Airport/water_rw_buoy.ac",
|
||||||
|
0.0 );
|
||||||
|
}
|
||||||
|
|
||||||
// write out beacon references
|
// write out beacon references
|
||||||
for ( i = 0; i < (int)beacon_nodes.size(); ++i ) {
|
for ( i = 0; i < (int)beacon_nodes.size(); ++i ) {
|
||||||
write_index_shared( objpath, b, beacon_nodes[i],
|
write_index_shared( objpath, b, beacon_nodes[i],
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
// build 3d airport
|
// build 3d airport
|
||||||
void build_airport( string airport_id, float alt_m,
|
void build_airport( string airport_id, float alt_m,
|
||||||
string_list& runways_raw,
|
string_list& runways_raw,
|
||||||
|
string_list& water_raw,
|
||||||
string_list& beacons_raw,
|
string_list& beacons_raw,
|
||||||
string_list& towers_raw,
|
string_list& towers_raw,
|
||||||
string_list& windsocks_raw,
|
string_list& windsocks_raw,
|
||||||
|
|
|
@ -248,6 +248,7 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list runways_list;
|
string_list runways_list;
|
||||||
|
string_list water_rw_list;
|
||||||
string_list beacon_list;
|
string_list beacon_list;
|
||||||
string_list tower_list;
|
string_list tower_list;
|
||||||
string_list windsock_list;
|
string_list windsock_list;
|
||||||
|
@ -302,9 +303,11 @@ int main( int argc, char **argv ) {
|
||||||
if ( runways_list.size() ) {
|
if ( runways_list.size() ) {
|
||||||
vector<string> rwy_token
|
vector<string> rwy_token
|
||||||
= simgear::strutils::split( runways_list[0] );
|
= simgear::strutils::split( runways_list[0] );
|
||||||
|
if ( token[0] == "100" ){
|
||||||
rwy = token[8];
|
rwy = token[8];
|
||||||
lat = atof( token[9].c_str() );
|
lat = atof( token[9].c_str() );
|
||||||
lon = atof( token[10].c_str() );
|
lon = atof( token[10].c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( airport_id.length() && airport_id == last_apt_id ) {
|
if ( airport_id.length() && airport_id == last_apt_id ) {
|
||||||
ready_to_go = true;
|
ready_to_go = true;
|
||||||
|
@ -331,6 +334,7 @@ int main( int argc, char **argv ) {
|
||||||
build_airport( last_apt_id,
|
build_airport( last_apt_id,
|
||||||
elev * SG_FEET_TO_METER,
|
elev * SG_FEET_TO_METER,
|
||||||
runways_list,
|
runways_list,
|
||||||
|
water_rw_list,
|
||||||
beacon_list,
|
beacon_list,
|
||||||
tower_list,
|
tower_list,
|
||||||
windsock_list,
|
windsock_list,
|
||||||
|
@ -364,13 +368,18 @@ int main( int argc, char **argv ) {
|
||||||
|
|
||||||
// clear runway list for start of next airport
|
// clear runway list for start of next airport
|
||||||
runways_list.clear();
|
runways_list.clear();
|
||||||
|
water_rw_list.clear();
|
||||||
beacon_list.clear();
|
beacon_list.clear();
|
||||||
tower_list.clear();
|
tower_list.clear();
|
||||||
windsock_list.clear();
|
windsock_list.clear();
|
||||||
light_list.clear();
|
light_list.clear();
|
||||||
} else if ( token[0] == "100" || token[0] == "102") {
|
} else if ( token[0] == "100" || token[0] == "102") {
|
||||||
// runway entry
|
// runway entry (Land or heli)
|
||||||
runways_list.push_back(line);
|
runways_list.push_back(line);
|
||||||
|
} else if ( token[0] == "101" ) {
|
||||||
|
// Water runway. Here we don't have to create any textures.
|
||||||
|
// Only place some buoys
|
||||||
|
water_rw_list.push_back(line);
|
||||||
} else if ( token[0] == "18" ) {
|
} else if ( token[0] == "18" ) {
|
||||||
// beacon entry
|
// beacon entry
|
||||||
beacon_list.push_back(line);
|
beacon_list.push_back(line);
|
||||||
|
@ -395,7 +404,9 @@ int main( int argc, char **argv ) {
|
||||||
} else if ( token[0] == "00" ) {
|
} else if ( token[0] == "00" ) {
|
||||||
// ??
|
// ??
|
||||||
} else if ( token[0] >= "110" ) {
|
} else if ( token[0] >= "110" ) {
|
||||||
//ignore lines for now
|
//ignore taxiways for now
|
||||||
|
} else if ( token[0] == "10" ) {
|
||||||
|
//ignore old taxiways for now
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||||
"Unknown line in file: " << line );
|
"Unknown line in file: " << line );
|
||||||
|
@ -438,6 +449,7 @@ int main( int argc, char **argv ) {
|
||||||
if( is_in_range( runways_list, min_lat, max_lat, min_lon, max_lon ) ) {
|
if( is_in_range( runways_list, min_lat, max_lat, min_lon, max_lon ) ) {
|
||||||
build_airport( last_apt_id, elev * SG_FEET_TO_METER,
|
build_airport( last_apt_id, elev * SG_FEET_TO_METER,
|
||||||
runways_list,
|
runways_list,
|
||||||
|
water_rw_list,
|
||||||
beacon_list,
|
beacon_list,
|
||||||
tower_list,
|
tower_list,
|
||||||
windsock_list,
|
windsock_list,
|
||||||
|
|
Loading…
Reference in a new issue