2016-03-18 140 views
0

我想改变关键按下gluLookAt。例如,我想从顶部,右侧,底部和左侧看到我的场景,方法是敲击键t,r,b,l。我开始实现从顶部的样子,但当按下“t”键时它似乎不起作用,在我的场景中没有任何变化。我究竟做错了什么?在按键上更改gluLookAt。顶部,右侧,底部,左侧

这是我keyResponder方法:

void CDrawModel::myKeyResponder(unsigned char key, int x, int y) { 
if(key == 27) {        // The ESC key 
    glutDestroyWindow(glutGetWindow());  // kill the window 
    exit(0); 
} 


if (key == 't' || key == 'T'){ 
    gluLookAt(0, 600, 0, 
     0, 0, 0, 
     0, 600, 1); 
    cout << "T ot t pressed" << endl; 
} 

//refresh the screen after every key press... 
glutPostRedisplay(); 
} 
+1

看来你不知道向上的矢量是干什么的。 [检查这个问题。](http://stackoverflow.com/questions/5717654/glulookat-please-explain)除此之外,你张贴的片段太模糊。我们不知道您为矩阵做了什么样的初始化,以及如何渲染场景。 – aslg

回答

1

当你按下的 'T' 按钮,在你的lookAt向上向量必须是(0,0,-1)。

意思就是说gluLookAt必须有这样的参数:

gluLookAt(0,600,0,0,0,0,0,0,-1)

建议:尝试了解向量弥补手段风景。

+0

谢谢!将试试这:) –

相关问题