Show
Ignore:
Timestamp:
01/08/07 11:00:16 (8 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osggeodemo
osggeometry
osghud
osgimpostor
osgkeyboard
osglauncher
osglight
osglightpoint
osglogicop
osglogo
osgmovie
osgmultiplecameras
osgmultitexture
osgoccluder
osgparametric
osgparticle

Files:
1 modified

Legend:

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

    r5636 r5927  
    1 #include <osgProducer/Viewer> 
     1#include <osgViewer/Viewer> 
    22 
    33#include <osg/MatrixTransform> 
     
    2424#include <osg/ShapeDrawable> 
    2525 
     26#include <iostream> 
    2627 
    2728class OccluderEventHandler : public osgGA::GUIEventHandler 
     
    2930    public: 
    3031     
    31         OccluderEventHandler(osgProducer::Viewer* viewer):_viewer(viewer) {} 
     32        OccluderEventHandler(osgViewer::Viewer* viewer):_viewer(viewer) {} 
    3233     
    3334        virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&); 
     
    4041         
    4142         
    42         osgProducer::Viewer*                    _viewer; 
     43        osgViewer::Viewer*                    _viewer; 
    4344        osg::ref_ptr<osg::Group>                _occluders; 
    4445        osg::ref_ptr<osg::ConvexPlanarOccluder> _convexPlanarOccluder; 
     
    4748bool OccluderEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) 
    4849{ 
     50#if 0 
    4951    switch(ea.getEventType()) 
    5052    { 
     
    5355            if (ea.getKey()=='a') 
    5456            { 
    55  
    5657                float x = ea.getXnormalized(); 
    5758                float y = ea.getYnormalized(); 
     
    9798            return false; 
    9899    } 
     100#else 
     101    osg::notify(osg::NOTICE)<<"Computre intersections not implemented yet."<<std::endl; 
     102    return false; 
     103#endif 
    99104} 
    100105 
     
    285290    
    286291    // initialize the viewer. 
    287     osgProducer::Viewer viewer(arguments); 
    288  
    289     // set up the value with sensible default event handlers. 
    290     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
     292    osgViewer::Viewer viewer; 
    291293 
    292294    bool manuallyCreateOccluders = false; 
     
    295297    if (manuallyCreateOccluders) 
    296298    { 
    297         viewer.getEventHandlerList().push_front(new OccluderEventHandler(&viewer)); 
    298     } 
    299  
    300     // get details on keyboard and mouse bindings used by the viewer. 
    301     viewer.getUsage(*arguments.getApplicationUsage()); 
     299        viewer.addEventHandler(new OccluderEventHandler(&viewer)); 
     300    } 
    302301 
    303302    // if user request help write it out to cout. 
     
    305304    { 
    306305        arguments.getApplicationUsage()->write(std::cout); 
    307         return 1; 
    308     } 
    309  
    310     // any option left unread are converted into errors to write out later. 
    311     arguments.reportRemainingOptionsAsUnrecognized(); 
    312  
    313     // report any errors if they have occured when parsing the program aguments. 
    314     if (arguments.errors()) 
    315     { 
    316         arguments.writeErrorMessages(std::cout); 
    317306        return 1; 
    318307    } 
     
    322311    if (!loadedmodel) 
    323312    { 
     313        osg::notify(osg::NOTICE)<<"Please sepecify and model filename on the command line."<<std::endl; 
    324314        return 1; 
    325315    } 
     
    346336    viewer.setSceneData( rootnode.get() ); 
    347337 
    348  
    349     // create the windows and run the threads. 
    350     viewer.realize(); 
    351  
    352  
    353     while( !viewer.done() ) 
    354     { 
    355         // wait for all cull and draw threads to complete. 
    356         viewer.sync(); 
    357  
    358         // update the scene by traversing it with the the update visitor which will 
    359         // call all node update callbacks and animations. 
    360         viewer.update(); 
    361           
    362         // fire off the cull and draw traversals of the scene. 
    363         viewer.frame(); 
    364          
    365     } 
    366  
    367     // wait for all cull and draw threads to complete. 
    368     viewer.sync(); 
    369  
    370     // run a clean up frame to delete all OpenGL objects. 
    371     viewer.cleanup_frame(); 
    372  
    373     // wait for all the clean up frame to complete. 
    374     viewer.sync(); 
    375  
    376     return 0; 
     338    return viewer.run(); 
    377339}