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

    r5636 r5927  
    22 
    33#include <stdio.h> 
    4 #include <osgProducer/Viewer> 
     4#include <osgViewer/Viewer> 
    55 
    66#include <osg/Node> 
     
    2020 
    2121#include <osgUtil/Optimizer> 
     22 
     23#include <iostream> 
    2224 
    2325// currently not a satisfactory solution, but this is early days for the 
     
    8587    osg::ArgumentParser arguments(&argc,argv); 
    8688 
    87     // set up the usage document, in case we need to print out how to use this program. 
    88     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example of how to control animation in Geo files."); 
    89     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    90     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    91     arguments.getApplicationUsage()->addCommandLineOption("--fov <float>","Set the Field of View"); 
    92     
    93     float camera_fov=-1; 
    94     while (arguments.read("--fov",camera_fov)) {} 
    95  
    9689    // construct the viewer. 
    97     osgProducer::Viewer viewer(arguments); 
    98  
    99     // set up the value with sensible default event handlers. 
    100     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    101  
    102     // get details on keyboard and mouse bindings used by the viewer. 
    103     viewer.getUsage(*arguments.getApplicationUsage()); 
    104  
    105     // if user request help write it out to cout. 
    106     if (arguments.read("-h") || arguments.read("--help")) 
    107     { 
    108         arguments.getApplicationUsage()->write(std::cout); 
    109         return 1; 
    110     } 
    111  
    112     // any option left unread are converted into errors to write out later. 
    113     arguments.reportRemainingOptionsAsUnrecognized(); 
    114  
    115     // report any errors if they have occured when parsing the program aguments. 
    116     if (arguments.errors()) 
    117     { 
    118         arguments.writeErrorMessages(std::cout); 
    119         return 1; 
    120     } 
    121      
    122     if (arguments.argc()<=1) 
    123     { 
    124         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    125         return 1; 
    126     } 
    127  
     90    osgViewer::Viewer viewer; 
    12891 
    12992    // load the nodes from the commandline arguments. 
     
    13194    if (!rootnode) 
    13295    { 
     96        osg::notify(osg::NOTICE)<<"Please specify and geo model filename on the command line."<<std::endl; 
    13397        return 1; 
    13498    } 
     
    146110        ghand=new geodemoEventHandler(); 
    147111        gh->setUserUpdate(dodynamics); 
    148         viewer.getEventHandlerList().push_front(ghand); 
     112        viewer.addEventHandler(ghand); 
    149113    } 
    150114    else 
     
    162126                    ghand=new geodemoEventHandler(); 
    163127                    gh->setUserUpdate(dodynamics); 
    164                     viewer.getEventHandlerList().push_front(ghand); 
     128                    viewer.addEventHandler(ghand); 
    165129                } 
    166130            } 
     
    168132    } 
    169133 
    170     // create the windows and run the threads. 
    171     viewer.realize(); 
    172  
    173     while( !viewer.done() ) 
    174     { 
    175         // wait for all cull and draw threads to complete. 
    176         viewer.sync(); 
    177  
    178         // update the scene by traversing it with the the update visitor which will 
    179         // call all node update callbacks and animations. 
    180         viewer.update(); 
    181           
    182         // fire off the cull and draw traversals of the scene. 
    183         viewer.frame(); 
    184          
    185     } 
    186      
    187     // wait for all cull and draw threads to complete. 
    188     viewer.sync(); 
    189  
    190     // run a clean up frame to delete all OpenGL objects. 
    191     viewer.cleanup_frame(); 
    192  
    193     // wait for all the clean up frame to complete. 
    194     viewer.sync(); 
    195  
    196     return 0; 
     134    return viewer.run(); 
    197135}