//
// Written by Curtis Olson, started January 1998.
//
-// Copyright (C) 1998, 1999 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
#endif
#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <ssg.h> // plib include
-
-#include <Debug/logstream.hxx>
-#include <Misc/fgstream.hxx>
-#include <Airports/genapt.hxx>
-#include <Bucket/newbucket.hxx>
-#include <Clouds/cloudobj.hxx>
-#include <Main/options.hxx>
-#include <Main/views.hxx>
-#include <Misc/fgpath.hxx>
+#include <simgear/xgl/xgl.h>
+
+#include <plib/ssg.h> // plib include
+
+#include <simgear/bucket/newbucket.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/fgstream.hxx>
+#include <simgear/misc/fgpath.hxx>
+
+#include <Main/globals.hxx>
#include <Objects/obj.hxx>
#include <Scenery/scenery.hxx> // for scenery.center
#include "tilecache.hxx"
#include "tileentry.hxx"
+FG_USING_NAMESPACE(std);
// a cheesy hack (to be fixed later)
extern ssgBranch *terrain;
//
// target_cache_size >= (current.options.tile_diameter + 1) ** 2
//
- int side = current_options.get_tile_diameter() + 2;
+ int side = globals->get_options()->get_tile_diameter() + 2;
int target_cache_size = (side*side);
FG_LOG( FG_TERRAIN, FG_DEBUG, " target cache size = "
<< target_cache_size );
// and ... just in case we missed something ...
terrain->removeAllKids();
- FG_LOG( FG_TERRAIN, FG_DEBUG, " done with init()" );
+ FG_LOG( FG_TERRAIN, FG_INFO, " done with init()" );
}
tile_cache[index].range_ptr = new ssgRangeSelector;
tile_cache[index].tile_bucket = p;
- FGPath tile_path( current_options.get_fg_root() );
- tile_path.append( "Scenery" );
+ FGPath tile_path;
+ if ( globals->get_options()->get_fg_scenery() != "" ) {
+ tile_path.set( globals->get_options()->get_fg_scenery() );
+ } else {
+ tile_path.set( globals->get_options()->get_fg_root() );
+ tile_path.append( "Scenery" );
+ }
tile_path.append( p.gen_base_path() );
- // Load the appropriate data file and build tile fragment list
+ // Load the appropriate data file
FGPath tile_base = tile_path;
tile_base.append( p.gen_index_str() );
ssgBranch *new_tile = fgObjLoad( tile_base.str(), &tile_cache[index],
while ( ! in.eof() ) {
in >> token;
in >> name;
+#if defined ( macintosh ) || defined ( _MSC_VER )
+ in >> ::skipws;
+#else
in >> skipws;
+#endif
cout << "token = " << token << " name = " << name << endl;
FGPath custom_path = tile_path;
}
}
- // generate cloud layer
- if ( current_options.get_clouds() ) {
- ssgLeaf *cloud_layer = fgGenCloudLayer( &tile_cache[index],
- current_options.get_clouds_asl() );
- cloud_layer->clrTraversalMaskBits( SSGTRAV_HOT );
- new_tile -> addKid( cloud_layer );
- }
-
tile_cache[index].transform_ptr->addKid( tile_cache[index].range_ptr );
// calculate initial tile offset
FGTileCache::next_avail( void )
{
// Point3D delta;
- Point3D abs_view_pos;
+ sgdVec3 abs_view_pos;
int i;
// float max, med, min, tmp;
float dist, max_dist;
return(i);
} else if ( tile_cache[i].is_loaded() || tile_cache[i].is_cached() ) {
// calculate approximate distance from view point
- abs_view_pos = current_view.get_abs_view_pos();
+ sgdCopyVec3( abs_view_pos,
+ globals->get_current_view()->get_abs_view_pos() );
- FG_LOG( FG_TERRAIN, FG_DEBUG,
- "DIST Abs view pos = " << abs_view_pos );
+ FG_LOG( FG_TERRAIN, FG_DEBUG, "DIST Abs view pos = "
+ << abs_view_pos[0] << ","
+ << abs_view_pos[1] << ","
+ << abs_view_pos[2] );
FG_LOG( FG_TERRAIN, FG_DEBUG,
" ref point = " << tile_cache[i].center );
dist = max + (med + min) / 4;
*/
- dist = tile_cache[i].center.distance3D( abs_view_pos );
+ sgdVec3 center;
+ sgdSetVec3( center,
+ tile_cache[i].center[0],
+ tile_cache[i].center[1],
+ tile_cache[i].center[2] );
+ dist = sgdDistanceVec3( center, abs_view_pos );
FG_LOG( FG_TERRAIN, FG_DEBUG, " distance = " << dist );
FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
exit( -1 );
}
+
+ // avoid a potential compiler warning
+ return -1;
}