- Timestamp:
- 01/11/07 12:47:01 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgsimplifier/osgsimplifier.cpp
r5636 r5959 13 13 #include <osgUtil/Optimizer> 14 14 #include <osgUtil/Simplifier> 15 #include <osgProducer/Viewer> 16 15 #include <osgViewer/Viewer> 16 #include <osgGA/TrackballManipulator> 17 #include <iostream> 17 18 18 19 class KeyboardEventHandler : public osgGA::GUIEventHandler … … 72 73 73 74 // construct the viewer. 74 osgProducer::Viewer viewer(arguments); 75 76 // set up the value with sensible default event handlers. 77 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 78 79 // get details on keyboard and mouse bindings used by the viewer. 80 viewer.getUsage(*arguments.getApplicationUsage()); 75 osgViewer::Viewer viewer; 81 76 82 77 // read the sample ratio if one is supplied … … 91 86 } 92 87 93 // report any errors if they have occured when parsing the program aguments.94 if (arguments.errors())95 {96 arguments.writeErrorMessages(std::cout);97 return 1;98 }99 100 88 if (arguments.argc()<=1) 101 89 { … … 103 91 return 1; 104 92 } 105 106 osg::Timer_t start_tick = osg::Timer::instance()->tick();107 93 108 94 // read the scene from the list of file specified commandline args. … … 115 101 return 1; 116 102 } 117 118 // any option left unread are converted into errors to write out later.119 arguments.reportRemainingOptionsAsUnrecognized();120 121 // report any errors if they have occured when parsing the program aguments.122 if (arguments.errors())123 {124 arguments.writeErrorMessages(std::cout);125 }126 127 osg::Timer_t end_tick = osg::Timer::instance()->tick();128 129 std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl;130 131 103 132 104 //loadedModel->accept(simplifier); 133 105 134 106 unsigned int keyFlag = 0; 135 viewer. getEventHandlerList().push_front(new KeyboardEventHandler(keyFlag));107 viewer.addEventHandler(new KeyboardEventHandler(keyFlag)); 136 108 137 109 // set the scene to render 138 110 viewer.setSceneData(loadedModel.get()); 139 111 112 viewer.setCameraManipulator(new osgGA::TrackballManipulator()); 113 140 114 // create the windows and run the threads. 141 115 viewer.realize(); 142 116 143 float multiplier = 0. 99f;117 float multiplier = 0.8f; 144 118 float minRatio = 0.001f; 145 119 float ratio = sampleRatio; 146 120 121 147 122 while( !viewer.done() ) 148 123 { 149 // wait for all cull and draw threads to complete.150 viewer.sync();151 152 // update the scene by traversing it with the the update visitor which will153 // call all node update callbacks and animations.154 viewer.update();155 156 124 // fire off the cull and draw traversals of the scene. 157 125 viewer.frame(); … … 179 147 } 180 148 181 // wait for all cull and draw threads to complete.182 viewer.sync();183 184 // run a clean up frame to delete all OpenGL objects.185 viewer.cleanup_frame();186 187 // wait for all the clean up frame to complete.188 viewer.sync();189 190 149 return 0; 191 150 }
