查看: 1109|回复: 0

getProjectionMatrixAsOrtho

[复制链接]

该用户从未签到

发表于 2014-11-13 14:50:09 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表