Changeset 252 for experimental
- Timestamp:
- Feb 21, 2011, 6:35:43 PM (14 years ago)
- Location:
- experimental/TerrainTest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/TerrainTest/ModificationVisitor.cpp
r251 r252 1 1 #include "ModificationVisitor.h" 2 2 3 ModificationVisitor::ModificationVisitor( )3 ModificationVisitor::ModificationVisitor(std::string extensionToSet) : _extensionToSet(extensionToSet) 4 4 { 5 5 setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ); … … 8 8 void ModificationVisitor::apply( osg::Node& node ) 9 9 { 10 OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: Node found"<< std::endl;10 //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: Node found: " << node.className() << std::endl; 11 11 traverse( node ); 12 12 } … … 14 14 void ModificationVisitor::apply( osg::PagedLOD& pNode ) 15 15 { 16 OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD found" << std::endl; 16 //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD found: " << pNode.className() << std::endl; 17 18 for( unsigned int i=0;i<pNode.getNumFileNames();i++) 19 { 20 //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child #" << i << std::endl; 21 if(pNode.getFileName(i)!="") 22 { 23 //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child Name pre: " << pNode.getFileName(i) << std::endl; 24 pNode.setFileName(i, pNode.getFileName(i)+_extensionToSet ); 25 //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child Name post: " << newFileName << std::endl; 26 } 27 } 28 17 29 traverse( pNode ); 18 30 } -
experimental/TerrainTest/ModificationVisitor.h
r251 r252 8 8 { 9 9 public: 10 ModificationVisitor( );10 ModificationVisitor(std::string extensionToSet); 11 11 virtual void apply( osg::Node& node ); 12 12 virtual void apply( osg::PagedLOD& pNode ); 13 14 private: 15 std::string _extensionToSet; 13 16 }; -
experimental/TerrainTest/ReaderWriterTerrainMod.cpp
r251 r252 4 4 { 5 5 supportsExtension( "terrainmod", "Terrain modification pseudo loader"); 6 7 std::string extensionToAdd = ".terrainmod"; 6 8 } 7 8 //ReaderWriterTerrainMod::~ReaderWriterTerrainMod()9 //{10 //}11 9 12 10 ReaderWriterTerrainMod::ReadResult ReaderWriterTerrainMod::readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const 13 11 { 12 // Check if its a valid file for this pseudo loader 14 13 std::string ext = osgDB::getLowerCaseFileExtension( file ); 15 14 if( !acceptsExtension(ext) ) 16 15 return ReadResult::FILE_NOT_HANDLED; 17 16 18 std::string fileName = osgDB::findDataFile( file, options ); 17 // Strip the pseudo-loader extension 18 std::string realName = osgDB::getNameLessExtension( file ); 19 20 // check if stripped file exists 21 std::string fileName = osgDB::findDataFile( realName, options ); 19 22 if( fileName.empty() ) 20 23 return ReadResult::FILE_NOT_FOUND; 21 24 22 // Strip the pseudo-loader extension23 std::string realName = osgDB::getNameLessExtension( fileName );24 25 25 // Load real file 26 osg::Node *node = osgDB::readNodeFile( realName, options );26 osg::Node *node = osgDB::readNodeFile( fileName, options ); 27 27 if( !node ) 28 28 { 29 29 // propagate the read failure upwards 30 OSG_WARN << "Subfile \"" << realName << "\" could not be loaded" << std::endl;30 OSG_WARN << "Subfile \"" << fileName << "\" could not be loaded" << std::endl; 31 31 return ReadResult::FILE_NOT_HANDLED; 32 32 } 33 33 34 // Modify Node35 OSG_NOTIFY( osg::ALWAYS ) << "Doing modification in pseudoloader!" << std::endl;36 37 34 // Traverse through loaded graph, check for PagedLOD and modify all filenames of external references 38 ModificationVisitor modVisitor ;35 ModificationVisitor modVisitor(extensionToAdd); 39 36 node->accept( modVisitor ); 40 41 std::string extensionToAdd = ".terrainmod";42 43 37 44 38 return node; 45 39 } 46 40 47 48 41 // Add ourself to the Registry to instantiate the reader/writer. 49 42 REGISTER_OSGPLUGIN(terrainmod, ReaderWriterTerrainMod)
Note: See TracChangeset
for help on using the changeset viewer.