|
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::Vec3 eye;
osg::Vec3 center;
osg::Vec3 up;
viewer->getCamera()->getViewMatrixAsLookAt(eye,center,up);
osg::ref_ptr<osg::Camera> cameraMaster = viewer->getCamera();
osg::Matrix _inverseMV;
_inverseMV.invert( cameraMaster->getViewMatrix());//getviewMatrix视图矩阵
//getProjectMatrix获取投影矩阵
osg::Vec3 ptEye= osg::Vec3( 0, 0, 0) * _inverseMV;
double left=0.0f;
double right=0.0f;
double bottom=0.0f;
double top=0.0f;
double znear=0.0f;
double zfar=0.0f;
cameraMaster->getProjectionMatrixAsOrtho(left, right, bottom, top, znear, zfar);
osg::ref_ptr<osg::Group> root = new osg::Group();
//加入渐变文字
root->addChild(createFadeText());
//读取地形模型
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("lz.osg");
root->addChild(node.get());
//优化场景数据
osgUtil::Optimizer optimizer ;
optimizer.optimize(root.get()) ;
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0 ;
}
这个投影矩阵,left, right, bottom, top, znear, zfar都设置为0,为什么执行完cameraMaster->getProjectionMatrixAsOrtho(left, right, bottom, top, znear, zfar); 这些参数信息还是0
|
|