查看: 1199|回复: 0

getViewMatrixAsLookAt的问题

[复制链接]

该用户从未签到

发表于 2015-7-11 15:23:58 | 显示全部楼层 |阅读模式
各位好。新人遇到一个困惑的问题

//将参数设置给相机,并立即获取相机参数  
viewer.setCameraManipulator(NULL);
viewer.getCamera()->setViewMatrixAsLookAt(eye,center,up);
viewer.getCamera()->getViewMatrixAsLookAt(eye,center,up);  

//将各参数打印出来  
    printf("eye: %f,%f,%f new\n",eye._v[0],eye._v[1],eye._v[2]);  
    printf("center: %f,%f,%f new\n",center._v[0],center._v[1],center._v[2]);  
    printf("up: %f,%f,%f new\n",up._v[0],up._v[1],up._v[2]);  

问题是,getViewMatrixAsLookAt修改了我eye,center,up参数值,我f5调试跟,发现是在这个方法里面
void Matrix_implementation::getLookAt(Vec3d& eye,Vec3d& center,Vec3d& up,value_type lookDistance) const
{
    Matrix_implementation inv;
    inv.invert(*this);

    // note: e and c variables must be used inside this method instead of eye and center
    // because eye and center are references and they may point to the same variable.
    Vec3d e = osg::Vec3d(0.0,0.0,0.0)*inv;
    up = transform3x3(*this,osg::Vec3d(0.0,1.0,0.0));
    Vec3d c = transform3x3(*this,osg::Vec3d(0.0,0.0,-1));
    c.normalize();
    c = e + c*lookDistance;

    // assign the results
    eye = e;
    center = c;
}

不是很懂原理,请大侠指点。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

联系我们

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