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/osgsequence/osgsequence.cpp

    r5636 r5954  
    2020#include <osgDB/ReadFile> 
    2121 
    22 #include <osgProducer/Viewer> 
    23  
     22#include <osgViewer/Viewer> 
     23 
     24#include <iostream> 
    2425 
    2526// create text drawable at 'pos' 
     
    132133    seq->setDuration(1.0f, -1); 
    133134 
     135    seq->setMode(osg::Sequence::START); 
     136 
    134137    return seq; 
    135138} 
     
    150153        if (ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN) { 
    151154            switch (ea.getKey()) { 
    152             case 'S': 
     155            case 's': 
    153156                { 
    154157                    osg::Sequence::SequenceMode mode = _seq->getMode(); 
     
    168171                } 
    169172                break; 
    170             case 'L': 
     173            case 'l': 
    171174                { 
    172175                    osg::Sequence::LoopMode mode; 
     
    201204    // use an ArgumentParser object to manage the program arguments. 
    202205    osg::ArgumentParser arguments(&argc,argv); 
    203  
    204     // set up the usage document, in case we need to print out how to use this program. 
    205     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of osg::Sequence."); 
    206     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    207     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    208206    
    209207    // construct the viewer. 
    210     osgProducer::Viewer viewer(arguments); 
    211  
    212     // set up the value with sensible default event handlers. 
    213     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    214  
    215     // get details on keyboard and mouse bindings used by the viewer. 
    216     viewer.getUsage(*arguments.getApplicationUsage()); 
    217  
    218     // if user request help write it out to cout. 
    219     if (arguments.read("-h") || arguments.read("--help")) 
    220     { 
    221         arguments.getApplicationUsage()->write(std::cout); 
    222         return 1; 
    223     } 
    224  
    225     // any option left unread are converted into errors to write out later. 
    226     arguments.reportRemainingOptionsAsUnrecognized(); 
    227  
    228     // report any errors if they have occured when parsing the program aguments. 
    229     if (arguments.errors()) 
    230     { 
    231         arguments.writeErrorMessages(std::cout); 
    232         return 1; 
    233     } 
    234      
    235     if (arguments.argc()<=1) 
    236     { 
    237         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    238         return 1; 
    239     } 
    240      
     208    osgViewer::Viewer viewer; 
    241209    // root 
    242210    osg::Group* rootNode = new osg::Group; 
     
    250218        "- can loop or swing through an interval of it's children", 
    251219        "- can repeat the interval a number of times or indefinitively", 
    252         "- press 'Shift-S' to start/pause/resume", 
    253         "- press 'Shift-L' to toggle loop/swing mode", 
     220        "- press 's' to start/pause/resume", 
     221        "- press 'l' to toggle loop/swing mode", 
    254222        NULL 
    255223    }; 
     
    264232 
    265233    // add event handler to control sequence 
    266     viewer.getEventHandlerList().push_front(new SequenceEventHandler(seq)); 
    267  
    268     // create the windows and run the threads. 
    269     viewer.realize(); 
    270  
    271     while( !viewer.done() ) 
    272     { 
    273         // wait for all cull and draw threads to complete. 
    274         viewer.sync(); 
    275  
    276         // update the scene by traversing it with the the update visitor which will 
    277         // call all node update callbacks and animations. 
    278         viewer.update(); 
    279           
    280         // fire off the cull and draw traversals of the scene. 
    281         viewer.frame(); 
    282          
    283     } 
    284      
    285     // wait for all cull and draw threads to complete. 
    286     viewer.sync(); 
    287  
    288     // run a clean up frame to delete all OpenGL objects. 
    289     viewer.cleanup_frame(); 
    290  
    291     // wait for all the clean up frame to complete. 
    292     viewer.sync(); 
    293  
    294     return 0; 
    295 } 
     234    viewer.addEventHandler(new SequenceEventHandler(seq)); 
     235 
     236    return viewer.run(); 
     237}