Changeset 352


Ignore:
Timestamp:
Apr 21, 2012, 5:28:24 PM (7 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
3 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");
  • experimental/distortionNG/extViewer.h

    r350 r352  
    3737
    3838                /** 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());
    4040
    4141                void setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, osg::StateSet* stateset, unsigned int screenNum=0);
  • experimental/distortionNG/main.cpp

    r350 r352  
    3535#include <osgGA/AnimationPathManipulator>
    3636#include <osgGA/TerrainManipulator>
     37
     38#include "DistortionManipulator.h"
     39
    3740int main(int argc, char** argv)
    3841{
     
    4851                return -1;
    4952        }
    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
    5363        // set up the camera manipulators.
    5464    {
     
    7787    }
    7888
     89        // Add the distortion manipulator
     90        osgViewer::DistortionManipulator* distManip = new osgViewer::DistortionManipulator();
     91        distManip->setDistortionSet(_distortionSet);
     92        viewer.addEventHandler(distManip);
    7993
    8094    // add the state manipulator
Note: See TracChangeset for help on using the changeset viewer.