#include "ReaderWriterDist.h" #include ReaderWriterDist::ReaderWriterDist() { supportsExtension( "dist", "distortion set loader"); extensionToAdd = ".dist"; } ReaderWriterDist::ReadResult ReaderWriterDist::readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const { // Check if its a valid file for this pseudo loader std::string ext = osgDB::getLowerCaseFileExtension( file ); if( !acceptsExtension(ext) ) return ReadResult::FILE_NOT_HANDLED; // Strip the pseudo-loader extension std::string realName = osgDB::getNameLessExtension( file ); // check if stripped file exists std::string fileName = osgDB::findDataFile( realName, options ); if( fileName.empty() ) return ReadResult::FILE_NOT_FOUND; // If options are available: Save it'S original KdTree Hint. Options::BuildKdTreesHint originalHint = Options::NO_PREFERENCE; if(options) { originalHint = options->getBuildKdTreesHint(); const_cast(options)->setBuildKdTreesHint(Options::DO_NOT_BUILD_KDTREES); } // Load real file osg::Node *node = osgDB::readNodeFile( fileName, options ); if( !node ) { // propagate the read failure upwards OSG_WARN << "Subfile \"" << fileName << "\" could not be loaded" << std::endl; return ReadResult::FILE_NOT_HANDLED; } return node; } // Add ourself to the Registry to instantiate the reader/writer. REGISTER_OSGPLUGIN(dist, ReaderWriterDist)