Show
Ignore:
Timestamp:
01/11/07 12:47:01 (7 years ago)
Author:
robert
Message:

Ported follow examples to osgViewer:

osgshape
osgsimplifier
osgsimulation
osgslice
osgspacewarp
osgspheresegment
osgspotlight
osgstereoimage

Files:
1 modified

Legend:

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

    r5636 r5959  
    1313#include <osgUtil/Optimizer> 
    1414#include <osgUtil/Simplifier> 
    15 #include <osgProducer/Viewer> 
    16  
     15#include <osgViewer/Viewer> 
     16#include <osgGA/TrackballManipulator> 
     17#include <iostream> 
    1718 
    1819class KeyboardEventHandler : public osgGA::GUIEventHandler 
     
    7273 
    7374    // construct the viewer. 
    74     osgProducer::Viewer viewer(arguments); 
    75  
    76     // set up the value with sensible default event handlers. 
    77     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    78  
    79     // get details on keyboard and mouse bindings used by the viewer. 
    80     viewer.getUsage(*arguments.getApplicationUsage()); 
     75    osgViewer::Viewer viewer; 
    8176 
    8277    // read the sample ratio if one is supplied 
     
    9186    } 
    9287 
    93     // report any errors if they have occured when parsing the program aguments. 
    94     if (arguments.errors()) 
    95     { 
    96         arguments.writeErrorMessages(std::cout); 
    97         return 1; 
    98     } 
    99      
    10088    if (arguments.argc()<=1) 
    10189    { 
     
    10391        return 1; 
    10492    } 
    105  
    106     osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
    10793 
    10894    // read the scene from the list of file specified commandline args. 
     
    115101        return 1; 
    116102    } 
    117  
    118     // any option left unread are converted into errors to write out later. 
    119     arguments.reportRemainingOptionsAsUnrecognized(); 
    120  
    121     // report any errors if they have occured when parsing the program aguments. 
    122     if (arguments.errors()) 
    123     { 
    124         arguments.writeErrorMessages(std::cout); 
    125     } 
    126  
    127     osg::Timer_t end_tick = osg::Timer::instance()->tick(); 
    128  
    129     std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl; 
    130  
    131103     
    132104    //loadedModel->accept(simplifier); 
    133105 
    134106    unsigned int keyFlag = 0; 
    135     viewer.getEventHandlerList().push_front(new KeyboardEventHandler(keyFlag)); 
     107    viewer.addEventHandler(new KeyboardEventHandler(keyFlag)); 
    136108 
    137109    // set the scene to render 
    138110    viewer.setSceneData(loadedModel.get()); 
    139111 
     112    viewer.setCameraManipulator(new osgGA::TrackballManipulator()); 
     113 
    140114    // create the windows and run the threads. 
    141115    viewer.realize(); 
    142116 
    143     float multiplier = 0.99f; 
     117    float multiplier = 0.8f; 
    144118    float minRatio = 0.001f; 
    145119    float ratio = sampleRatio; 
    146120 
     121 
    147122    while( !viewer.done() ) 
    148123    { 
    149         // wait for all cull and draw threads to complete. 
    150         viewer.sync(); 
    151  
    152         // update the scene by traversing it with the the update visitor which will 
    153         // call all node update callbacks and animations. 
    154         viewer.update(); 
    155           
    156124        // fire off the cull and draw traversals of the scene. 
    157125        viewer.frame(); 
     
    179147    } 
    180148     
    181     // wait for all cull and draw threads to complete. 
    182     viewer.sync(); 
    183  
    184     // run a clean up frame to delete all OpenGL objects. 
    185     viewer.cleanup_frame(); 
    186  
    187     // wait for all the clean up frame to complete. 
    188     viewer.sync(); 
    189  
    190149    return 0; 
    191150}