Ignore:
Timestamp:
Apr 21, 2012, 9:49:26 PM (12 years ago)
Author:
Torben Dannhauer
Message:

DistortionManipulator? is working (alpha stadium)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/main.cpp

    r352 r353  
    4747        osg::Image* intMap = osgDB::readImageFile("intensitymap.png");
    4848        if (!intMap)
    49         {
    50                 osg::notify(osg::WARN) << "Couldn't find intensity map, quiting." << std::endl;
    51                 return -1;
    52         }
     49                osg::notify(osg::WARN) << "Couldn't find intensity map, skip intensityMap setup." << std::endl;
     50
    5351        // Create DistortionSet
    5452        osg::ref_ptr<osgViewer::DistortionSet> _distortionSet = new osgViewer::DistortionSet();
     
    6260
    6361        // set up the camera manipulators.
     62    osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
     63
     64    keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
     65    keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
     66    keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
     67    keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
     68
     69    std::string pathfile;
     70    char keyForAnimationPath = '5';
     71    while (arguments.read("-p",pathfile))
    6472    {
    65         osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
    66 
    67         keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
    68         keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
    69         keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
    70         keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
    71 
    72         std::string pathfile;
    73         char keyForAnimationPath = '5';
    74         while (arguments.read("-p",pathfile))
     73        osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
     74        if (apm || !apm->valid())
    7575        {
    76             osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
    77             if (apm || !apm->valid())
    78             {
    79                 unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
    80                 keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
    81                 keyswitchManipulator->selectMatrixManipulator(num);
    82                 ++keyForAnimationPath;
    83             }
     76            unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
     77            keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
     78            keyswitchManipulator->selectMatrixManipulator(num);
     79            ++keyForAnimationPath;
    8480        }
    85 
    86         viewer.setCameraManipulator( keyswitchManipulator.get() );
    8781    }
    8882
     83        // Add keyswitch manipulator for multiple scene controls-
     84    viewer.setCameraManipulator( keyswitchManipulator.get() );
     85
    8986        // Add the distortion manipulator
    90         osgViewer::DistortionManipulator* distManip = new osgViewer::DistortionManipulator();
    91         distManip->setDistortionSet(_distortionSet);
    92         viewer.addEventHandler(distManip);
     87        viewer.addEventHandler(new osgViewer::DistortionManipulator(_distortionSet));
    9388
    9489    // add the state manipulator
Note: See TracChangeset for help on using the changeset viewer.