#include "ReaderWriterTerrainMod.h" ReaderWriterTerrainMod::ReaderWriterTerrainMod() { supportsExtension( "terrainmod", "Terrain modification pseudo loader"); } //ReaderWriterTerrainMod::~ReaderWriterTerrainMod() //{ //} ReaderWriterTerrainMod::ReadResult ReaderWriterTerrainMod::readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension( file ); if( !acceptsExtension(ext) ) return ReadResult::FILE_NOT_HANDLED; std::string fileName = osgDB::findDataFile( file, options ); if( fileName.empty() ) return ReadResult::FILE_NOT_FOUND; /*std::ifstream( fileName.c_str(), std::ios::in ); if( !stream ) return ReadResult::ERROR_IN_READING_FILE; return readNode( stream, options );*/ // Strip the pseudo-loader extension std::string realName = osgDB::getNameLessExtension( fileName ); // Load real file osg::Node *node = osgDB::readNodeFile( realName, options ); if( !node ) { // propagate the read failure upwards OSG_WARN << "Subfile \"" << realName << "\" could not be loaded" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // Modify Node return node; } // Add ourself to the Registry to instantiate the reader/writer. REGISTER_OSGPLUGIN(terrainmod, ReaderWriterTerrainMod)