#include <time.h>
-#include <Tools/scenery_version.hxx>
#include <Math/mat3.h>
+#include <Polygon/names.hxx>
+#include <Tools/scenery_version.hxx>
#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;
// 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
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();
// 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);
}
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",
++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.
//
#endif
+#include <Include/compiler.h>
+
+#include STL_STRING
+
#include <Bucket/newbucket.hxx>
#include <Math/fg_geodesy.hxx>
#include <Math/point3d.hxx>
#include <Triangulate/triangle.hxx>
+FG_USING_STD(string);
+FG_USING_STD(vector);
+
typedef vector < int > belongs_to;
typedef belongs_to::iterator belongs_to_iterator;
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
// 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 );
};
// $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.
//