Ignore:
Timestamp:
Apr 22, 2012, 4:51:35 PM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r360 r361  
    4141        // Add help for command-line options here
    4242    arguments.getApplicationUsage()->addCommandLineOption("--distort","load distortion file and set up geometrical distortion for viewer. This includes blending");
    43     arguments.getApplicationUsage()->addCommandLineOption("--blend","Set up viewer vor simple blending CullDrawThreadPerContext threading model for viewer.");
    44 
    45         osgDB::Registry::instance()->addFileExtensionAlias("dist", "osgt");
     43    arguments.getApplicationUsage()->addCommandLineOption("--blend","Set up viewer for simple intensity map blending.");
     44
     45        std::string distortionSetFilename = "";
     46        std::string intensityMapFilename = "";
     47        while( arguments.read("--blend",intensityMapFilename) ) {}
     48        while( arguments.read("--distort",distortionSetFilename) ) {}
     49
     50        if( !intensityMapFilename.empty() )
     51        {
     52                OSG_ALWAYS<<"Pure blendmap setup with : "<<intensityMapFilename<<std::endl;
     53                setUpIntensityMapBlending(intensityMapFilename);
     54        }
     55        else if( !distortionSetFilename.empty() )
     56        {
     57                OSG_ALWAYS<<"Set up distortion by loaded distortionSet: "<<distortionSetFilename<<std::endl;
     58
     59                osg::Object* distSet = osgDB::readObjectFile( distortionSetFilename );
     60                if( distSet != NULL )
     61                {
     62                        OSG_ALWAYS<<"read distortionSet success"<<std::endl;
     63                        setUpViewForManualDistortion(static_cast<osgViewer::DistortionSet*>(distSet));
     64                }
     65                else
     66                {
     67                        OSG_ALWAYS<<"read distortionSet failed"<<std::endl;
     68                }
     69        }       
     70       
    4671}
    4772
     
    236261
    237262        addSlave(camera.get(), _distortionSet->getProjectionOffset(), _distortionSet->getViewOffset() );
     263
    238264    }
    239265
     
    332358    stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitIntensityMap(), intensityMapTexture, osg::StateAttribute::ON);
    333359
    334         // create shaders for blending
     360        // create shader for blending
    335361        osg::Program* IntensityMapProgram = new osg::Program;
    336362        IntensityMapProgram->setName( "intensityMapBlending" );
    337         osg::Shader* fShader = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shader.frag" );
    338         fShader->setName("intensityMapFragShader");
    339 
    340         if ( fShader )
    341         {
    342                 IntensityMapProgram->addShader( fShader );
     363        osg::Shader* shaderIntensityMap = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shaderIntensityMap.frag" );
     364        shaderIntensityMap->setName("shaderIntensityMap");
     365        _distortionSet->setShaderIntensityMap( shaderIntensityMap );
     366
     367        if ( shaderIntensityMap )
     368        {
     369                IntensityMapProgram->addShader( shaderIntensityMap );
    343370                stateset->addUniform( new osg::Uniform("sceneTexture", (int)_distortionSet->getTexUnitScene()) );
    344371                stateset->addUniform( new osg::Uniform("intensityMapTexture", (int)_distortionSet->getTexUnitIntensityMap()) );
Note: See TracChangeset for help on using the changeset viewer.