Changeset 359


Ignore:
Timestamp:
Apr 22, 2012, 9:33:36 AM (7 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r357 r359  
    240240    // distortion correction set up.
    241241    {
    242                 osg::Geode* geode = new osg::Geode();
     242                osg::ref_ptr<osg::Switch> root = _distortionSet->getDistortionInternals();
     243                osg::Geode* meshGeode = new osg::Geode();
     244                root->addChild(meshGeode, true);        // Child #0  (adds mesh,shader,.. so camera renders mesh (and  thus render the scene))
     245               
    243246
    244247                // new we need to add the scene texture to the mesh, we do so by creating a
    245248        // StateSet to contain the Texture StateAttribute.
    246             osg::StateSet* stateset = geode->getOrCreateStateSet();
     249            osg::StateSet* stateset = meshGeode->getOrCreateStateSet();
    247250        stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitScene(), sceneTexture,osg::StateAttribute::ON);
    248251        stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
     
    250253                osg::TexMat* texmat = new osg::TexMat;
    251254            texmat->setScaleByTextureRectangleSize(true);
    252         stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
    253 
    254                 setUpIntensityMapBlending(_distortionSet, stateset, screenNum);
     255        stateset->setTextureAttributeAndModes(_distortionSet->getTexUnitScene(), texmat, osg::StateAttribute::ON);
    255256
    256257                osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, projectorMatrix);
    257                 geode->addDrawable(distortionMesh);
     258                meshGeode->addDrawable(distortionMesh);
     259
     260                setUpIntensityMapBlending(_distortionSet, screenNum);
    258261
    259262        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
     
    273276        camera->setViewMatrix(osg::Matrix::identity());
    274277
    275                 osg::ref_ptr<osg::Switch> root = _distortionSet->getDistortionInternals();
    276                 root->addChild(geode, true);    // Child #0  (adds mesh,shader,.. so camera renders mesh (and  thus render the scene))
    277278                camera->addChild(root);
    278 
    279279                _distortionSet->setDistortionCamera( camera );
    280280
    281281                // Ensure selector is visible:
    282                 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
    283                 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
     282                meshGeode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
     283                meshGeode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
    284284               
    285285        camera->setName("Dist Cam");
     
    289289}
    290290
    291 void extViewer::setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, osg::StateSet* stateset, unsigned int screenNum)
     291void extViewer::setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, unsigned int screenNum)
    292292{
    293293        osg::Image* intensityMap = _distortionSet->getIntensityMap();
     294        osg::StateSet* stateset = _distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->getOrCreateStateSet();
     295
    294296        if(intensityMap == NULL)        return;
    295297
  • experimental/distortionNG/extViewer.h

    r352 r359  
    3939        void setUpViewForManualDistortion(osgViewer::DistortionSet* distSet, unsigned int screenNum=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
    4040
    41                 void setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, osg::StateSet* stateset, unsigned int screenNum=0);
     41                void setUpIntensityMapBlending(osgViewer::DistortionSet* distSet, unsigned int screenNum=0);
    4242                void setUpIntensityMapBlending(std::string intensityMap);
    4343
  • experimental/distortionNG/main.cpp

    r357 r359  
    174174 * distortionManipulator                                abgeleitet von osgGA::GUIEventHandler
    175175 *                                                                              Grundfunktionen:
    176  *                                                      [.]             - Key to Show Distortion Mesh / Intensity Map / none
     176 *                                                      [done|.|.]      - Key to Show Distortion Mesh / Intensity Map / none
    177177 *                                                                              - Key to Save distortion Container  - via plugin
    178178 *                                                      [.]             - Key to toggle MANUAL mode between blending und distortion setup
Note: See TracChangeset for help on using the changeset viewer.