| 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 | | |
| 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; |
| 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(); |