周一到周五,每天一篇,北京時間早上7點(diǎn)準(zhǔn)時更新~
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比焦作網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式焦作網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋焦作地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。If you think about it, most 3D graphics aren’t really 3D(用腎想象一下都知道,實(shí)際上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的概念和技術(shù)來描述事物看起來如何,然后俺們就把這樣的3D數(shù)據(jù)給"干"到了2D顯示器上). We call the process of squishing 3D data down into 2D data projection(我們把3D數(shù)據(jù)變成2D數(shù)據(jù)的操作叫投影). 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(我們在這里講到的投影是指發(fā)生在頂點(diǎn)處理階段的OpenGL中的那些變換中的一個). Transformations also allow you to rotate objects around; move them about; and even stretch, shrink, and warp them(變換同樣的允許你可以旋轉(zhuǎn)物體、移動物體、揉、捏、掐等等都是可以的。反正就是讓物體發(fā)生他們本來命運(yùn)里就安排好的操作)
Coordinate Spaces in OpenGL(OpenGL中的坐標(biāo)系)
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(一系列的操作可以用一個矩陣來表達(dá),并且用向量乘以一個矩陣后,還能將向量從一個空間轉(zhuǎn)到另一個空間). Several coordinate spaces are commonly used in OpenGL programming(OpenGL里用到了很多常見的坐標(biāo)系). 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(幾何形體的變換可以在你定義頂點(diǎn)數(shù)據(jù)之后到他們顯示到熒幕上之前來做,但通通常主要涉及的是模型、視口、投影). In this section, we examine each of the coordinate spaces commonly used in 3D computer graphics (and summarized in Table 4.1)(在本章節(jié),俺們主要來講講在3D圖形學(xué)里常用的幾個坐標(biāo)系,在表4.1里列出來了), and the transforms used to move vectors between them(那些變換就是把向量在這些坐標(biāo)系之間來回折騰,想想也是過的很慘的日子,為什么人們要互相傷害)
A matrix that moves coordinates from one space to another is normally named for those spaces(一個般來講,我們矩陣的名字就代表著他們干了什么事,比如把物體的頂點(diǎn)從模型坐標(biāo)系轉(zhuǎn)到視口坐標(biāo)系的矩陣就叫模型視口矩陣). For example, a matrix that transforms an object’s vertices from model space into view space is commonly referred to as a model–view matrix
Object Coordinates(模型坐標(biāo)系)
Most of your vertex data will typically begin life in object space, which is also commonly known as model space(大多數(shù)頂點(diǎn)數(shù)據(jù)都是在模型坐標(biāo)系下定義滴,在模型坐標(biāo)系里,所有的位置都是相對于模型坐標(biāo)系的原點(diǎn)來定義滴). 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(比如一個宇宙灰船,闊能,它的原點(diǎn)在飛行器鼻尖兒上,也有可能在重心處,還有可能在飛行員坐的位置,然并卵). 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建模軟件里,返回原點(diǎn),然后放大縮小應(yīng)該要讓你看見飛船的全身,太羞恥了,沒事就想著看別人全身). 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(王法在哪里?因此,把原點(diǎn)放在模型外面,感覺是沒什么卵用的。因?yàn)槔@原點(diǎn)旋轉(zhuǎn)物體的時候,會增加一個相當(dāng)大的偏移,這樣會讓人很蛋疼)
World Coordinates(世界坐標(biāo)系)
The next common coordinate space is world space. This is where coordinates are stored relative to a fixed, global origin(下一個坐標(biāo)系就是世界坐標(biāo)系了,世界坐標(biāo)系里的東西都是參考相對固定的世界坐標(biāo)系的原點(diǎn)來的). 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(還是以那個可憐的飛船為例, 世界坐標(biāo)系的原點(diǎn)通常是在它玩耍的那個空間的某處,比如什么行星的某個固定的地方). Often, this is the space in which lighting and physics calculations are performed(通常情況下,這是進(jìn)行光照計(jì)算和物理模擬的地方)
View Coordinates(視口坐標(biāo)系)
An important concept throughout this chapter is that of view coordinates, also often referred to as camera or eye coordinates(另一個重要的概念就是視口坐標(biāo)系,有人也叫它攝像機(jī)或者眼睛坐標(biāo)系). View coordinates are relative to the position of the observer (hence the terms “camera” and “eye”) regardless of any transformations that may occur;(眼睛通常就代表的是觀察者,你可以把觀察者想象成一個絕對坐標(biāo)) 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從兩個視角來看視口坐標(biāo)系). 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(右邊這個圖里,視口坐標(biāo)系稍微的進(jìn)行了一點(diǎn)旋轉(zhuǎn),這樣你能更好的看到它與z軸的關(guān)系). 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軸的正方向從原點(diǎn)指向觀察者,z軸負(fù)方向從觀察者指向屏幕里面,屏幕處的z坐標(biāo)是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畫畫的時候,你使用的是笛卡爾坐標(biāo)系,在沒有任何變換的時候,這個坐標(biāo)系只能在剛才描述的那個視口坐標(biāo)系下工作)
Clip and Normalized Device Space(剪裁和NDC坐標(biāo)系)
Clip space is the coordinate space in which OpenGL performs clipping(剪裁坐標(biāo)系是OpenGL執(zhí)行剪裁的地方). When your vertex shader writes to gl_Position, this coordinate is considered to be in clipspace(當(dāng)你在vertex shader中給gl_Position賦值之后,這個坐標(biāo)被認(rèn)為是在剪裁空間中). This is always a four-dimensional homogenous coordinate(這個坐標(biāo)永遠(yuǎn)是一個四元齊次坐標(biāo)). Upon exiting clip space, all four of the vertex’s components are divided through by the w component(到離開剪裁空間的時候,所有的頂點(diǎn)的元素都會被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(這種操作就可以產(chǎn)生透視、投影這樣的效果). The result of the division is considered to be in normalized device coordinate space (NDC space)(這個操作結(jié)束后,坐標(biāo)變到了NDC坐標(biāo)系下,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,那么剪裁空間中的坐標(biāo)和NDC空間中的坐標(biāo)是一樣的)
本日的翻譯就到這里,明天見,拜拜~~
第一時間獲取最新橋段,請關(guān)注東漢書院以及圖形之心公眾號
東漢書院,等你來玩哦
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。