有效的方法计算gluLookAt的向上向量,它指向y轴最多? [英] Effective way to calculate the up vector for gluLookAt which points up the y-axis the most?

查看:582
本文介绍了有效的方法计算gluLookAt的向上向量,它指向y轴最多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个向上的向量,当相机看任何角度(除了直接向下或向上,因为向上的向量将垂直于y轴)。

I need to create an up vector for when the camera looks at any angle (except directly down or up because the up vector would be perpendicular to the y-axis).

向上向量必须垂直于当然的视线。当视线不是沿着y轴,你可以想象一个围绕眼睛的圆周和视线向上的向量可以是。在该圆上,将存在比任何其他点更远离y轴的点。这是我想要的上传矢量。

The up vector has to be perpendicular to the line of sight of-course. When the line of sight isn't along the y-axis, you can imagine a circle around the eye and the line of sight where the up vector could be. On this circle, there will be a point which goes further up the y-axis than any other point. This is what I want my up-vector to be.

我相信我可以解决一个解决方案,但我猜人们会做这么多次之前和我想要有最有效的解决方案。

I'm sure I can work out a solution but I'm guessing people would have done this plenty of times before and I want to have the most effective solution.

我的相机,至少使用这个时,不会直接向下或向上y轴,所以没有问题。

My camera, when using this at least, wont look directly down or up the y-axis so there is no problem there.

推荐答案

gluLookAt 不要求您提供的向上向量垂直于您正在查找的方向。所以你可以只使用0,1,0。

gluLookAt does not require that the up vector you provide be perpendicular to the direction you’re looking. So you can just use 0,1,0.

如果你真的想要一个垂直向量,看看 gluLookAt 的手册页并做他们正在做的 u

If you really, really want to come up with a perpendicular vector, take a look at the man page for gluLookAt and do what they're doing to make u

这篇关于有效的方法计算gluLookAt的向上向量,它指向y轴最多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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