Changeset 352 for experimental/distortionNG/extViewer.cpp
- Timestamp:
- Apr 21, 2012, 5:28:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r351 r352 32 32 #include <osgUtil/SmoothingVisitor> 33 33 34 #include "DistortionManipulator.h"35 34 36 35 extViewer::extViewer() : Viewer() … … 138 137 139 138 140 void extViewer::setUpViewForManualDistortion( unsigned int screenNum, osg::Image* intensityMap, const osg::Matrixd& projectorMatrix)139 void extViewer::setUpViewForManualDistortion(osgViewer::DistortionSet* distSet, unsigned int screenNum, const osg::Matrixd& projectorMatrix) 141 140 { 142 141 OSG_INFO<<"View::setUpViewForManualDistortion(sn="<<screenNum<<")"<<std::endl; 143 142 144 // Create DistortionSet 145 _distortionSet = new osgViewer::DistortionSet(); 146 _distortionSet->setIntensityMap( intensityMap ); 147 _distortionSet->setDistortionMeshRows( 20 ); 148 _distortionSet->setDistortionMeshColumns( 20 ); 149 150 151 143 if(distSet == NULL) 144 { 145 OSG_NOTICE<<"Error, no DistortionSet specified, cannot setup distortion."<<std::endl; 146 return; 147 } 148 _distortionSet = distSet; 152 149 153 150 osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); … … 238 235 camera->attach(osg::Camera::COLOR_BUFFER, sceneTexture); 239 236 240 addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());237 addSlave(camera.get(), _distortionSet->getProjectionOffset(), _distortionSet->getViewOffset() ); 241 238 } 242 239 … … 276 273 camera->setViewMatrix(osg::Matrix::identity()); 277 274 275 osg::ref_ptr<osg::Group> root = new osg::Group; 276 root->addChild(geode); // add mesh to root so camera renders mesh (and thus render the scene) 277 camera->addChild(root); 278 278 279 // selector 279 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 280 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) ); 281 osg::ref_ptr<distortionHandler> selectorHandler = new distortionHandler( camera, distortionMesh ); 282 osg::ref_ptr<osg::Group> root = new osg::Group; 283 root->addChild(geode); 284 osg::Geode* selectorHighlighter = selectorHandler->createVertexHighlighter(); 285 selectorHighlighter->setCullingActive(false); // disable the culling for the selector, otherwise the selector is culled away on the edge. 286 root->addChild(selectorHighlighter); 287 addEventHandler( selectorHandler.get() ); 288 camera->addChild(root); 289 // Avoid that the highlighter is culled away 290 osg::CullSettings::CullingMode mode = camera->getCullingMode(); 291 camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) ); 292 293 // Add the distortionHandler 294 osgViewer::DistortionManipulator* distManip = new osgViewer::DistortionManipulator(); 295 distManip->setDistortionSet(_distortionSet); 296 addEventHandler(distManip); 297 280 //geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); 281 //geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) ); 282 //osg::ref_ptr<distortionHandler> selectorHandler = new distortionHandler( camera, distortionMesh ); 283 //osg::Geode* selectorHighlighter = selectorHandler->createVertexHighlighter(); 284 //selectorHighlighter->setCullingActive(false); // disable the culling for the selector, otherwise the selector is culled away on the edge. 285 //root->addChild(selectorHighlighter); 286 //addEventHandler( selectorHandler.get() );// should be in main.cpp 287 288 //// Avoid that the highlighter is culled away 289 //osg::CullSettings::CullingMode mode = camera->getCullingMode(); 290 //camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) ); 298 291 299 292 camera->setName("Dist Cam");
Note: See TracChangeset
for help on using the changeset viewer.