#include "globals.hxx"
#include "options.hxx"
-class DummyLoadHelper : public simgear::ModelLoadHelper {
-public:
- virtual osg::Node *loadTileModel(const string& modelPath, bool)
- {
- try {
- SGSharedPtr<SGPropertyNode> prop = new SGPropertyNode;
- return simgear::SGModelLib::loadModel(modelPath,
- globals->get_props());
- } catch (...) {
- std::cerr << "Error loading \"" << modelPath << "\"" << std::endl;
- return 0;
- }
- }
-};
-
class GraphDumpHandler : public osgGA::GUIEventHandler
{
public:
{
sgUserDataInit(0);
- DummyLoadHelper dummyLoadHelper;
- simgear::TileEntry::setModelLoadHelper(&dummyLoadHelper);
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc, argv);
#include "SceneryPager.hxx"
#include "tilemgr.hxx"
-using std::for_each;
using flightgear::SceneryPager;
-using simgear::SGModelLib;
using simgear::TileEntry;
using simgear::TileCache;
const string_list &sc = globals->get_fg_scenery();
fp.clear();
std::copy(sc.begin(), sc.end(), back_inserter(fp));
-
- TileEntry::setModelLoadHelper(this);
+ _options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root());
+ if (!_disableNasalHooks->getBoolValue())
+ _options->setModelData(new FGNasalModelDataProxy);
reinit();
}
}
}
-osg::Node*
-FGTileMgr::loadTileModel(const string& modelPath, bool cacheModel)
-{
- SGPath fullPath = modelPath;
- if (fullPath.isRelative()) {
- string_list sc = globals->get_fg_scenery();
-
- for (string_list_iterator it = sc.begin(); it != sc.end(); ++it) {
- // fg_senery contains empty strings as "markers" (see FGGlobals::set_fg_scenery)
- if (!it->empty()) {
- SGPath tmpPath(*it);
- tmpPath.append(modelPath);
- if (tmpPath.exists()) {
- fullPath = tmpPath;
- break;
- }
- }
- }
- }
- osg::Node* result = 0;
- try {
- if(cacheModel)
- result =
- SGModelLib::loadModel(fullPath.str(), globals->get_props(),
- _disableNasalHooks->getBoolValue() ? NULL : new FGNasalModelDataProxy);
- else
- {
- result=
- SGModelLib::loadDeferredModel(fullPath.str(), globals->get_props(),
- _disableNasalHooks->getBoolValue() ? NULL : new FGNasalModelDataProxy);
- }
- } catch (const sg_io_exception& exc) {
- string m(exc.getMessage());
- m += " ";
- m += exc.getLocation().asString();
- SG_LOG( SG_TERRAIN, SG_ALERT, m );
- } catch (const sg_exception& exc) { // XXX may be redundant
- SG_LOG( SG_TERRAIN, SG_ALERT, exc.getMessage());
- }
- return result;
-}
-
/**
* Update the various queues maintained by the tilemagr (private
* internal function, do not call directly.)
class SGReaderWriterOptions;
}
-class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
+class FGTileMgr : public SGSubsystem {
private:
/// lat and lon are expected to be in degrees.
bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0);
- // Load a model for a tile
- osg::Node* loadTileModel(const std::string& modelPath, bool cacheModel);
-
// Returns true if tiles around current view position have been loaded
bool isSceneryLoaded();
};