From 8e5f3ac8a333a971d7f8104a387426c3bc47a014 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 29 Jul 2010 01:07:32 +0100 Subject: [PATCH] Set the key SGModelLib callback to make aircraft-dir OSG loading work. --- src/Cockpit/panel.cxx | 6 +----- src/Main/main.cxx | 22 +++++++++++++++++++--- src/Model/model_panel.cxx | 11 +---------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index be2f12570..9c39626ee 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -122,11 +122,7 @@ FGTextureManager::createTexture (const string &relativePath, bool staticTexture) { osg::Texture2D* texture = _textureMap[relativePath].get(); if (texture == 0) { - SG_LOG( SG_COCKPIT, SG_DEBUG, - "Texture " << relativePath << " does not yet exist" ); - SGPath tpath(globals->get_fg_root()); - tpath.append(relativePath); - + SGPath tpath = globals->resolve_aircraft_path(relativePath); texture = SGLoadTexture2D(staticTexture, tpath); _textureMap[relativePath] = texture; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 07c10598a..789d80ce8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -342,7 +342,7 @@ static void fgMainLoop( void ) { // implementation is an AI model and depends on that globals->get_multiplayer_mgr()->Update(); -#if ENABLE_ATCDCL +#if ENABLE_ATCDCL // Run ATC subsystem if (fgGetBool("/sim/atc/enabled")) globals->get_ATC_mgr()->update(delta_time_sec); @@ -493,6 +493,20 @@ struct GeneralInitOperation : public GraphicsContextOperation SG_LOG ( SG_GENERAL, SG_INFO, "Depth buffer bits = " << tmp ); } }; + + +osg::Node* load_panel(SGPropertyNode *n) +{ + osg::Geode* geode = new osg::Geode; + geode->addDrawable(new FGPanelNode(n)); + return geode; +} + +SGPath resolve_path(const std::string& s) +{ + return globals->resolve_maybe_aircraft_path(s); +} + } // This is the top level master main function that is registered as @@ -573,8 +587,10 @@ static void fgIdleFunction ( void ) { //////////////////////////////////////////////////////////////////// globals->set_matlib( new SGMaterialLib ); simgear::SGModelLib::init(globals->get_fg_root()); - - + simgear::SGModelLib::setPropRoot(globals->get_props()); + simgear::SGModelLib::setResolveFunc(resolve_path); + simgear::SGModelLib::setPanelFunc(load_panel); + //////////////////////////////////////////////////////////////////// // Initialize the TG scenery subsystem. //////////////////////////////////////////////////////////////////// diff --git a/src/Model/model_panel.cxx b/src/Model/model_panel.cxx index eef538cb0..b18d1f164 100644 --- a/src/Model/model_panel.cxx +++ b/src/Model/model_panel.cxx @@ -22,15 +22,6 @@ using std::vector; using namespace simgear; - -static -osg::Node* load_panel(SGPropertyNode *n) -{ - osg::Geode* geode = new osg::Geode; - geode->addDrawable(new FGPanelNode(n)); - return geode; -} - //////////////////////////////////////////////////////////////////////// // Global functions. @@ -39,7 +30,7 @@ osg::Node* load_panel(SGPropertyNode *n) osg::Node * fgLoad3DModelPanel(const string &path, SGPropertyNode *prop_root) { - osg::Node* node = SGModelLib::loadModel(path, prop_root, load_panel); + osg::Node* node = SGModelLib::loadModel(path, prop_root); if (node) node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); return node;