Show
Ignore:
Timestamp:
01/05/07 22:19:01 (8 years ago)
Author:
robert
Message:

Ported osgcluster to osgViewer.

Files:
1 modified

Legend:

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

    r5381 r5920  
    99#include <osg/PolygonMode> 
    1010#include <osg/LineStipple> 
     11#include <osg/AnimationPath> 
    1112 
    1213#include <osgDB/Registry> 
     
    1718#include <osgGA/DriveManipulator> 
    1819 
    19 #include <osgProducer/Viewer> 
     20#include <osgViewer/Viewer> 
    2021 
    2122#include <osgUtil/Optimizer> 
     
    9596int main( int argc, char **argv ) 
    9697{ 
    97  
    9898    // use an ArgumentParser object to manage the program arguments. 
    9999    osg::ArgumentParser arguments(&argc,argv); 
    100  
    101     // set up the usage document, in case we need to print out how to use this program. 
    102     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use multi-pass and osg::ClipNode to clip parts of the scene away.."); 
    103     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    104     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    105     
    106     // initialize the viewer. 
    107     osgProducer::Viewer viewer(arguments); 
    108  
    109     // set up the value with sensible default event handlers. 
    110     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    111  
    112     // get details on keyboard and mouse bindings used by the viewer. 
    113     viewer.getUsage(*arguments.getApplicationUsage()); 
    114  
    115     // if user request help write it out to cout. 
    116     if (arguments.read("-h") || arguments.read("--help")) 
    117     { 
    118         arguments.getApplicationUsage()->write(std::cout); 
    119         return 1; 
    120     } 
    121  
    122     // any option left unread are converted into errors to write out later. 
    123     arguments.reportRemainingOptionsAsUnrecognized(); 
    124  
    125     // report any errors if they have occured when parsing the program aguments. 
    126     if (arguments.errors()) 
    127     { 
    128         arguments.writeErrorMessages(std::cout); 
    129         return 1; 
    130     } 
    131      
    132     if (arguments.argc()<=1) 
    133     { 
    134         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    135         return 1; 
    136     } 
    137100 
    138101    // load the nodes from the commandline arguments. 
     
    140103    if (!loadedModel) 
    141104    { 
     105        osg::notify(osg::NOTICE)<<"Please specifiy a filename and the command line"<<std::endl; 
    142106        return 1; 
    143107    } 
     
    145109    // decorate the scenegraph with a clip node. 
    146110    osg::Node* rootnode = decorate_with_clip_node(loadedModel); 
    147  
    148    
    149      
     111       
    150112    // run optimization over the scene graph 
    151113    osgUtil::Optimizer optimzer; 
    152114    optimzer.optimize(rootnode); 
     115     
     116    osgViewer::Viewer viewer; 
    153117      
    154118    // set the scene to render 
    155119    viewer.setSceneData(rootnode); 
    156120 
    157     // create the windows and run the threads. 
    158     viewer.realize(); 
    159  
    160     while( !viewer.done() ) 
    161     { 
    162         // wait for all cull and draw threads to complete. 
    163         viewer.sync(); 
    164  
    165         // update the scene by traversing it with the the update visitor which will 
    166         // call all node update callbacks and animations. 
    167         viewer.update(); 
    168           
    169         // fire off the cull and draw traversals of the scene. 
    170         viewer.frame(); 
    171          
    172     } 
    173      
    174     // wait for all cull and draw threads to complete. 
    175     viewer.sync(); 
    176  
    177     // run a clean up frame to delete all OpenGL objects. 
    178     viewer.cleanup_frame(); 
    179  
    180     // wait for all the clean up frame to complete. 
    181     viewer.sync(); 
    182  
    183     return 0; 
     121    return viewer.run(); 
    184122}