Show
Ignore:
Timestamp:
03/24/08 11:53:14 (6 years ago)
Author:
robert
Message:

Added full range of cameras manipulators to osgmultitexturecontrol example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp

    r7921 r7987  
    3030#include <osgGA/TerrainManipulator> 
    3131#include <osgGA/StateSetManipulator> 
     32#include <osgGA/AnimationPathManipulator> 
     33#include <osgGA/TrackballManipulator> 
     34#include <osgGA/FlightManipulator> 
     35#include <osgGA/DriveManipulator> 
     36#include <osgGA/KeySwitchMatrixManipulator> 
     37#include <osgGA/StateSetManipulator> 
     38#include <osgGA/AnimationPathManipulator> 
     39#include <osgGA/TerrainManipulator> 
    3240 
    3341#include <osgViewer/ViewerEventHandlers> 
     
    217225    // add all the event handlers to the viewer 
    218226    { 
    219         // add terrain manipulator 
    220         viewer.setCameraManipulator(new osgGA::TerrainManipulator); 
    221  
    222227        // add the state manipulator 
    223228        viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
     
    242247    } 
    243248 
     249    { 
     250        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 
     251 
     252        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); 
     253        keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); 
     254        keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); 
     255 
     256        unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     257        keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); 
     258 
     259        std::string pathfile; 
     260        char keyForAnimationPath = '5'; 
     261        while (arguments.read("-p",pathfile)) 
     262        { 
     263            osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); 
     264            if (apm || !apm->valid())  
     265            { 
     266                num = keyswitchManipulator->getNumMatrixManipulators(); 
     267                keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); 
     268                ++keyForAnimationPath; 
     269            } 
     270        } 
     271 
     272        keyswitchManipulator->selectMatrixManipulator(num); 
     273 
     274        viewer.setCameraManipulator( keyswitchManipulator.get() ); 
     275    } 
     276 
    244277    // add a viewport to the viewer and attach the scene graph. 
    245278    viewer.setSceneData( rootnode );