Show
Ignore:
Timestamp:
01/10/07 14:52:22 (7 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgparticleeffects
osgphotoalbum
osgpick
osgpoints
osgpointsprite
osgprecipitation
osgprerender
osgprerendercubemap
osgreflect
osgscalarbar
osgscribe
osgsequence
osgplanets

Files:
1 modified

Legend:

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

    r5381 r5954  
    3232#include <osgGA/FlightManipulator> 
    3333#include <osgGA/DriveManipulator> 
    34  
    35 #include <osgProducer/Viewer> 
     34#include <osgGA/KeySwitchMatrixManipulator> 
     35 
     36#include <osgViewer/Viewer> 
    3637 
    3738 
     
    583584 
    584585    // initialize the viewer. 
    585     osgProducer::Viewer viewer(arguments); 
    586  
    587     // set up the value with sensible default event handlers. 
    588     viewer.setUpViewer(osgProducer::Viewer::ESCAPE_SETS_DONE | osgProducer::Viewer::VIEWER_MANIPULATOR | osgProducer::Viewer::STATE_MANIPULATOR); 
    589  
    590     // get details on keyboard and mouse bindings used by the viewer. 
    591     viewer.getUsage(*arguments.getApplicationUsage()); 
     586    osgViewer::Viewer viewer; 
     587 
     588    osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 
     589    viewer.setCameraManipulator( keyswitchManipulator.get() ); 
    592590 
    593591    SolarSystem solarSystem; 
     
    898896 
    899897    // set up tracker manipulators, once for each astral body 
    900      
    901898    { 
    902899        FindNamedNodeVisitor fnnv("Moon"); 
     
    911908            tm->setTrackNode( fnnv._foundNodes.front().get() ); 
    912909 
    913             unsigned int num = viewer.addCameraManipulator( tm ); 
    914             viewer.selectCameraManipulator( num ); 
     910            unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     911            keyswitchManipulator->addMatrixManipulator( 'm', "moon", tm ); 
     912            keyswitchManipulator->selectMatrixManipulator( num ); 
    915913        } 
    916914    }     
     
    928926            tm->setTrackNode( fnnv._foundNodes.front().get() ); 
    929927 
    930             unsigned int num = viewer.addCameraManipulator( tm ); 
    931             viewer.selectCameraManipulator( num ); 
     928            unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     929            keyswitchManipulator->addMatrixManipulator( 'e', "earth", tm); 
     930            keyswitchManipulator->selectMatrixManipulator( num ); 
    932931        } 
    933932    }     
     
    945944            tm->setTrackNode( fnnv._foundNodes.front().get() ); 
    946945 
    947             unsigned int num = viewer.addCameraManipulator( tm ); 
    948             viewer.selectCameraManipulator( num ); 
     946            unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     947            keyswitchManipulator->addMatrixManipulator( 's', "sun", tm); 
     948            keyswitchManipulator->selectMatrixManipulator( num ); 
    949949        } 
    950950    }     
    951      
    952     // create the windows and run the threads. 
    953     viewer.realize(); 
    954      
    955     while( !viewer.done() ) 
    956     { 
    957         // wait for all cull and draw threads to complete. 
    958         viewer.sync(); 
    959  
    960         // update the scene by traversing it with the the update visitor which will 
    961         // call all node update callbacks and animations. 
    962         viewer.update(); 
    963           
    964         // fire off the cull and draw traversals of the scene. 
    965         viewer.frame(); 
    966          
    967     } 
    968      
    969      
    970     // wait for all cull and draw threads to complete. 
    971     viewer.sync(); 
    972  
    973     // run a clean up frame to delete all OpenGL objects. 
    974     viewer.cleanup_frame(); 
    975  
    976     // wait for all the clean up frame to complete. 
    977     viewer.sync(); 
    978  
    979     return 0; 
     951 
     952    return viewer.run(); 
     953 
    980954}// end main 
    981955