|
楼主 |
发表于 2012-2-3 21:47:29
|
显示全部楼层
这个是我从网上找到的俯瞰的代码,想做这个场景的缩略图
长宽高是我通过包围盒计算的- osg::Camera* createBirdsEye( int blenth,int bwidth, int bheight)
- {
- osg::ref_ptr<osg::Camera> camera = new osg::Camera;
- camera->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
- double viewDistance = 2.0 * bheight;
- float top = blenth;
- float right = bwidth;
- camera->setProjectionMatrixAsOrtho2D(-right, right, -top, top);
- osg::Vec3d upDirection( 0.0,1.0,0.0 );
- osg::Vec3d viewDirection( 0.0,0.0,1.0 );
- osg::Vec3d center(0,0,0);
- osg::Vec3d eyePoint = center + viewDirection * viewDistance;
- camera->setViewMatrixAsLookAt( eyePoint, center, upDirection );
- return camera.release();
- }
复制代码 但是发现出来的图像不是正的 而是扁的矩形
然后我试了一下 花了一个box 结果显示如下
不知到为啥不是正方形 求解答 谢谢了
|
|