|
下面代码用了ortho projection,ModelView矩阵视点为(0, -16, 0),视线沿y轴正方向
设置近裁剪平面与视点距离为17,远裁剪平面与视点距离为100
这时,由于几何体的y坐标在0和1之间,应该看不到几何体才对
但是,为什么还是可以看到几何体??请各位大虾指教!!小弟谢了!!
#include <osg/DisplaySettings>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osgViewer/Viewer>
#include <iostream>
#include <osgText/Text>
#include <osg/Matrix>
#include <osg/Geometry>
#include <osg/Projection>
void main(){
osgViewer::Viewer viewer ;
osg::Camera *cam = viewer.getCamera() ;
osg::ref_ptr<osg::Geode> geode = new osg::Geode() ;
osg::Geometry *geom = new osg::Geometry() ;
osg::Vec3Array *vertices = new osg::Vec3Array() ;
vertices->push_back(osg::Vec3(0.0, 0.0, 0.0)) ;
vertices->push_back(osg::Vec3(1.0, 0.0, 0.0)) ;
vertices->push_back(osg::Vec3(1.0, 1.0, 1.0)) ;
vertices->push_back(osg::Vec3(0.0, 1.0, 1.0)) ;
geom->setVertexArray(vertices) ;
geom->addPrimitiveSet(new osg:rawArrays(GL_POLYGON, 0, 4)) ;
geode->addDrawable(geom) ;
viewer.setSceneData(geode.get()) ;
viewer.realize() ;
cam->setViewMatrixAsLookAt(osg::Vec3(.0, -16, 0), osg::Vec3(0, 10000, 0), osg::Vec3(0, 0, 1)) ;
cam->setProjectionMatrixAsOrtho(-3, 3, -3, 3, 17, 100) ;
while(!viewer.done()){
viewer.frame() ;
}
//viewer.run() ;
} |
|