我正在尝试学习opengl Glut的基础知识,我正在关注网站的教程。
我无法理解如何在太空中移动相机,而不仅仅是两个纵坐标。
你能帮帮我吗?
我正在使用glutPassiveMotionFunc(mouseMove)功能。
//MOUSE MOVEMENT----------------------------------------------------------
void mouseMove(int x, int y) {
xOrigin = x;
// this will only be true when the left button is down
if (xOrigin >= 0) {
// update deltaAngle
deltaAngle = (x - xOrigin) * 0.001f;
// update camera's direction
lx = x + sin(angle + deltaAngle);
lz = y - cos(angle + deltaAngle);
}
else{
deltaAngle = (x + xOrigin) * 0.001f;
// update camera's direction
lx = x + sin(angle + deltaAngle);
lz = y - cos(angle + deltaAngle);
}
}
答案 0 :(得分:0)
openGL中有多个坐标系,屏幕坐标,眼睛坐标,世界坐标......
从鼠标回调函数获得的x和y是指屏幕坐标,它从窗口左上角的(0,0)开始。
另一方面,相机在不同的水平上工作。你没有提到你正在使用的OpenGL版本......但是无论如何你可以阅读gluLookAt()的手册页来了解更多关于眼睛坐标系的信息。