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();
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;

View file

@ -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,7 +587,9 @@ 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.

View file

@ -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;