Changeset 367
- Timestamp:
- May 31, 2012, 10:11:55 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r361 r367 88 88 OSG_ALWAYS<<"ea.getYmax()="<<ea.getYmax()<<std::endl; 89 89 90 91 90 92 if(activeDistortionMode == MESH) 91 93 { -
experimental/distortionNG/ReaderWriterDist.cpp
r366 r367 25 25 // Get ReaderWriter 26 26 rw = osgDB::Registry::instance()->getReaderWriterForExtension("osgt"); 27 28 27 } 29 28 30 ReaderWriterDist:: ReadResult ReaderWriterDist::readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const29 ReaderWriterDist::Options* ReaderWriterDist::prepareReading( ReadResult& result, std::string& fileName, std::ios::openmode& mode, const Options* options ) const 31 30 { 32 std::string ext = osgDB::getLowerCaseFileExtension( file ); 33 if( !acceptsExtension(ext) ) 34 return ReadResult::FILE_NOT_HANDLED; 31 std::string ext = osgDB::getLowerCaseFileExtension( fileName ); 32 if ( !acceptsExtension(ext) ) 33 { 34 result = ReadResult::FILE_NOT_HANDLED; 35 return 0; 36 } 37 fileName = osgDB::findDataFile( fileName, options ); 38 if ( fileName.empty() ) 39 { 40 result = ReadResult::FILE_NOT_FOUND; 41 return 0; 42 } 35 43 36 // check if file exists 37 std::string fileName = osgDB::findDataFile( file, options ); 38 if( fileName.empty() ) 39 return ReadResult::FILE_NOT_FOUND; 44 osg::ref_ptr<Options> local_opt = options ? 45 static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options; 46 local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)); 40 47 41 std::ifstream stream( fileName.c_str(), std::ios::in );42 if (!stream) return ReadResult::ERROR_IN_READING_FILE; 43 return readNode( stream, options);48 mode |= std::ios::binary; 49 50 return local_opt.release(); 44 51 } 45 52 46 ReaderWriterDist::ReadResult ReaderWriterDist:: readNode( std::istream& fin, const osgDB::ReaderWriter::Options* options ) const 53 ReaderWriterDist::ReadResult ReaderWriterDist::readObject( const std::string& file, const Options* options) const 54 { 55 ReadResult result = ReadResult::FILE_LOADED; 56 std::string fileName = file; 57 std::ios::openmode mode = std::ios::in; 58 Options* local_opt = prepareReading( result, fileName, mode, options ); 59 if ( !result.success() ) return result; 60 61 osgDB::ifstream istream( fileName.c_str(), mode ); 62 return readObject( istream, local_opt ); 63 } 64 65 ReaderWriterDist::ReadResult ReaderWriterDist::readObject( std::istream& fin, const Options* options ) const 47 66 { 48 67 if ( rw ) … … 56 75 OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to convert stream to node" << std::endl; 57 76 } 58 else59 OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to get ReaderWriter for internally used extension" << std::endl;77 OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to get ReaderWriter for internally used extension" << std::endl; 78 return( ReadResult::NOT_IMPLEMENTED ); 60 79 } 61 80 62 ReaderWriterDist:: WriteResult writeNode( const osg::Node& node, const std::string& fileName, const Options* options ) const81 ReaderWriterDist::Options* ReaderWriterDist::prepareWriting( WriteResult& result, const std::string& fileName, std::ios::openmode& mode, const Options* options ) const 63 82 { 64 std::string ext = osgDB::getLowerCaseFileExtension( file ); 65 if( !acceptsExtension(ext) ) 66 return WriteResult::FILE_NOT_HANDLED; 83 std::string ext = osgDB::getFileExtension( fileName ); 84 if ( !acceptsExtension(ext) ) result = WriteResult::FILE_NOT_HANDLED; 67 85 68 std::ifstream stream( fileName.c_str(), std::ios::in ); 69 if (!stream) return ReadResult::ERROR_IN_READING_FILE; 70 return readNode( stream, options ); 71 // ------------------ 72 WriteResult result = WriteResult::FILE_SAVED; 73 std::ios::openmode mode = std::ios::out; 74 osg::ref_ptr<Options> local_opt = prepareWriting( result, fileName, mode, options ); 75 if ( !result.success() ) return result; 86 osg::ref_ptr<Options> local_opt = options ? 87 static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options; 88 local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName)); 76 89 77 osgDB::ofstream fout( fileName.c_str(), mode ); 78 if ( !fout ) return WriteResult::ERROR_IN_WRITING_FILE; 90 mode |= std::ios::binary; 79 91 80 result = writeNode( node, fout, local_opt.get() ); 81 fout.close(); 82 return result; 92 return local_opt.release(); 83 93 } 84 94 85 ReaderWriterDist::WriteResult writeNode( const osg::Node& node, std::ostream& fout, const Options* options ) const 95 ReaderWriterDist::WriteResult ReaderWriterDist::writeObject( const osg::Object& object, const std::string& fileName, const osgDB::ReaderWriter::Options* options ) const 96 { 97 WriteResult result = WriteResult::FILE_SAVED; 98 std::ios::openmode mode = std::ios::out; 99 osg::ref_ptr<Options> local_opt = prepareWriting( result, fileName, mode, options ); 100 if ( !result.success() ) return result; 101 102 osgDB::ofstream fout( fileName.c_str(), mode ); 103 if ( !fout ) return WriteResult::ERROR_IN_WRITING_FILE; 104 105 result = writeObject( object, fout, local_opt.get() ); 106 fout.close(); 107 return result; 108 } 109 110 ReaderWriterDist::WriteResult ReaderWriterDist::writeObject( const osg::Object& object, std::ostream& fout, const osgDB::ReaderWriter::Options* options ) const 86 111 { 87 112 if ( rw ) 88 113 { 89 osgDB::ReaderWriter::WriteResult wr = rw->writeObject( node, fout, writeOptions );114 osgDB::ReaderWriter::WriteResult wr = rw->writeObject( object, fout, writeOptions ); 90 115 if (wr.success() ) 91 116 { … … 96 121 } 97 122 OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to get ReaderWriter for internally used extension" << std::endl; 123 return( WriteResult::NOT_IMPLEMENTED ); 98 124 } 99 125 -
experimental/distortionNG/ReaderWriterDist.h
r366 r367 8 8 #include <osgDB/Registry> 9 9 #include <osgDB/ReadFile> 10 #include <osgDB/WriteFile> 11 #include <stdlib.h> 10 12 11 #include "ModificationVisitor.h"12 13 13 14 class ReaderWriterDist : public osgDB::ReaderWriter … … 17 18 18 19 virtual const char* className() const { return "distortion set loader"; }; 19 virtual ReadResult readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const; 20 virtual ReadResult readNode( std::istream& fin, const osgDB::ReaderWriter::Options* options ) const; 21 virtual WriteResult writeNode( const osg::Node& node, const std::string& fileName, const osgDB::ReaderWriter::Options* options ) const; 22 virtual WriteResult writeNode( const osg::Node& node, std::ostream& fout, const osgDB::ReaderWriter::Options* options ) const; 20 Options* prepareReading( ReadResult& result, std::string& fileName, std::ios::openmode& mode, const Options* options ) const; 21 Options* prepareWriting( WriteResult& result, const std::string& fileName, std::ios::openmode& mode, const Options* options ) const; 22 virtual ReadResult readObject( const std::string& file, const osgDB::ReaderWriter::Options* options) const; // passes the call to the stream function 23 virtual ReadResult readObject( std::istream& fin, const osgDB::ReaderWriter::Options* options ) const; // passes the call to the readwriter defined in the ctor 24 virtual WriteResult writeObject( const osg::Object& object, const std::string& fileName, const osgDB::ReaderWriter::Options* options ) const; // passes the call to the stream function 25 virtual WriteResult writeObject( const osg::Object& object, std::ostream& fout, const osgDB::ReaderWriter::Options* options ) const; // passes the call to the readwriter defined in the ctor 23 26 24 27 -
experimental/distortionNG/main.cpp
r366 r367 164 164 * - Mesh Dimensions (rows, columns) 165 165 * - Mesh Type (GLenum QUAD_STRIP, ...) 166 * - Mesh Coordinates [0-1]166 * - Mesh Coordinates [0-1] 167 167 * - Texture Coordinates [0-1] 168 168 * - textureUnit for Scene RTT (z.B.: 0) -
experimental/distortionNG/osgdb_dist.vcproj
r365 r367 85 85 LinkLibraryDependencies="false" 86 86 AdditionalOptions=" /STACK:10000000 /machine:X86 /debug" 87 AdditionalDependencies=" $(NOINHERIT) kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ..\..\..\lib\OpenThreadsd.lib ..\..\..\lib\osgd.lib ..\..\..\lib\osgDBd.lib ..\..\..\lib\osgUtild.lib opengl32.lib ..\..\..\lib\osgd.lib ..\..\..\lib\OpenThreadsd.lib D:\OpenSceneGraph\3rdParty_x86_x64\x86\lib\zlibD.lib opengl32.lib"88 OutputFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1. 0\osgdb_distd.dll"87 AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib OpenThreadsd.lib osgd.lib osgDBd.lib osgUtild.lib opengl32.lib D:\OpenSceneGraph\3rdParty_x86_x64\x86\lib\zlibD.lib $(NOINHERIT)" 88 OutputFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.3\osgdb_distd.dll" 89 89 Version="0.0" 90 90 LinkIncremental="2" 91 AdditionalLibraryDirectories=" "91 AdditionalLibraryDirectories=""$(OSG_ROOT)\lib\"" 92 92 GenerateDebugInformation="true" 93 93 ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_distd.pdb" … … 182 182 LinkLibraryDependencies="false" 183 183 AdditionalOptions=" /STACK:10000000 /machine:X86" 184 AdditionalDependencies=" $(NOINHERIT) kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ..\..\..\lib\OpenThreads.lib ..\..\..\lib\osg.lib ..\..\..\lib\osgDB.lib ..\..\..\lib\osgUtil.lib opengl32.lib ..\..\..\lib\osg.lib ..\..\..\lib\OpenThreads.lib D:\OpenSceneGraph\3rdParty_x86_x64\x86\lib\zlib.lib opengl32.lib"185 OutputFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1. 0\osgdb_dist.dll"184 AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib OpenThreads.lib osg.lib osgDB.lib osgUtil.lib opengl32.lib D:\OpenSceneGraph\3rdParty_x86_x64\x86\lib\zlib.lib $(NOINHERIT)" 185 OutputFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.3\osgdb_dist.dll" 186 186 Version="0.0" 187 187 LinkIncremental="1" 188 AdditionalLibraryDirectories=" "188 AdditionalLibraryDirectories=""$(OSG_ROOT)\lib\"" 189 189 ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_dist.pdb" 190 190 ImportLibrary="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\lib\osgPlugins-3.1.0\osgdb_dist.lib" … … 282 282 Version="0.0" 283 283 LinkIncremental="1" 284 AdditionalLibraryDirectories=" "284 AdditionalLibraryDirectories=""$(OSG_ROOT)\lib\"" 285 285 ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_dists.pdb" 286 286 ImportLibrary="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\lib\osgPlugins-3.1.0\osgdb_dists.lib" … … 379 379 Version="0.0" 380 380 LinkIncremental="2" 381 AdditionalLibraryDirectories=" "381 AdditionalLibraryDirectories=""$(OSG_ROOT)\lib\"" 382 382 GenerateDebugInformation="true" 383 383 ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_distrd.pdb"
Note: See TracChangeset
for help on using the changeset viewer.