#include <simgear/props/props_io.hxx>
#include <simgear/scene/model/model.hxx>
#include <simgear/scene/model/ModelRegistry.hxx>
+#include <simgear/misc/ResourceManager.hxx>
#include "SGPagedLOD.hxx"
#include "SGReaderWriterXML.hxx"
osgDB::RegisterReaderWriterProxy<SGReaderWriterXML> g_readerWriter_XML_Proxy;
ModelRegistryCallbackProxy<LoadOnlyCallback> g_xmlCallbackProxy("xml");
-\fSGPropertyNode_ptr SGModelLib::static_propRoot;
+SGPropertyNode_ptr SGModelLib::static_propRoot;
SGModelLib::panel_func SGModelLib::static_panelFunc = NULL;
-SGModelLib::resolve_func SGModelLib::static_resolver = NULL;
////////////////////////////////////////////////////////////////////////
// Implementation of SGModelLib.
////////////////////////////////////////////////////////////////////////
-void SGModelLib::init(const string &root_dir)
+void SGModelLib::init(const string &root_dir, SGPropertyNode* root)
{
osgDB::Registry::instance()->getDataFilePathList().push_front(root_dir);
+ static_propRoot = root;
+ SGPagedLOD::setRenderingCache(root->getBoolValue("/sim/rendering/cache",true));
}
-void SGModelLib::setPropRoot(SGPropertyNode* root)
-{
- static_propRoot = root;
-}
-
void SGModelLib::setPanelFunc(panel_func pf)
{
static_panelFunc = pf;
}
-void SGModelLib::setResolveFunc(resolve_func rf)
-{
- static_resolver = rf;
-}
-
std::string SGModelLib::findDataFile(const std::string& file,
const osgDB::ReaderWriter::Options* opts,
SGPath currentPath)
{
- // if we have a valid current path, first attempt to resolve relative
- // to that path
- if (currentPath.exists()) {
- SGPath p = currentPath;
- p.append(file);
- if (p.exists()) {
- return p.str();
- }
- }
-
- // next try the resolve function if one has been defined
- if (static_resolver) {
- SGPath p = static_resolver(file);
- if (p.exists()) {
- return p.str();
- }
+ SGPath p = ResourceManager::instance()->findPath(file, currentPath);
+ if (p.exists()) {
+ return p.str();
}
-
+
// finally hand on to standard OSG behaviour
return osgDB::findDataFile(file, opts);
}