From: curt Date: Sat, 27 Mar 1999 05:23:22 +0000 (+0000) Subject: Interpolate real z value of all nodes from dem data. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=903ac38cfff0cc948c077c6cc2aa3b1202de825e;p=flightgear.git Interpolate real z value of all nodes from dem data. Write scenery file to correct location. Pass along correct triangle attributes and write to output file. --- diff --git a/GenOutput/genobj.cxx b/GenOutput/genobj.cxx index 72110fa72..b708f0ce5 100644 --- a/GenOutput/genobj.cxx +++ b/GenOutput/genobj.cxx @@ -25,27 +25,33 @@ #include -#include #include +#include +#include #include "genobj.hxx" // build the wgs-84 point list -void FGGenOutput::gen_wgs84_points() { +void FGGenOutput::gen_wgs84_points( const FGArray& array ) { cout << "calculating wgs84 point" << endl; Point3D geod, radians, cart; const_point_list_iterator current = geod_nodes.begin(); const_point_list_iterator last = geod_nodes.end(); + double real_z; + for ( ; current != last; ++current ) { geod = *current; + real_z = array.interpolate_altitude( geod.x() * 3600.0, + geod.y() * 3600.0 ); + // convert to radians radians = Point3D( geod.x() * DEG_TO_RAD, geod.y() * DEG_TO_RAD, - geod.z() ); + real_z ); cart = fgGeodToCart(radians); // cout << cart << endl; @@ -183,7 +189,7 @@ void FGGenOutput::calc_gbs() { // build the necessary output structures based on the triangulation // data -int FGGenOutput::build( const FGTriangle& t ) { +int FGGenOutput::build( const FGArray& array, const FGTriangle& t ) { FGTriNodes trinodes = t.get_out_nodes(); // copy the geodetic node list into this class @@ -193,7 +199,7 @@ int FGGenOutput::build( const FGTriangle& t ) { tri_elements = t.get_elelist(); // generate the point list in wgs-84 coordinates - gen_wgs84_points(); + gen_wgs84_points( array ); // calculate the global bounding sphere calc_gbs(); @@ -248,12 +254,19 @@ void FGGenOutput::calc_bounding_sphere( int i, Point3D *center, // write out the fgfs scenery file -int FGGenOutput::write( const FGBucket& b, const string& path ) { +int FGGenOutput::write( const string& base, const FGBucket& b ) { Point3D p; + string dir = base + "/Scenery/" + b.gen_base_path(); + string command = "mkdir -p " + dir; + system(command.c_str()); + + string file = dir + "/" + b.gen_index_str(); + cout << "Output file = " << file << endl; + FILE *fp; - if ( (fp = fopen( path.c_str(), "w" )) == NULL ) { - cout << "ERROR: opening " << path << " for writing!" << endl; + if ( (fp = fopen( file.c_str(), "w" )) == NULL ) { + cout << "ERROR: opening " << file << " for writing!" << endl; exit(-1); } @@ -301,9 +314,13 @@ int FGGenOutput::write( const FGBucket& b, const string& path ) { const_triele_list_iterator t_current = tri_elements.begin(); const_triele_list_iterator t_last = tri_elements.end(); int counter = 0; + int attribute; + string attr_name; for ( ; t_current != t_last; ++t_current ) { + attribute = (int)t_current->get_attribute(); calc_bounding_sphere( counter, ¢er, &radius ); - fprintf(fp, "# usemtl desert1\n"); + attr_name = get_area_name( (AreaType)attribute ); + fprintf(fp, "# usemtl %s\n", attr_name.c_str() ); fprintf(fp, "# bs %.2f %.2f %.2f %.2f\n", center.x(), center.y(), center.z(), radius); fprintf(fp, "f %d %d %d\n", @@ -312,11 +329,21 @@ int FGGenOutput::write( const FGBucket& b, const string& path ) { ++counter; } + fclose(fp); + + command = "gzip --force --best " + file; + system(command.c_str()); + return 1; } // $Log$ +// Revision 1.4 1999/03/27 05:23:22 curt +// Interpolate real z value of all nodes from dem data. +// Write scenery file to correct location. +// Pass along correct triangle attributes and write to output file. +// // Revision 1.3 1999/03/25 19:04:21 curt // Preparations for outputing scenery file to correct location. // diff --git a/GenOutput/genobj.hxx b/GenOutput/genobj.hxx index ed90deef9..5a5b12b68 100644 --- a/GenOutput/genobj.hxx +++ b/GenOutput/genobj.hxx @@ -32,11 +32,18 @@ #endif +#include + +#include STL_STRING + #include #include #include #include +FG_USING_STD(string); +FG_USING_STD(vector); + typedef vector < int > belongs_to; typedef belongs_to::iterator belongs_to_iterator; @@ -75,7 +82,7 @@ private: double gbs_radius; // build the wgs-84 point list - void gen_wgs84_points(); + void gen_wgs84_points( const FGArray& array ); // build the node -> element (triangle) reverse lookup table. // there is an entry for each point containing a list of all the @@ -106,10 +113,10 @@ public: // build the necessary output structures based on the // triangulation data - int build( const FGTriangle& t ); + int build( const FGArray& array, const FGTriangle& t ); // write out the fgfs scenery file - int write( const FGBucket& b, const string& path ); + int write( const string& base, const FGBucket& b ); }; @@ -117,6 +124,11 @@ public: // $Log$ +// Revision 1.5 1999/03/27 05:23:23 curt +// Interpolate real z value of all nodes from dem data. +// Write scenery file to correct location. +// Pass along correct triangle attributes and write to output file. +// // Revision 1.4 1999/03/25 19:04:22 curt // Preparations for outputing scenery file to correct location. //