| 311 | | osgProducer::Viewer viewer(arguments); |
| 312 | | |
| 313 | | // set up the value with sensible default event handlers. |
| 314 | | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
| 315 | | |
| 316 | | // get details on keyboard and mouse bindings used by the viewer. |
| 317 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 318 | | |
| 319 | | // if user request help write it out to cout. |
| 320 | | if (arguments.read("-h") || arguments.read("--help")) |
| 321 | | { |
| 322 | | arguments.getApplicationUsage()->write(std::cout); |
| 323 | | return 1; |
| 324 | | } |
| 325 | | |
| 326 | | // any option left unread are converted into errors to write out later. |
| 327 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 328 | | |
| 329 | | // report any errors if they have occured when parsing the program aguments. |
| 330 | | if (arguments.errors()) |
| 331 | | { |
| 332 | | arguments.writeErrorMessages(std::cout); |
| 333 | | return 1; |
| 334 | | } |
| | 306 | osgViewer::Viewer viewer; |
| 353 | | // set all the sceneview's up so that their left and right add cull masks are set up. |
| 354 | | for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin(); |
| 355 | | itr!=viewer.getSceneHandlerList().end(); |
| 356 | | ++itr) |
| 357 | | { |
| 358 | | // switch off small feature culling to prevent the light points from being culled. |
| 359 | | osgUtil::SceneView* sceneview = (*itr)->getSceneView(); |
| 360 | | sceneview->setCullingMode( sceneview->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING); |
| 361 | | } |
| 362 | | |
| 363 | | while( !viewer.done() ) |
| 364 | | { |
| 365 | | // wait for all cull and draw threads to complete. |
| 366 | | viewer.sync(); |
| 367 | | |
| 368 | | // update the scene by traversing it with the the update visitor which will |
| 369 | | // call all node update callbacks and animations. |
| 370 | | viewer.update(); |
| 371 | | |
| 372 | | // fire off the cull and draw traversals of the scene. |
| 373 | | viewer.frame(); |
| 374 | | |
| 375 | | } |
| 376 | | |
| 377 | | // wait for all cull and draw threads to complete. |
| 378 | | viewer.sync(); |
| 379 | | |
| 380 | | // run a clean up frame to delete all OpenGL objects. |
| 381 | | viewer.cleanup_frame(); |
| 382 | | |
| 383 | | // wait for all the clean up frame to complete. |
| 384 | | viewer.sync(); |
| 385 | | |
| 386 | | return 0; |
| | 325 | viewer.getCamera()->setCullingMode( viewer.getCamera()->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING); |
| | 326 | |
| | 327 | return viewer.run(); |