Show
Ignore:
Timestamp:
11/03/05 11:16:38 (8 years ago)
Author:
robert
Message:

Added initial CameraNode? and CameraView? stups for the .ive loader

Files:
1 modified

Legend:

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

    r4621 r4671  
    744744      int iview; 
    745745}; 
    746 int main( int argc, char **argv ) 
    747 { 
    748      
    749     // use an ArgumentParser object to manage the program arguments. 
    750     osg::ArgumentParser arguments(&argc,argv); 
    751      
    752     // set up the usage document, in case we need to print out how to use this program. 
    753     arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
    754     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); 
    755     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    756     arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad"); 
    757     arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField"); 
    758     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line paramters"); 
    759     arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); 
    760     arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available"); 
    761     arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindigs."); 
    762      
    763      
    764     // construct the viewer. 
    765     osgProducer::Viewer viewer(arguments); 
    766      
    767     // set up the value with sensible default event handlers. 
    768     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    769      
    770     // get details on keyboard and mouse bindings used by the viewer. 
    771     viewer.getUsage(*arguments.getApplicationUsage()); 
    772      
    773     // if user request help write it out to cout. 
    774     bool helpAll = arguments.read("--help-all"); 
    775     unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) | 
    776         ((helpAll ||  arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) | 
    777         ((helpAll ||  arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 ); 
    778     if (helpType) 
    779     { 
    780         arguments.getApplicationUsage()->write(std::cout, helpType); 
    781         return 1; 
    782     } 
    783      
    784     // report any errors if they have occured when parsing the program aguments. 
    785     if (arguments.errors()) 
    786     { 
    787         arguments.writeErrorMessages(std::cout); 
    788         return 1; 
    789     } 
    790      
    791     if (arguments.argc()<1) 
    792     { 
    793         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
    794         return 1; 
    795     } 
    796      
    797     osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
    798      
    799     // create the scene from internal specified terrain/constraints. 
    800     osg::ref_ptr<osg::Node> loadedModel = makedelaunay(0); 
    801      
    802     // if no model has been successfully loaded report failure. 
    803     if (!loadedModel)  
    804     { 
    805         std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; 
    806         return 1; 
    807     } 
    808      
    809      
    810     // any option left unread are converted into errors to write out later. 
    811     arguments.reportRemainingOptionsAsUnrecognized(); 
    812      
    813     // report any errors if they have occured when parsing the program aguments. 
    814     if (arguments.errors()) 
    815     { 
    816         arguments.writeErrorMessages(std::cout); 
    817     } 
    818      
    819     osg::Timer_t end_tick = osg::Timer::instance()->tick(); 
    820      
    821     std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl; 
    822      
    823     // optimize the scene graph, remove rendundent nodes and state etc. 
    824     osgUtil::Optimizer optimizer; 
    825     optimizer.optimize(loadedModel.get()); 
    826      
    827     // pass the loaded scene graph to the viewer. 
    828     viewer.setSceneData(loadedModel.get()); 
    829      
    830     // copied from osgtessealte.cpp 
    831     // add event handler for keyboard 'n' to retriangulate 
    832     viewer.getEventHandlerList().push_front(new KeyboardEventHandler(loadedModel.get(), viewer)); 
    833      
    834     // create the windows and run the threads. 
    835     viewer.realize(); 
    836      
    837     while( !viewer.done() ) 
    838     { 
    839         // wait for all cull and draw threads to complete. 
    840         viewer.sync(); 
    841          
    842         // update the scene by traversing it with the the update visitor which will 
    843         // call all node update callbacks and animations. 
    844         viewer.update(); 
    845          
    846         // fire off the cull and draw traversals of the scene. 
    847         viewer.frame(); 
    848          
    849     } 
    850      
    851     // wait for all cull and draw threads to complete before exit. 
    852     viewer.sync(); 
    853      
    854     return 0; 
    855 } 
    856746 
    857747osg::Vec3Array * WallConstraint::getWall(const float height) const 
     
    13801270 
    13811271 
     1272int main( int argc, char **argv ) 
     1273{ 
     1274     
     1275    // use an ArgumentParser object to manage the program arguments. 
     1276    osg::ArgumentParser arguments(&argc,argv); 
     1277     
     1278    // set up the usage document, in case we need to print out how to use this program. 
     1279    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
     1280    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); 
     1281    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
     1282    arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad"); 
     1283    arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField"); 
     1284    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line paramters"); 
     1285    arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); 
     1286    arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available"); 
     1287    arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindigs."); 
     1288     
     1289     
     1290    // construct the viewer. 
     1291    osgProducer::Viewer viewer(arguments); 
     1292     
     1293    // set up the value with sensible default event handlers. 
     1294    viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
     1295     
     1296    // get details on keyboard and mouse bindings used by the viewer. 
     1297    viewer.getUsage(*arguments.getApplicationUsage()); 
     1298     
     1299    // if user request help write it out to cout. 
     1300    bool helpAll = arguments.read("--help-all"); 
     1301    unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) | 
     1302        ((helpAll ||  arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) | 
     1303        ((helpAll ||  arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 ); 
     1304    if (helpType) 
     1305    { 
     1306        arguments.getApplicationUsage()->write(std::cout, helpType); 
     1307        return 1; 
     1308    } 
     1309     
     1310    // report any errors if they have occured when parsing the program aguments. 
     1311    if (arguments.errors()) 
     1312    { 
     1313        arguments.writeErrorMessages(std::cout); 
     1314        return 1; 
     1315    } 
     1316     
     1317    if (arguments.argc()<1) 
     1318    { 
     1319        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
     1320        return 1; 
     1321    } 
     1322     
     1323    osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
     1324     
     1325    // create the scene from internal specified terrain/constraints. 
     1326    osg::ref_ptr<osg::Node> loadedModel = makedelaunay(0); 
     1327     
     1328    // if no model has been successfully loaded report failure. 
     1329    if (!loadedModel)  
     1330    { 
     1331        std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; 
     1332        return 1; 
     1333    } 
     1334     
     1335     
     1336    // any option left unread are converted into errors to write out later. 
     1337    arguments.reportRemainingOptionsAsUnrecognized(); 
     1338     
     1339    // report any errors if they have occured when parsing the program aguments. 
     1340    if (arguments.errors()) 
     1341    { 
     1342        arguments.writeErrorMessages(std::cout); 
     1343    } 
     1344     
     1345    osg::Timer_t end_tick = osg::Timer::instance()->tick(); 
     1346     
     1347    std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl; 
     1348     
     1349    // optimize the scene graph, remove rendundent nodes and state etc. 
     1350    osgUtil::Optimizer optimizer; 
     1351    optimizer.optimize(loadedModel.get()); 
     1352     
     1353    // pass the loaded scene graph to the viewer. 
     1354    viewer.setSceneData(loadedModel.get()); 
     1355     
     1356    // copied from osgtessealte.cpp 
     1357    // add event handler for keyboard 'n' to retriangulate 
     1358    viewer.getEventHandlerList().push_front(new KeyboardEventHandler(loadedModel.get(), viewer)); 
     1359     
     1360    // create the windows and run the threads. 
     1361    viewer.realize(); 
     1362     
     1363    while( !viewer.done() ) 
     1364    { 
     1365        // wait for all cull and draw threads to complete. 
     1366        viewer.sync(); 
     1367         
     1368        // update the scene by traversing it with the the update visitor which will 
     1369        // call all node update callbacks and animations. 
     1370        viewer.update(); 
     1371         
     1372        // fire off the cull and draw traversals of the scene. 
     1373        viewer.frame(); 
     1374         
     1375    } 
     1376     
     1377    // wait for all cull and draw threads to complete before exit. 
     1378    viewer.sync(); 
     1379     
     1380    return 0; 
     1381}