Changeset 361 for experimental/distortionNG/extViewer.cpp
- Timestamp:
- Apr 22, 2012, 4:51:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r360 r361 41 41 // Add help for command-line options here 42 42 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 46 71 } 47 72 … … 236 261 237 262 addSlave(camera.get(), _distortionSet->getProjectionOffset(), _distortionSet->getViewOffset() ); 263 238 264 } 239 265 … … 332 358 stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitIntensityMap(), intensityMapTexture, osg::StateAttribute::ON); 333 359 334 // create shader sfor blending360 // create shader for blending 335 361 osg::Program* IntensityMapProgram = new osg::Program; 336 362 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 ); 343 370 stateset->addUniform( new osg::Uniform("sceneTexture", (int)_distortionSet->getTexUnitScene()) ); 344 371 stateset->addUniform( new osg::Uniform("intensityMapTexture", (int)_distortionSet->getTexUnitIntensityMap()) );
Note: See TracChangeset
for help on using the changeset viewer.