Ignore:
Timestamp:
Apr 21, 2012, 5:28:24 PM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r351 r352  
    3232#include <osgUtil/SmoothingVisitor>
    3333
    34 #include "DistortionManipulator.h"
    3534
    3635extViewer::extViewer() : Viewer()
     
    138137
    139138
    140 void extViewer::setUpViewForManualDistortion(unsigned int screenNum, osg::Image* intensityMap, const osg::Matrixd& projectorMatrix)
     139void extViewer::setUpViewForManualDistortion(osgViewer::DistortionSet* distSet, unsigned int screenNum, const osg::Matrixd& projectorMatrix)
    141140{
    142141        OSG_INFO<<"View::setUpViewForManualDistortion(sn="<<screenNum<<")"<<std::endl;
    143142
    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;
    152149
    153150    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
     
    238235        camera->attach(osg::Camera::COLOR_BUFFER, sceneTexture);
    239236
    240         addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
     237        addSlave(camera.get(), _distortionSet->getProjectionOffset(), _distortionSet->getViewOffset() );
    241238    }
    242239
     
    276273        camera->setViewMatrix(osg::Matrix::identity());
    277274
     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
    278279                // 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) );
    298291
    299292        camera->setName("Dist Cam");
Note: See TracChangeset for help on using the changeset viewer.