1
0
Fork 0

Set the key SGModelLib callback to make aircraft-dir OSG loading work.

This commit is contained in:
James Turner 2010-07-29 01:07:32 +01:00
parent ab495d1370
commit 8e5f3ac8a3
3 changed files with 21 additions and 18 deletions

View file

@ -122,11 +122,7 @@ FGTextureManager::createTexture (const string &relativePath, bool staticTexture)
{ {
osg::Texture2D* texture = _textureMap[relativePath].get(); osg::Texture2D* texture = _textureMap[relativePath].get();
if (texture == 0) { if (texture == 0) {
SG_LOG( SG_COCKPIT, SG_DEBUG, SGPath tpath = globals->resolve_aircraft_path(relativePath);
"Texture " << relativePath << " does not yet exist" );
SGPath tpath(globals->get_fg_root());
tpath.append(relativePath);
texture = SGLoadTexture2D(staticTexture, tpath); texture = SGLoadTexture2D(staticTexture, tpath);
_textureMap[relativePath] = texture; _textureMap[relativePath] = texture;

View file

@ -342,7 +342,7 @@ static void fgMainLoop( void ) {
// implementation is an AI model and depends on that // implementation is an AI model and depends on that
globals->get_multiplayer_mgr()->Update(); globals->get_multiplayer_mgr()->Update();
#if ENABLE_ATCDCL #if ENABLE_ATCDCL
// Run ATC subsystem // Run ATC subsystem
if (fgGetBool("/sim/atc/enabled")) if (fgGetBool("/sim/atc/enabled"))
globals->get_ATC_mgr()->update(delta_time_sec); 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 ); 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 // 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 ); globals->set_matlib( new SGMaterialLib );
simgear::SGModelLib::init(globals->get_fg_root()); 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. // Initialize the TG scenery subsystem.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View file

@ -22,15 +22,6 @@
using std::vector; using std::vector;
using namespace simgear; 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. // Global functions.
@ -39,7 +30,7 @@ osg::Node* load_panel(SGPropertyNode *n)
osg::Node * osg::Node *
fgLoad3DModelPanel(const string &path, SGPropertyNode *prop_root) 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) if (node)
node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); node->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
return node; return node;