|
楼主 |
发表于 2009-11-8 11:50:19
|
显示全部楼层
投影参数设置如下:- ComputeBoundsVisitor v;
- destNode->accept (v);
- BoundingBox box=v.getBoundingBox ();
- float w=(box.xMax ()-box.xMin());
- float h=(box.yMax ()-box.yMin());
- int txt_width=800,txt_height=(int)(800*h/w);
- Camera *camera=new Camera;
- camera->setClearColor(osg::Vec4(1.f,1.f,1.f,1.0f));
- camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- camera->setProjectionMatrix(osg::Matrix::ortho2D(-w/2,w/2,-h/2,h/2));
- camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
- camera->setViewport(0,0,txt_width,txt_height);
- camera->setRenderOrder(osg::Camera::PRE_RENDER);
- camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
复制代码 |
|