【发布时间】:2010-09-22 04:57:28
【问题描述】:
在 OpenGL 中,我试图围绕一个点旋转相机,相机与该点的距离为 r,并在旋转时面向该点。换句话说,我希望相机沿着圆心在半径为 r 的圆周上移动,相机在圆周上的任何一点都朝向中心。
假设在 3d 空间中,圆的中心是 (3, 0, 3);
我试过了:
// move to center of circle
glTranslatef(-3, 0, -3)
// move a distance away from the circle
glTranslatef(0, 0, r);
// rotate along the y "up" axis
glRotatef(CameraAngle, 0, 1, 0);
CameraAngle 是围绕圆移动的度数。
我的最终结果是相机仍然沿原点旋转,而不是圆心。谁能帮我解决这个问题?谢谢!
【问题讨论】: