gluLookAt问题-如何使曲线像运动?

问题描述 投票:0回答:1

因此,基本上,通过使用向左,向右,向上和向下键,可能需要使用this animation来实现gluLookAt

我已经尝试了所有方法,但无法使其完全像这样移动。你有什么建议吗?这是我当前用于相机移动的功能。

void specialKeys(int key, int x, int y) {
    switch (key) {
        case GLUT_KEY_DOWN:
            ex -= 0.04;
            break;
        case GLUT_KEY_UP:
            ex += 0.04;
            break;
        case GLUT_KEY_LEFT:
            ey += 0.05;
            cy -= 0.05;
            std::cout << ex << " " << cx << " " << uy << std::endl;
            break;
        case GLUT_KEY_RIGHT:
            ey -= 0.05;
            cy += 0.05;
            std::cout << ex << " " << cx << " " << uy << std::endl;
            break;
        default:
            break;
        }
    glutPostRedisplay();
}

其余的代码可以在前面的问题Why does my wired sphere turn into ellipsoid when translating and changing camera angle?Issues with animation - translation, projection OpenGL/C++中找到。

我的gluLookAt是:

gluLookAt(ex + 0.0, ey + 0.0, ez*ex - 5.5, cx, cy, -1.0 + cz, -1.0, 0.0, 0.0);

当元素被转换到正确的位置时,我的上下键不按预期的方式工作。我认为我走在正确的道路上,但是我已经为此进行了两天的工作,无法解决它。

c++ opengl glut opengl-compat glu
1个回答
0
投票

视图的目标似乎不在圆环的中心。它似乎在对称轴上,但是在圆环的前面。因此,gluLookAt的自变量centerZ取决于gluLookAt。例如:

ez
© www.soinside.com 2019 - 2024. All rights reserved.