Changeset 380


Ignore:
Timestamp:
Jun 14, 2012, 10:21:52 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/distortionNG
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionManipulator.cpp

    r379 r380  
    1818
    1919#include "DistortionManipulator.h"
     20#include "extViewer.h"
    2021
    2122#include <osgViewer/Viewer>
     
    3334
    3435
    35 DistortionManipulator::DistortionManipulator(DistortionSet* ds)
    36  : _highlightColor( osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) ), _distortionSet( ds )
     36DistortionManipulator::DistortionManipulator(extViewer* viewer, DistortionSet* ds)
     37 : _highlightColor( osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) ), _distortionSet( ds ), _viewer(viewer)
    3738{
    3839        activeSetupMode = DISABLED;
     
    258259                                //OSG_ALWAYS<<"Calling delegated class.."<<std::endl;
    259260                                _delegatedDistortionSetupStrategy->delegateDistortionSetup(_distortionSet);
    260                                 if( _distortionSet->isDirty() )
     261                                if( _distortionSet->isDirty() && _viewer.valid())
    261262                                {
    262                                         // todo: transfer matrixes into viewer camera.
     263                                        _viewer->updateDistortion();
    263264                                }
    264265                                //OSG_ALWAYS<<"..done"<<std::endl;
  • experimental/distortionNG/DistortionManipulator.h

    r372 r380  
    3131#include "DistortionSet.h"
    3232
     33class extViewer;
    3334
    3435namespace osgViewer {
     
    5859
    5960
    60         DistortionManipulator(DistortionSet* ds);
     61        DistortionManipulator(extViewer* viewer, DistortionSet* ds);
    6162        virtual ~DistortionManipulator();
    6263
     
    8990        osg::ref_ptr<osg::Geometry> _highlighter;
    9091    osg::observer_ptr<osg::Camera> _camera;
     92         osg::observer_ptr<extViewer> _viewer;
    9193        osg::Geometry* _distortionMesh;
    9294        const osg::Vec4 _highlightColor;
  • experimental/distortionNG/extViewer.cpp

    r370 r380  
    397397        setUpViewForManualDistortion(ds);
    398398}
     399
     400void extViewer::updateDistortion()
     401{
     402        if(!_distortionSet.valid())
     403        {
     404                osg::notify(osg::WARN) << "You cannot update the distortion without distortion set up." << std::endl;
     405                return;
     406        }
     407
     408        this->getCamera()->setViewMatrix(_distortionSet->getViewOffset());
     409        this->getCamera()->setProjectionMatrix(_distortionSet->getProjectionOffset());
     410}
  • experimental/distortionNG/extViewer.h

    r374 r380  
    5151                void setUpIntensityMapBlending(std::string intensityMap);
    5252
     53                /**
     54                 * \brief This functions updates the distortion setup by applying the distortionSet values to the viewers distortion setup.
     55                 *
     56                 */
     57                void updateDistortion();
     58
    5359                osgViewer::DistortionSet* getDistortionSet()    {return _distortionSet;}
    5460                void setDistortionSet(osgViewer::DistortionSet* ds) {_distortionSet = ds;}
  • experimental/distortionNG/main.cpp

    r376 r380  
    9393
    9494        // Add the distortion manipulator
    95         osgViewer::DistortionManipulator* distortionManip = new osgViewer::DistortionManipulator(_distortionSet);
     95        osgViewer::DistortionManipulator* distortionManip = new osgViewer::DistortionManipulator(&viewer, _distortionSet);
    9696
    9797        DistortionSetupStrategyProjectSyntropy* psStrategy = new DistortionSetupStrategyProjectSyntropy();
Note: See TracChangeset for help on using the changeset viewer.