- Timestamp:
- 01/10/07 14:52:22 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgsequence/osgsequence.cpp
r5636 r5954 20 20 #include <osgDB/ReadFile> 21 21 22 #include <osgProducer/Viewer> 23 22 #include <osgViewer/Viewer> 23 24 #include <iostream> 24 25 25 26 // create text drawable at 'pos' … … 132 133 seq->setDuration(1.0f, -1); 133 134 135 seq->setMode(osg::Sequence::START); 136 134 137 return seq; 135 138 } … … 150 153 if (ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN) { 151 154 switch (ea.getKey()) { 152 case ' S':155 case 's': 153 156 { 154 157 osg::Sequence::SequenceMode mode = _seq->getMode(); … … 168 171 } 169 172 break; 170 case ' L':173 case 'l': 171 174 { 172 175 osg::Sequence::LoopMode mode; … … 201 204 // use an ArgumentParser object to manage the program arguments. 202 205 osg::ArgumentParser arguments(&argc,argv); 203 204 // set up the usage document, in case we need to print out how to use this program.205 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of osg::Sequence.");206 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");207 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");208 206 209 207 // construct the viewer. 210 osgProducer::Viewer viewer(arguments); 211 212 // set up the value with sensible default event handlers. 213 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 214 215 // get details on keyboard and mouse bindings used by the viewer. 216 viewer.getUsage(*arguments.getApplicationUsage()); 217 218 // if user request help write it out to cout. 219 if (arguments.read("-h") || arguments.read("--help")) 220 { 221 arguments.getApplicationUsage()->write(std::cout); 222 return 1; 223 } 224 225 // any option left unread are converted into errors to write out later. 226 arguments.reportRemainingOptionsAsUnrecognized(); 227 228 // report any errors if they have occured when parsing the program aguments. 229 if (arguments.errors()) 230 { 231 arguments.writeErrorMessages(std::cout); 232 return 1; 233 } 234 235 if (arguments.argc()<=1) 236 { 237 arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 238 return 1; 239 } 240 208 osgViewer::Viewer viewer; 241 209 // root 242 210 osg::Group* rootNode = new osg::Group; … … 250 218 "- can loop or swing through an interval of it's children", 251 219 "- can repeat the interval a number of times or indefinitively", 252 "- press ' Shift-S' to start/pause/resume",253 "- press ' Shift-L' to toggle loop/swing mode",220 "- press 's' to start/pause/resume", 221 "- press 'l' to toggle loop/swing mode", 254 222 NULL 255 223 }; … … 264 232 265 233 // add event handler to control sequence 266 viewer.getEventHandlerList().push_front(new SequenceEventHandler(seq)); 267 268 // create the windows and run the threads. 269 viewer.realize(); 270 271 while( !viewer.done() ) 272 { 273 // wait for all cull and draw threads to complete. 274 viewer.sync(); 275 276 // update the scene by traversing it with the the update visitor which will 277 // call all node update callbacks and animations. 278 viewer.update(); 279 280 // fire off the cull and draw traversals of the scene. 281 viewer.frame(); 282 283 } 284 285 // wait for all cull and draw threads to complete. 286 viewer.sync(); 287 288 // run a clean up frame to delete all OpenGL objects. 289 viewer.cleanup_frame(); 290 291 // wait for all the clean up frame to complete. 292 viewer.sync(); 293 294 return 0; 295 } 234 viewer.addEventHandler(new SequenceEventHandler(seq)); 235 236 return viewer.run(); 237 }
