|
离屏渲染一图片800*600 。保存后的图片大小也是800*600 ,但是图片边缘有蓝色背景。我想问怎么设置相机能去掉背景。我先尝试改变osgviewer 里面的camera 投影矩阵不起作用。用TrackballManipulator 能够改变相机位置,可是没有办法改变投影矩阵。下面的代码该投影矩阵和设置相机位置都没有效。为什么?
osg::ref_ptr<osg::Camera> camera = new osg::Camera(*viewer.getCamera());
camera->setViewport(new osg::Viewport(0,0,traits->width,traits->height));
camera->setProjectionMatrixAsFrustum(float(-traceNum)/2.0f,float(traceNum)/2.0f,float(-sampleNum)/2.0f,float(sampleNum)/2.0f,-1000,1000);
camera->setViewMatrixAsLookAt(osg::Vec3f(traceNum/2.0f,100,sampleNum/2.0f),osg::Vec3f(traceNum/2.0f,0,sampleNum/2.0f),osg::Vec3f(0,1,0));
viewer.setCamera(camera.get());
viewer.setCamera(camera.get()); |
|