|
osgEarth 2.1.1
|
Public Member Functions | |
| OSGTerrainEnginePlugin () | |
| virtual const char * | className () |
| virtual bool | acceptsExtension (const std::string &extension) const |
| virtual ReadResult | readObject (const std::string &uri, const Options *options) const |
| virtual ReadResult | readNode (const std::string &uri, const Options *options) const |
Definition at line 31 of file Plugin.cpp.
| OSGTerrainEnginePlugin::OSGTerrainEnginePlugin | ( | ) | [inline] |
Definition at line 34 of file Plugin.cpp.
{}
| virtual bool OSGTerrainEnginePlugin::acceptsExtension | ( | const std::string & | extension | ) | const [inline, virtual] |
Definition at line 41 of file Plugin.cpp.
{
return
osgDB::equalCaseInsensitive( extension, "osgearth_engine_osgterrain" ) ||
osgDB::equalCaseInsensitive( extension, "osgearth_osgterrain_tile" );
}
| virtual const char* OSGTerrainEnginePlugin::className | ( | ) | [inline, virtual] |
Definition at line 36 of file Plugin.cpp.
{
return "osgEarth osgTerrain Engine";
}
| virtual ReadResult OSGTerrainEnginePlugin::readNode | ( | const std::string & | uri, |
| const Options * | options | ||
| ) | const [inline, virtual] |
Definition at line 68 of file Plugin.cpp.
{
static int s_tileCount = 0;
static double s_tileTime = 0.0;
static osg::Timer_t s_startTime;
if ( "osgearth_osgterrain_tile" == osgDB::getFileExtension(uri) )
{
if ( s_tileCount == 0 )
s_startTime = osg::Timer::instance()->tick();
// See if the filename starts with server: and strip it off. This will trick OSG
// into passing in the filename to our plugin instead of using the CURL plugin if
// the filename contains a URL. So, if you want to read a URL, you can use the
// following format: osgDB::readNodeFile("server:http://myserver/myearth.earth").
// This should only be necessary for the first level as the other files will have
// a tilekey prepended to them.
if ((uri.length() > 7) && (uri.substr(0, 7) == "server:"))
return readNode(uri.substr(7), options);
// parse the tile key and engine ID:
std::string tileDef = osgDB::getNameLessExtension(uri);
unsigned int lod, x, y, engineID;
sscanf(tileDef.c_str(), "%d_%d_%d.%d", &lod, &x, &y, &engineID);
// find the appropriate engine:
osg::ref_ptr<OSGTerrainEngineNode> engineNode;
OSGTerrainEngineNode::getEngineByUID( (UID)engineID, engineNode );
if ( engineNode.valid() )
{
osg::Timer_t start = osg::Timer::instance()->tick();
// assemble the key and create the node:
const Profile* profile = engineNode->getMap()->getProfile();
TileKey key( lod, x, y, profile );
osg::Node* node = engineNode->createNode( key );
// Blacklist the tile if we couldn't load it
if ( !node )
{
OE_DEBUG << LC << "Blacklisting " << uri << std::endl;
osgEarth::Registry::instance()->blacklist( uri );
return ReadResult::FILE_NOT_FOUND;
}
return ReadResult( node, ReadResult::FILE_LOADED );
}
else
{
return ReadResult::FILE_NOT_FOUND;
}
}
else
{
return ReadResult::FILE_NOT_HANDLED;
}
}
Here is the call graph for this function:| virtual ReadResult OSGTerrainEnginePlugin::readObject | ( | const std::string & | uri, |
| const Options * | options | ||
| ) | const [inline, virtual] |
Definition at line 48 of file Plugin.cpp.
{
if ( "osgearth_engine_osgterrain" == osgDB::getFileExtension( uri ) )
{
if ( "earth" == osgDB::getNameLessExtension( osgDB::getFileExtension( uri ) ) )
{
return readNode( uri, options );
}
else
{
OSGTerrainOptions terrainOpts;
return ReadResult( new OSGTerrainEngineNode() );
}
}
else
{
return readNode( uri, options );
}
}
1.7.3