Ambigious OpenGL的默认摄像机位置摄像机、位置、Ambigious、OpenGL

2023-09-08 01:08:01 作者:囍歡

在我的OpenGL程序(我应用透视投影矩阵之前)每当我得出了一些对象我画它在世界坐标系的原点,但几乎所有的OpenGL教程指出相机(我的投影视图)位于在原点看向正z轴(这取决于你如何对待后面的投影矩阵Z值),但是如果这是真的怎么做我的相机(位于原点)能够查看地处对象由来。

in my Opengl programs (before i apply perspective projection matrix) whenever i draw some object I draw it at the origin of the world coordinate system, however almost all of the Opengl tutorials states that the camera (My projection view) is located at the origin looking toward positive z-axis (which depends on how you treat z value in the projection matrix later on), however if that is true how does my camera (located in the origin) is able to view an object located in the origin.

注:我需要这些信息,使我改变世界的并将其绕原点,所以我得到一个可旋转摄像头的幻觉

Note: i need this information so that i shift the world and rotate it around the origin so i get a rotating camera illusion.

推荐答案

怎么会出现在屏幕上,将取决于你适用于它的整个转换。我跨preT,这与使用单位矩阵既为投影和(模型)视图转换的方式你的问题。在这种情况下,你直接绘制在剪辑的空间。从技术上讲,这将定义在原点的摄像机的位置,但是视锥将等同于一个邻(-1.0,1.0,-1.0,1.0,1.0,-1.0)设置 - 让你的视锥将位于半的背后的摄像头(这是完全正常的邻位的预测,但听起来似乎有悖常理)。对于摄像头的方向,这部分是一个比较ambigous。通常情况下,GL有摄像机眺望-z方向上的惯例,但在裁剪空间,+ Z将指向到屏幕,以及经典的透视函数将这个实际使用 z_near = -near z_far = -far 附近参数。 (这也是也是为什么identy变换通过所取得的原因与最后两个标志调用翻转相对于x和y的范围)。因此,在这种情况下,人们的可以的认为,摄像头实际上是沿着+ Z寻找,或者我们可以说,相机看起来沿-z,但近及远的飞机是由投影交换。这就是你怎么想跨preT这些东西的事。这些公约大多是关系到经典的固定功能GL,它使用的照明和雾的计算(也许一个视图别的东西)的眼位。而且它也可能会承担的相机看起来沿-z公约镜面照明期限计算,如果 GL_LIGHT_MODEL_LOCAL_VIEWER 未启用(缺省情况下是禁用的,看到的 glLightModel()

What appears on your screen will depend on the whole transformations you apply to it. I interpret your question in the way that you use an identity matrix both for the projection and the (model)view transformation. In that case, you are directly drawing in clip space. Technically, this will define a camera position at the origin, but the view frustum will be equivalent to an Ortho(-1.0, 1.0, -1.0, 1.0, 1.0, -1.0) setup - so your view frustum will lie half behind the camera (which is perfectly fine for ortho projections, but might seem counterintuitive). For the camera orientation, that part is a bit more ambigous. Usually, GL had the convention that the camera looks into the -z direction, but in clip space, +z will point into the screen, and the classic Ortho and Perspective functions treat this by actually using z_near=-near and z_far=-far for the near and far parameters. (That is also is also the reason why identy transform is achieved through that Ortho call with the last two signs flipped relative to the x and y ranges). So in that case, one could argue that the camera is actually looking along +z, or one could argue that the camera looks along -z, but the near and far planes are swapped by the projection. That is a matter of how you like to interpret these things. These conventions mostly matter to classic "fixed-function" GL, which uses the eye position for lighting and fog calculations (and maybe a view things else). And it also might assume the "camera looks along -z" convention for calculation of the specular lighting term if GL_LIGHT_MODEL_LOCAL_VIEWER is not enabled (which is disabled by default, see glLightModel().

在现代GL,没有这样的约定除了左撇子夹子空间的存在,你可以让你自己的约定,对于眼位(如果你需要一个)。

In modern GL, no such conventions exist besides the left-handedness of the clip space, and you can make your own conventions for an eye space (if you need one).