Show
Ignore:
Timestamp:
01/23/07 13:10:44 (7 years ago)
Author:
robert
Message:

Added stats and range of keyboard mouse handling to osgshadow example

Files:
1 modified

Legend:

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

    r6010 r6030  
    1111 
    1212#include <osgGA/TrackballManipulator> 
     13#include <osgGA/FlightManipulator> 
     14#include <osgGA/DriveManipulator> 
     15#include <osgGA/KeySwitchMatrixManipulator> 
     16#include <osgGA/StateSetManipulator> 
    1317#include <osgGA/AnimationPathManipulator> 
     18#include <osgGA/TerrainManipulator> 
     19#include <osgGA/AnimationPathManipulator> 
    1420 
    1521#include <osgViewer/Viewer> 
     22#include <osgViewer/StatsHandler> 
    1623 
    1724#include <osgShadow/OccluderGeometry> 
     
    167174     
    168175 
    169     std::string pathfile; 
    170     while (arguments.read("-p",pathfile)) 
    171     { 
    172         osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile); 
    173         if (apm->valid()) viewer.setCameraManipulator(apm.get()); 
    174     } 
    175  
    176     if (!viewer.getCameraManipulator()) viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); 
     176    // set up the camera manipulators. 
     177    { 
     178        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 
     179 
     180        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); 
     181        keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); 
     182        keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); 
     183        keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); 
     184 
     185        std::string pathfile; 
     186        char keyForAnimationPath = '5'; 
     187        while (arguments.read("-p",pathfile)) 
     188        { 
     189            osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); 
     190            if (apm || !apm->valid())  
     191            { 
     192                unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     193                keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); 
     194                keyswitchManipulator->selectMatrixManipulator(num); 
     195                ++keyForAnimationPath; 
     196            } 
     197        } 
     198 
     199        viewer.setCameraManipulator( keyswitchManipulator.get() ); 
     200    } 
     201 
     202    // add stats 
     203    viewer.addEventHandler( new osgViewer::StatsHandler() ); 
    177204 
    178205    // any option left unread are converted into errors to write out later.