|
- int main( int argc, char **argv )
- {
- // use an ArgumentParser object to manage the program arguments.
- osg::ArgumentParser arguments(&argc,argv);
- // read the scene from the list of file specified commandline args.
- osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
- // if not loaded assume no arguments passed in, try use default mode instead.
- if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osg");
- // if no model has been successfully loaded report failure.
- if (!loadedModel)
- {
- std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
- return 1;
- }
- // construct the viewer.
- osgViewer::Viewer viewer;
- int xoffset = 300;
- int yoffset = 150;
- // left window + left slave camera
- {
- osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
- traits->x = xoffset + 0;
- traits->y = yoffset + 0;
- traits->width = 600;
- traits->height = 480;
- traits->windowDecoration = true;
- traits->doubleBuffer = true;
- traits->sharedContext = 0;
- osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
- viewer.getCamera()->setGraphicsContext(gc.get());
- viewer.getCamera()->setViewport(new osg::Viewport(0,0, traits->width, traits->height));
- }
- // optimize the scene graph, remove rendundent nodes and state etc.
- osgUtil::Optimizer optimizer;
- optimizer.optimize(loadedModel.get());
- // set the scene to render
- viewer.setSceneData(loadedModel.get());
- viewer.setCameraManipulator(new osgGA::TrackballManipulator());
- //osg::ref_ptr<osg::Camera> camera1 = viewer.getCamera();
- //std::cout<<camera->getBound().center().x()<<","<<camera->getBound().center().y()<<","<<camera->getBound().center().z()<<"ss\n";
- while(!viewer.done())
- {
- viewer.frame();
- std::cout<<viewer.getCamera()->getBound().radius()<<"crr\n";
- std::cout<<loadedModel.get()->getBound().radius()<<"rr\n";
- }
- return 0;
复制代码
当发生缩放时,camera和node的包围球半径怎么一样 而且不变。 |
|