Changeset 367 for experimental


Ignore:
Timestamp:
May 31, 2012, 10:11:55 PM (13 years ago)
Author:
Torben Dannhauer
Message:

Dist-Plugin compiles, but not yet tested

Location:
experimental/distortionNG
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionManipulator.cpp

    r361 r367  
    8888                                OSG_ALWAYS<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
    8989
     90
     91
    9092                                if(activeDistortionMode == MESH)
    9193                                {
  • experimental/distortionNG/ReaderWriterDist.cpp

    r366 r367  
    2525        // Get ReaderWriter
    2626        rw = osgDB::Registry::instance()->getReaderWriterForExtension("osgt"); 
    27 
    2827}
    2928
    30 ReaderWriterDist::ReadResult ReaderWriterDist::readNode( const std::string& file, const osgDB::ReaderWriter::Options* options) const
     29ReaderWriterDist::Options* ReaderWriterDist::prepareReading( ReadResult& result, std::string& fileName, std::ios::openmode& mode, const Options* options ) const
    3130{
    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        }
    3543
    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));
    4047
    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();
    4451}
    4552
    46 ReaderWriterDist::ReadResult ReaderWriterDist:: readNode( std::istream& fin, const osgDB::ReaderWriter::Options* options ) const
     53ReaderWriterDist::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
     65ReaderWriterDist::ReadResult ReaderWriterDist::readObject( std::istream& fin, const Options* options ) const
    4766{
    4867        if ( rw )
     
    5675                        OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to convert stream to node" << std::endl;
    5776        }
    58         else
    59                 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 );
    6079}
    6180
    62 ReaderWriterDist::WriteResult writeNode( const osg::Node& node, const std::string& fileName, const Options* options ) const
     81ReaderWriterDist::Options* ReaderWriterDist::prepareWriting( WriteResult& result, const std::string& fileName, std::ios::openmode& mode, const Options* options ) const
    6382{
    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;
    6785
    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));
    7689
    77     osgDB::ofstream fout( fileName.c_str(), mode );
    78     if ( !fout ) return WriteResult::ERROR_IN_WRITING_FILE;
     90        mode |= std::ios::binary;
    7991
    80     result = writeNode( node, fout, local_opt.get() );
    81     fout.close();
    82     return result;
     92        return local_opt.release();
    8393}
    8494
    85 ReaderWriterDist::WriteResult writeNode( const osg::Node& node, std::ostream& fout, const Options* options ) const
     95ReaderWriterDist::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
     110ReaderWriterDist::WriteResult ReaderWriterDist::writeObject( const osg::Object& object, std::ostream& fout, const osgDB::ReaderWriter::Options* options ) const
    86111{
    87112        if ( rw )
    88113        {
    89                 osgDB::ReaderWriter::WriteResult wr = rw->writeObject( node, fout, writeOptions );
     114                osgDB::ReaderWriter::WriteResult wr = rw->writeObject( object, fout, writeOptions );
    90115                if (wr.success() )                     
    91116                {
     
    96121        }
    97122        OSG_NOTIFY( osg::WARN ) << "ERROR: Unable to get ReaderWriter for internally used extension" << std::endl;
     123        return( WriteResult::NOT_IMPLEMENTED );
    98124}
    99125
  • experimental/distortionNG/ReaderWriterDist.h

    r366 r367  
    88#include <osgDB/Registry>
    99#include <osgDB/ReadFile>
     10#include <osgDB/WriteFile>
     11#include <stdlib.h>
    1012
    11 #include "ModificationVisitor.h"
    1213
    1314class ReaderWriterDist : public osgDB::ReaderWriter
     
    1718
    1819        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
    2326
    2427
  • experimental/distortionNG/main.cpp

    r366 r367  
    164164 *                                                                              - Mesh Dimensions (rows, columns)
    165165 *                                                                              - Mesh Type (GLenum QUAD_STRIP, ...)
    166  *                                                                              - Mesh Coordinates [0-1]
     166 *                                                                              - Mesh Coordinates [0-1]
    167167 *                                                                              - Texture Coordinates [0-1]
    168168 *                                                                              - textureUnit for Scene RTT (z.B.: 0)
  • experimental/distortionNG/osgdb_dist.vcproj

    r365 r367  
    8585                                LinkLibraryDependencies="false"
    8686                                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"
    8989                                Version="0.0"
    9090                                LinkIncremental="2"
    91                                 AdditionalLibraryDirectories=""
     91                                AdditionalLibraryDirectories="&quot;$(OSG_ROOT)\lib\&quot;"
    9292                                GenerateDebugInformation="true"
    9393                                ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_distd.pdb"
     
    182182                                LinkLibraryDependencies="false"
    183183                                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"
    186186                                Version="0.0"
    187187                                LinkIncremental="1"
    188                                 AdditionalLibraryDirectories=""
     188                                AdditionalLibraryDirectories="&quot;$(OSG_ROOT)\lib\&quot;"
    189189                                ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_dist.pdb"
    190190                                ImportLibrary="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\lib\osgPlugins-3.1.0\osgdb_dist.lib"
     
    282282                                Version="0.0"
    283283                                LinkIncremental="1"
    284                                 AdditionalLibraryDirectories=""
     284                                AdditionalLibraryDirectories="&quot;$(OSG_ROOT)\lib\&quot;"
    285285                                ProgramDatabaseFile="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\bin\osgPlugins-3.1.0\osgdb_dists.pdb"
    286286                                ImportLibrary="D:\OpenSceneGraph\OpenSceneGraph-3.1.0_x86\lib\osgPlugins-3.1.0\osgdb_dists.lib"
     
    379379                                Version="0.0"
    380380                                LinkIncremental="2"
    381                                 AdditionalLibraryDirectories=""
     381                                AdditionalLibraryDirectories="&quot;$(OSG_ROOT)\lib\&quot;"
    382382                                GenerateDebugInformation="true"
    383383                                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.