glulookat() 用法-opengl 和 C++
0你能帮我解决这个场景吗:我有一个 3D 世界,我想以第一人称方式定位相机(真正的目的是在穿越小行星时从宇宙飞船内部的第一人称视图腰带)。在这种情况下 glulookat 的参数是什么?我想:
gluLookAt(30, 30, 30, 0, 0, 0, 0, 1, 0);//the up vector would be normal y axis
这样的说法正确吗?
另外,如果我想让相机随着船一起移动,该怎么做?当移动船时,我还应该从 glulookat 移动“眼睛”坐标?像眼睛坐标(glulookat 的前 3 个参数)之类的东西应该与船坐标相同吗?
0Could you please help me out with this scenario: I have a 3D world, and I want to position the camera in a first-person manner( the real purpose would be a first-person view from inside a spaceship, while travelling through an asteroid belt). What would be the parameters for glulookat in this case? I thought of:
gluLookAt(30, 30, 30, 0, 0, 0, 0, 1, 0);//the up vector would be normal y axis
Would this be correct?
Also if I want the camera to move along with the ship, how would that be done? When moving the ship I should also move the "eye" coordinates from glulookat? Something like the eye coordinates(the first 3 parametres of glulookat) should be the same with the ship coordinates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您建议的 gluLookAt 调用会将相机定位在
(30,30,30)
并将其指向原点。这更像是你所需要的。您必须在每一帧中调用它,以便相机能够跟随船舶的运动。如果你想让船做桶滚,你必须有额外的变量来跟踪向上向量。
我喜欢有某种结构来保存坐标,以便我可以重载 gl 函数来获取它们并编写更短的函数调用,例如
The gluLookAt call you propose would position the camera at
(30,30,30)
and point it at the origin.This is more like what you need. You'll have to call it every frame so that the camera will follow the ship's movement. If you want the ship to do a barrel roll, you'll have to have additional variables to track the up vector.
I like to have some kind of struct to hold co-ordinates so that I can overload gl functions to take them and write shorter function calls, e.g.