Understanding Transformations(理解变换)

周一到周五,天天一篇,北京时间早上7点准时更新~app

If you think about it, most 3D graphics aren’t really 3D(用肾想象一下都知道,实际上3D图像并非真3D). We use 3D concepts and terminology to describe what something looks like; then this 3D data is “squished” onto a 2D computer screen(咱们使用3D的概念和技术来描述事物看起来如何,而后俺们就把这样的3D数据给"干"到了2D显示器上). We call the process of squishing 3D data down into 2D data projection(咱们把3D数据变成2D数据的操做叫投影). We refer to the projection whenever we want to describe the type of transformation (orthographic or perspective) that occurs during vertex processing, but projection is only one of the types of transformations that occur in OpenGL(咱们在这里讲到的投影是指发生在顶点处理阶段的OpenGL中的那些变换中的一个). Transformations also allow you to rotate objects around; move them about; and even stretch, shrink, and warp them(变换一样的容许你能够旋转物体、移动物体、揉、捏、掐等等都是能够的。反正就是让物体发生他们原本命运里就安排好的操做)less

Coordinate Spaces in OpenGL(OpenGL中的坐标系)ide

A series of one or more transforms can be represented as a matrix, and multiplication by that matrix effectively moves a vector from one coordinate space to another(一系列的操做能够用一个矩阵来表达,而且用向量乘以一个矩阵后,还能将向量从一个空间转到另外一个空间). Several coordinate spaces are commonly used in OpenGL programming(OpenGL里用到了不少常见的坐标系). Any number of geometric transformations can occur between the time you specify your vertices and the time they appear on the screen, but the most common are modeling, viewing, and projection(几何形体的变换能够在你定义顶点数据以后到他们显示到荧幕上以前来作,但统统常主要涉及的是模型、视口、投影). In this section, we examine each of the coordinate spaces commonly used in 3D computer graphics (and summarized in Table 4.1)(在本章节,俺们主要来说讲在3D图形学里经常使用的几个坐标系,在表4.1里列出来了), and the transforms used to move vectors between them(那些变换就是把向量在这些坐标系之间来回折腾,想一想也是过的很惨的日子,为何人们要互相伤害)
Understanding Transformations(理解变换)
A matrix that moves coordinates from one space to another is normally named for those spaces(一个般来说,咱们矩阵的名字就表明着他们干了什么事,好比把物体的顶点从模型坐标系转到视口坐标系的矩阵就叫模型视口矩阵). For example, a matrix that transforms an object’s vertices from model space into view space is commonly referred to as a model–view matrixui

Object Coordinates(模型坐标系)this

Most of your vertex data will typically begin life in object space, which is also commonly known as model space(大多数顶点数据都是在模型坐标系下定义滴,在模型坐标系里,全部的位置都是相对于模型坐标系的原点来定义滴). In object space, positions of vertices are interpreted relative to a local origin. Consider a spaceship model. The origin of the model is probably going to be somewhere logical, such as the tip of the craft’s nose, at its center of gravity, or where the pilot might sit(好比一个宇宙灰船,阔能,它的原点在飞行器鼻尖儿上,也有可能在重心处,还有可能在飞行员坐的位置,然并卵). In a 3D modeling program, returning to the origin and zooming out sufficiently should show you the whole spaceship. The origin of a model is often the point about which you might rotate it to place it into a new orientation(在3D建模软件里,返回原点,而后放大缩小应该要让你看见飞船的全身,太羞耻了,没事就想着看别人全身). It wouldn’t make sense to place the origin far outside the model, because rotating the object about that point would apply significant translation as well as rotation(王法在哪里?所以,把原点放在模型外面,感受是没什么卵用的。由于绕原点旋转物体的时候,会增长一个至关大的偏移,这样会让人很蛋疼)spa

World Coordinates(世界坐标系)翻译

The next common coordinate space is world space. This is where coordinates are stored relative to a fixed, global origin(下一个坐标系就是世界坐标系了,世界坐标系里的东西都是参考相对固定的世界坐标系的原点来的). To continue the spaceship analogy, this could be the center of a play-field or other fixed body such as a nearby planet. Once in worldspace, all objects exist in a common frame(仍是以那个可怜的飞船为例, 世界坐标系的原点一般是在它玩耍的那个空间的某处,好比什么行星的某个固定的地方). Often, this is the space in which lighting and physics calculations are performed(一般状况下,这是进行光照计算和物理模拟的地方)component

View Coordinates(视口坐标系)orm

An important concept throughout this chapter is that of view coordinates, also often referred to as camera or eye coordinates(另外一个重要的概念就是视口坐标系,有人也叫它摄像机或者眼睛坐标系). View coordinates are relative to the position of the observer (hence the terms “camera” and “eye”) regardless of any transformations that may occur;(眼睛一般就表明的是观察者,你能够把观察者想象成一个绝对坐标) you can think of them as “absolute” coordinates. Thus, eye coordinates represent a virtual fixed coordinate system that is used as a common frame of reference. Figure 4.7 shows the view coordinate system from two viewpoints(图4.7从两个视角来看视口坐标系). On the left, the view coordinates are represented as seen by the observer of the scene (that is, perpendicular to the monitor)(左边的这个展现的是观察者看到的场景). On the right, the view coordinate system is rotated slightly so you can better see the relation of the z axis(右边这个图里,视口坐标系稍微的进行了一点旋转,这样你能更好的看到它与z轴的关系). Positive x and y are pointed right and up, respectively, from the viewer’s perspective(从观察者的视角来看,x、y的正方向指向了右边和上面). Positive z travels away from the origin toward the user, and negative z values travel farther away from the viewpoint into the screen. The screen lies at the z coordinate 0(z轴的正方向从原点指向观察者,z轴负方向从观察者指向屏幕里面,屏幕处的z坐标是0)
Understanding Transformations(理解变换)
When you draw in 3D with OpenGL, you use the Cartesian coordinate system. In the absence of any transformations, the system in use is identical to the eye coordinate system just described(在你用OpenGL画画的时候,你使用的是笛卡尔坐标系,在没有任何变换的时候,这个坐标系只能在刚才描述的那个视口坐标系下工做)server

Clip and Normalized Device Space(剪裁和NDC坐标系)

Clip space is the coordinate space in which OpenGL performs clipping(剪裁坐标系是OpenGL执行剪裁的地方). When your vertex shader writes to gl_Position, this coordinate is considered to be in clipspace(当你在vertex shader中给gl_Position赋值以后,这个坐标被认为是在剪裁空间中). This is always a four-dimensional homogenous coordinate(这个坐标永远是一个四元齐次坐标). Upon exiting clip space, all four of the vertex’s components are divided through by the w component(到离开剪裁空间的时候,全部的顶点的元素都会被w份量除). Obviously, after this, w becomes equal to 1.0. If w is not 1.0 before this division, the x, y, and z components are effectively scaled by the inverse of w(很明显,在这波操做后,w变成了1,若是w在除法操做以前不是1,则x、y、z就会被缩放). This allows for effects such as perspective foreshortening and projection(这种操做就能够产生透视、投影这样的效果). The result of the division is considered to be in normalized device coordinate space (NDC space)(这个操做结束后,坐标变到了NDC坐标系下,Normalized Device Coordinate的缩写). Clearly, if the resulting w component of a clip space coordinate is 1.0, then clip space and NDC space become identical.(很明显,若是在剪裁空间中的w份量是1.0,那么剪裁空间中的坐标和NDC空间中的坐标是同样的)

本日的翻译就到这里,明天见,拜拜~~

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院,等你来玩哦

相关文章
相关标签/搜索