Changeset 352 for experimental
- Timestamp:
- Apr 21, 2012, 5:28:24 PM (13 years ago)
- Location:
- experimental/distortionNG
- Files:
-
- 3 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"); -
experimental/distortionNG/extViewer.h
r350 r352 37 37 38 38 /** Convenience method for projection on curved screens using a slave camera rendering scene and a second camera doing distortion correction to present on a nonplaner display.*/ 39 void setUpViewForManualDistortion( unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());39 void setUpViewForManualDistortion(osgViewer::DistortionSet* distSet, unsigned int screenNum=0, const osg::Matrixd& projectorMatrix = osg::Matrixd()); 40 40 41 41 void setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, osg::StateSet* stateset, unsigned int screenNum=0); -
experimental/distortionNG/main.cpp
r350 r352 35 35 #include <osgGA/AnimationPathManipulator> 36 36 #include <osgGA/TerrainManipulator> 37 38 #include "DistortionManipulator.h" 39 37 40 int main(int argc, char** argv) 38 41 { … … 48 51 return -1; 49 52 } 50 51 viewer.setUpViewForManualDistortion(0, intMap); 52 53 // Create DistortionSet 54 osg::ref_ptr<osgViewer::DistortionSet> _distortionSet = new osgViewer::DistortionSet(); 55 _distortionSet->setIntensityMap( intMap ); 56 _distortionSet->setDistortionMeshRows( 20 ); 57 _distortionSet->setDistortionMeshColumns( 20 ); 58 59 viewer.setUpViewForManualDistortion(_distortionSet, 0); 60 61 62 53 63 // set up the camera manipulators. 54 64 { … … 77 87 } 78 88 89 // Add the distortion manipulator 90 osgViewer::DistortionManipulator* distManip = new osgViewer::DistortionManipulator(); 91 distManip->setDistortionSet(_distortionSet); 92 viewer.addEventHandler(distManip); 79 93 80 94 // add the state manipulator
Note: See TracChangeset
for help on using the changeset viewer.