不glRotate在OpenGL旋转摄像机或旋转轴世界或旋转模型对象? [英] does glRotate in OpenGL rotate the camera or rotate the world axis or rotate the model object?

查看:224
本文介绍了不glRotate在OpenGL旋转摄像机或旋转轴世界或旋转模型对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否 glRotate 旋转摄像头,世界轴,或对象。解释他们是如何与不同的例子。


解决方案

  

相机


有是在OpenGL没有摄像头。


  

世界轴


有没有世界在OpenGL。


  

或对象


有在OpenGL中没有对象。

困惑?


OpenGL是绘制系统,与点,线和三角形运行。有一个场景,或者没有什么概念在OpenGL的世界。所有存在的顶点,其中每个人都有一组属性和存在的OpenGL决定顶点是如何变成像素的状态。

这个过程的第一阶段是获得视口内的顶点位置。在固定管线(即没有着色),得到那些,如果首先用所谓的模型视点矩阵乘以每顶点位置,中间结果被用于照明计算,然后乘以投影矩阵。之后,裁剪,然后到正常化坐标视应用。

这两个矩阵我提到保存两个目的。第一个模型视图用于应用对传入顶点一些变换,使得那些在相对于原点的所需点结束。有一个在世界第一运动的几何形状的一些地方,然后移动世界中的观点没有什么区别。或保持在原点的视点和在相反的移动整个世界。所有这可以通过模型视图矩阵进行说明。

第二个投影的正常化进程一起工作的行为就像是一种镜头的,可以这么说。有了这个,你设置视场(和其他一些参数,如轮班,你需要对某些应用 - 不要担心吧)

有关矩阵有趣的是,他们是不可交换的,即对于两个给定矩阵N,M

  M * N = / = N * M;对于大多数M,N

这最终意味着,你可以在正确的顺序基本变换乘以到对方构成了一系列的变革A,B,C,D ......为一体的单一化合物变换矩阵T。

OpenGL的矩阵操作函数(他们BTW过时),做到这一点。你有选择的操作(矩阵模式)例如矩阵模型视点M.然后glRotate有效地做到这一点:

  M * = R(角,轴)

即。有源矩阵被乘以来自给定的参数构成的旋转矩阵。类似的规模和翻译。

如果发生这种情况,似乎像一个相机或放置一个对象完全取决于如何及顺序的操作组合。

但对于OpenGL的存在只是数字/矢量(顶点属性),这在某种程度上转化为2维视坐标,即拿得出的点填补其间的线或三角形。

I want to know whether glRotate rotates the camera, the world axis, or the object. Explain how they are different with examples.

解决方案

the camera

There is no camera in OpenGL.

the world axis

There is no world in OpenGL.

or the object.

There are no objects in OpenGL.

Confused?


OpenGL is a drawing system, that operates with points, lines and triangles. There is no concept of a scene or a world in OpenGL. All there is are vertices of which each has a set of attributes and there is the state of OpenGL which determines how vertices are turned into pixels.

The very first stage of this process is getting the vertex positions within the viewport. In the fixed function pipeline (i.e. without shaders), to get those, each vertex position if first multiplied with the so called "modelview" matrix, the intermediary result is used for lighting calculations and then multiplied with the "projection" matrix. After that clipping and then normalization into viewport coordinates are applied.

Those two matrices I mentioned save two purposes. The first one "modelview" is used to apply some transformation on the incoming vertices so that those end up in the desired spot relative to the origin. There is no difference in first moving geometry to some place in the world, and then moving the viewpoint within the world. Or keeping the viewpoint at the origin and move the whole world in the opposite. All this can be described by the modelview matrix.

The second one "projection" works together with the normalization process to behave like a kind of "lens", so to speak. With this you set the field of view (and a few other parameters, like shift, which you need for certain applications – don't worry about it).

The interesting thing about matrices is, that they're non-commutative, i.e. for two given matrices N, M

M * N =/= N * M ; for most M, N

This ultimately means, that you can compose a series of transformations A, B, C, D... into one single compound transformation matrix T by multiplying the primitive transformations onto each other in the right order.

The OpenGL matrix manipulation functions (they're obsolete BTW), do just that. You have a matrix selected for manipulation (the matrix mode) for example the modelview M. Then glRotate effectively does this:

M *= R(angle,axis)

i.e. the active matrix gets multiplied on a rotation matrix constructed from the given parameters. Similar for scale and translate.

If this happens to appear to behave like a camera or placing a object depends entirely on how and in which order those manipulations are combined.

But for OpenGL there are just numbers/vectors (vertex attributes), which somehow translate into 2-dimensional viewport coordinates, that get drawn as points for filled inbetween as line or a triangle.

这篇关于不glRotate在OpenGL旋转摄像机或旋转轴世界或旋转模型对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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