在OpenGL中平移和移动摄像机的正确方法? [英] Proper way to pan and move camera in OpenGL?

查看:1297
本文介绍了在OpenGL中平移和移动摄像机的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我在渲染之前通过glRotating进行平移,我通过gltranslating移动相机。我觉得这是错误的,因为im本质上是移动的场景,而不是相机。

Right now I'm panning by glRotating before rendering everything, and i'm moving the camera by gltranslating. I feel as if this is wrong since im essentially moving the scene, not the camera. What is the proper way to move the camera?

感谢

推荐答案

实际上,在相机周围移动场景是O​​penGL中的正确方式。

Actually 'moving the scene around the camera' is the proper way in OpenGL.

这是因为OpenGL将视图和模型矩阵组合到模型视图矩阵。 (有关详情,请查看此处

This is due to the fact that OpenGL combines the view and model matrices into the modelview matrix. (look here for more details)

显然lookat函数(如上所述)是一个移动(虚拟)相机的简单方法,但我发现它不适用于OpenGL3。

Obvious the lookat function (as mentioned above) is an easy way to move a (virtual) camera but i found that it doesn't work for OpenGL3.

d建议使用优秀的 glm库设置OpenGL3的转换矩阵。

I'd suggest to use the excellent glm library to setup the transformation matrices for OpenGL3.

种类:
Florian

Kind Regards, Florian

这篇关于在OpenGL中平移和移动摄像机的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆