From 2b8f7a21354b3f48eae3fa4607ed3e451a18a9d5 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 5 Jan 2001 00:05:02 +0000 Subject: [PATCH] Write out binary objects rather than ascii. --- src/BuildTiles/GenOutput/genobj.cxx | 65 ++++++++++++++++++++++++++++- src/BuildTiles/Main/Makefile.am | 2 +- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/BuildTiles/GenOutput/genobj.cxx b/src/BuildTiles/GenOutput/genobj.cxx index eaed894f..d4e17809 100644 --- a/src/BuildTiles/GenOutput/genobj.cxx +++ b/src/BuildTiles/GenOutput/genobj.cxx @@ -24,10 +24,10 @@ #include +#include #include #include -#include "scenery_version.hxx" #ifdef _MSC_VER # include @@ -308,8 +308,9 @@ void FGGenOutput::calc_bounding_sphere( FGConstruct& c, const FGTriEle& t, } +#if 0 // write out the fgfs scenery file -int FGGenOutput::write( FGConstruct &c ) { +int FGGenOutput::write_orig( FGConstruct &c ) { Point3D p; int i; @@ -423,5 +424,65 @@ int FGGenOutput::write( FGConstruct &c ) { return 1; } +#endif + + +// write out the fgfs scenery file +int FGGenOutput::write( FGConstruct &c ) { + int i; + + // Assemble all the data into the final format + + SGBucket b = c.get_bucket(); + string base = c.get_output_base() + "/Scenery/"; + string name = b.gen_index_str(); + + point_list wgs84_nodes = c.get_wgs84_nodes(); + point_list normals = c.get_point_normals(); + cout << "dumping normals = " << normals.size() << endl; + /* for ( i = 0; i < (int)normals.size(); ++i ) { + Point3D p = normals[i]; + printf("vn %.5f %.5f %.5f\n", p.x(), p.y(), p.z()); + } */ + point_list texcoords = tex_coords.get_node_list(); + + // allocate and initialize triangle group structures + group_list tris_v; group_list tris_tc; string_list tri_materials; + tris_v.clear(); tris_tc.clear(); tri_materials.clear(); + + group_list strips_v; group_list strips_tc; string_list strip_materials; + strips_v.clear(); strips_tc.clear(); strip_materials.clear(); + + group_list fans_v; group_list fans_tc; string_list fan_materials; + fans_v.clear(); fans_tc.clear(); fan_materials.clear(); + + for ( i = 0; i < FG_MAX_AREA_TYPES; ++i ) { + if ( (int)fans[i].size() > 0 ) { + cout << "creating " << fans[i].size() << " fans of type " + << i << endl; + string attr_name = get_area_name( (AreaType)i ); + + int_list vs, tcs; + for ( int j = 0; j < (int)fans[i].size(); ++j ) { + vs.clear(); tcs.clear(); + for ( int k = 0; k < (int)fans[i][j].size(); ++k ) { + vs.push_back( fans[i][j][k] ); + tcs.push_back( textures[i][j][k] ); + } + fans_v.push_back( vs ); + fans_tc.push_back( tcs ); + fan_materials.push_back( attr_name ); + } + } + } + + sgWriteBinObj( base, name, b, gbs_center, gbs_radius, + wgs84_nodes, normals, texcoords, + tris_v, tris_tc, tri_materials, + strips_v, strips_tc, strip_materials, + fans_v, fans_tc, fan_materials ); + + return 1; +} diff --git a/src/BuildTiles/Main/Makefile.am b/src/BuildTiles/Main/Makefile.am index f14d8cd5..d5907c80 100644 --- a/src/BuildTiles/Main/Makefile.am +++ b/src/BuildTiles/Main/Makefile.am @@ -16,7 +16,7 @@ fgfs_construct_LDADD = \ $(top_builddir)/src/Lib/landcover/liblandcover.a \ $(top_builddir)/src/Lib/poly2tri/libpoly2tri.a \ $(top_builddir)/src/Lib/TriangleJRS/libTriangleJRS.a \ - -lsgbucket -lsgmath -lsgmisc -lsgdebug -lplibsg -lz -lgpc + -lsgbucket -lsgio -lsgmath -lsgmisc -lsgdebug -lplibsg -lz -lgpc fgfs_master_SOURCES = master.cxx