Show
Ignore:
Timestamp:
01/06/07 22:35:57 (8 years ago)
Author:
robert
Message:

Ported osgcopy, osgcubemap, osgdelaunay, osgdepthpartion, osgdistortion, osgfadetext, osgforest and osgfxbrowser to osgViewer

Files:
1 modified

Legend:

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

    r5636 r5923  
    2424#include <osgText/Text> 
    2525 
    26 #include <osgProducer/Viewer> 
     26#include <osgViewer/Viewer> 
     27 
     28#include <iostream> 
    2729 
    2830// for the grid data.. 
     
    10701072    // use an ArgumentParser object to manage the program arguments. 
    10711073    osg::ArgumentParser arguments(&argc,argv); 
    1072  
    1073     // set up the usage document, in case we need to print out how to use this program. 
    1074     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates the osg::Shape classes."); 
    1075     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    1076     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    1077     arguments.getApplicationUsage()->addCommandLineOption("--trees <number>","Set the number of trees to create"); 
    10781074    
    10791075    // construct the viewer. 
    1080     osgProducer::Viewer viewer(arguments); 
     1076    osgViewer::Viewer viewer; 
    10811077 
    10821078    float numTreesToCreates = 10000; 
    10831079    arguments.read("--trees",numTreesToCreates); 
    1084  
    1085     // set up the value with sensible default event handlers. 
    1086     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    10871080     
    10881081    osg::ref_ptr<ForestTechniqueManager> ttm = new ForestTechniqueManager; 
    10891082     
    1090     viewer.getEventHandlerList().push_front(new TechniqueEventHandler(ttm.get())); 
    1091  
    1092     // get details on keyboard and mouse bindings used by the viewer. 
    1093     viewer.getUsage(*arguments.getApplicationUsage()); 
    1094  
    1095     // if user request help write it out to cout. 
    1096     if (arguments.read("-h") || arguments.read("--help")) 
    1097     { 
    1098         arguments.getApplicationUsage()->write(std::cout); 
    1099         return 1; 
    1100     } 
    1101  
    1102     // any option left unread are converted into errors to write out later. 
    1103     arguments.reportRemainingOptionsAsUnrecognized(); 
    1104  
    1105     // report any errors if they have occured when parsing the program aguments. 
    1106     if (arguments.errors()) 
    1107     { 
    1108         arguments.writeErrorMessages(std::cout); 
    1109         return 1; 
    1110     } 
    1111      
    1112     osg::Node* node = ttm->createScene((unsigned int)numTreesToCreates); 
     1083    viewer.addEventHandler(new TechniqueEventHandler(ttm.get())); 
    11131084 
    11141085    // add model to viewer. 
    1115     viewer.setSceneData( node ); 
    1116  
    1117     // create the windows and run the threads. 
    1118     viewer.realize(); 
    1119  
    1120     while( !viewer.done() ) 
    1121     { 
    1122         // wait for all cull and draw threads to complete. 
    1123         viewer.sync(); 
    1124  
    1125         // update the scene by traversing it with the the update visitor which will 
    1126         // call all node update callbacks and animations. 
    1127         viewer.update(); 
    1128           
    1129         // fire off the cull and draw traversals of the scene. 
    1130         viewer.frame(); 
    1131          
    1132     } 
    1133      
    1134     // wait for all cull and draw threads to complete. 
    1135     viewer.sync(); 
    1136  
    1137     // run a clean up frame to delete all OpenGL objects. 
    1138     viewer.cleanup_frame(); 
    1139  
    1140     // wait for all the clean up frame to complete. 
    1141     viewer.sync(); 
    1142  
    1143     return 0; 
    1144 } 
     1086    viewer.setSceneData( ttm->createScene((unsigned int)numTreesToCreates) ); 
     1087 
     1088 
     1089    return viewer.run(); 
     1090}