|
各位好。新人遇到一个困惑的问题
//将参数设置给相机,并立即获取相机参数
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;
}
不是很懂原理,请大侠指点。 |
|