查看: 1478|回复: 2

关于camera与camera中的node的boundingsphere的问题

[复制链接]

该用户从未签到

发表于 2010-5-16 10:57:38 | 显示全部楼层 |阅读模式
  1. int main( int argc, char **argv )
  2. {
  3. // use an ArgumentParser object to manage the program arguments.
  4. osg::ArgumentParser arguments(&argc,argv);

  5. // read the scene from the list of file specified commandline args.
  6. osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);

  7. // if not loaded assume no arguments passed in, try use default mode instead.
  8. if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osg");

  9. // if no model has been successfully loaded report failure.
  10. if (!loadedModel)
  11. {
  12. std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
  13. return 1;
  14. }

  15. // construct the viewer.
  16. osgViewer::Viewer viewer;

  17. int xoffset = 300;
  18. int yoffset = 150;

  19. // left window + left slave camera
  20. {
  21. osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
  22. traits->x = xoffset + 0;
  23. traits->y = yoffset + 0;
  24. traits->width = 600;
  25. traits->height = 480;
  26. traits->windowDecoration = true;
  27. traits->doubleBuffer = true;
  28. traits->sharedContext = 0;

  29. osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
  30. viewer.getCamera()->setGraphicsContext(gc.get());
  31. viewer.getCamera()->setViewport(new osg::Viewport(0,0, traits->width, traits->height));
  32. }


  33. // optimize the scene graph, remove rendundent nodes and state etc.
  34. osgUtil::Optimizer optimizer;
  35. optimizer.optimize(loadedModel.get());

  36. // set the scene to render
  37. viewer.setSceneData(loadedModel.get());
  38. viewer.setCameraManipulator(new osgGA::TrackballManipulator());
  39. //osg::ref_ptr<osg::Camera> camera1 = viewer.getCamera();
  40. //std::cout<<camera->getBound().center().x()<<","<<camera->getBound().center().y()<<","<<camera->getBound().center().z()<<"ss\n";

  41. while(!viewer.done())
  42. {
  43. viewer.frame();
  44. std::cout<<viewer.getCamera()->getBound().radius()<<"crr\n";
  45. std::cout<<loadedModel.get()->getBound().radius()<<"rr\n";
  46. }
  47. return 0;
复制代码


当发生缩放时,camera和node的包围球半径怎么一样 而且不变。

该用户从未签到

发表于 2010-5-16 18:00:00 | 显示全部楼层
std::cout<<viewer.getCamera()->computeBound().center().x()<<viewer.getCamera()->computeBound().center().y()<<viewer.getCamera()->computeBound().center().z()<<"crr\n";

该用户从未签到

发表于 2010-5-17 15:04:41 | 显示全部楼层
是不是要强制computeBound()
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表