#include <math.h>
#include <algorithm>
+#include <fstream>
#include <osg/Geode>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/material/EffectCullVisitor.hxx>
#include <simgear/scene/material/matlib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/scene/tgdb/TileEntry.hxx>
#include <simgear/scene/model/ModelRegistry.hxx>
// The file path list must be set in the registry.
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
- SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
- btgOptions->getDatabasePathList() = filePathList;
- btgOptions->setMatlib(globals->get_matlib());
- btgOptions->setUseRandomObjects(fgGetBool("/sim/rendering/random-objects", false));
- btgOptions->setUseRandomVegetation(fgGetBool("/sim/rendering/random-vegetation", false));
+ simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
+ options->getDatabasePathList() = filePathList;
+ options->setMaterialLib(globals->get_matlib());
+ options->setPropertyNode(globals->get_props());
// read the scene from the list of file specified command line args.
osg::ref_ptr<osg::Node> loadedModel;
- loadedModel = osgDB::readNodeFiles(dataFiles, btgOptions);
+ loadedModel = osgDB::readNodeFiles(dataFiles, options);
// if no model has been successfully loaded report failure.
if (!loadedModel.valid()) {
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/scene/model/modellib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/tsync/terrasync.hxx>
#include <Main/globals.hxx>
using simgear::TileCache;
-// helper: listen to property changes affecting tile loading
-class LoaderPropertyWatcher : public SGPropertyChangeListener
-{
-public:
- LoaderPropertyWatcher(FGTileMgr* pTileMgr) :
- _pTileMgr(pTileMgr)
- {
- }
-
- virtual void valueChanged(SGPropertyNode*)
- {
- _pTileMgr->configChanged();
- }
-
-private:
- FGTileMgr* _pTileMgr;
-};
-
-
FGTileMgr::FGTileMgr():
state( Start ),
vis( 16000 ),
- _terra_sync(NULL),
- _propListener(new LoaderPropertyWatcher(this))
+ _terra_sync(NULL)
{
- _randomObjects = fgGetNode("/sim/rendering/random-objects", true);
- _randomVegetation = fgGetNode("/sim/rendering/random-vegetation", true);
_maxTileRangeM = fgGetNode("/sim/rendering/static-lod/bare", true);
}
// remove all nodes we might have left behind
osg::Group* group = globals->get_scenery()->get_terrain_branch();
group->removeChildren(0, group->getNumChildren());
- delete _propListener;
- _propListener = NULL;
// clear OSG cache
osgDB::Registry::instance()->clearObjectCache();
}
void FGTileMgr::init() {
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
- _options = new SGReaderWriterBTGOptions;
- _options->setMatlib(globals->get_matlib());
-
- _randomObjects.get()->addChangeListener(_propListener, false);
- _randomVegetation.get()->addChangeListener(_propListener, false);
- configChanged();
+ _options = new simgear::SGReaderWriterOptions;
+ _options->setMaterialLib(globals->get_matlib());
+ _options->setPropertyNode(globals->get_props());
osgDB::FilePathList &fp = _options->getDatabasePathList();
const string_list &sc = globals->get_fg_scenery();
update(0.0);
}
-void FGTileMgr::configChanged()
-{
- _options->setUseRandomObjects(_randomObjects.get()->getBoolValue());
- _options->setUseRandomVegetation(_randomVegetation.get()->getBoolValue());
-}
-
/* schedule a tile for loading, keep request for given amount of time.
* Returns true if tile is already loaded. */
bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)
#include <simgear/scene/tgdb/TileEntry.hxx>
#include <simgear/scene/tgdb/TileCache.hxx>
-class SGReaderWriterBTGOptions;
-
namespace osg
{
class Node;
namespace simgear
{
class SGTerraSync;
+class SGReaderWriterOptions;
}
class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
SGBucket previous_bucket;
SGBucket current_bucket;
SGBucket pending;
- osg::ref_ptr<SGReaderWriterBTGOptions> _options;
+ osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
// x and y distance of tiles to load/draw
float vis;
static void refresh_tile(void* tileMgr, long tileIndex);
SGPropertyNode* _visibilityMeters;
- SGPropertyChangeListener* _propListener;
- SGPropertyNode_ptr _randomObjects;
- SGPropertyNode_ptr _randomVegetation;
SGPropertyNode_ptr _maxTileRangeM;
public:
virtual void update(double dt);
- // update loader configuration options
- void configChanged();
-
int schedule_tiles_at(const SGGeod& location, double rangeM);
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/material/EffectCullVisitor.hxx>
#include <simgear/scene/material/matlib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/scene/tgdb/TileEntry.hxx>
#include <simgear/scene/model/ModelRegistry.hxx>
// The file path list must be set in the registry.
osgDB::Registry::instance()->getDataFilePathList() = filePathList;
- SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
- btgOptions->getDatabasePathList() = filePathList;
- btgOptions->setMatlib(ml);
+ simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
+ options->getDatabasePathList() = filePathList;
+ options->setMaterialLib(ml);
+ options->setPropertyNode(props);
// Here, all arguments are processed
arguments.reportRemainingOptionsAsUnrecognized();
// read the scene from the list of file specified command line args.
osg::ref_ptr<osg::Node> loadedModel;
- loadedModel = osgDB::readNodeFiles(arguments, btgOptions);
+ loadedModel = osgDB::readNodeFiles(arguments, options);
// if no model has been successfully loaded report failure.
if (!loadedModel.valid()) {