週一到週五,天天一篇,北京時間早上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(那些變換就是把向量在這些座標系之間來回折騰,想一想也是過的很慘的日子,爲何人們要互相傷害)
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)
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空間中的座標是同樣的)
本日的翻譯就到這裏,明天見,拜拜~~
第一時間獲取最新橋段,請關注東漢書院以及圖形之心公衆號
東漢書院,等你來玩哦