UnderstandingTransformations(理解变换)-创新互联

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

创新互联-专业网站定制、快速模板网站建设、高性价比焦作网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式焦作网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖焦作地区。费用合理售后完善,十余年实体公司更值得信赖。

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(变换同样的允许你可以旋转物体、移动物体、揉、捏、掐等等都是可以的。反正就是让物体发生他们本来命运里就安排好的操作)

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

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 matrix

Object Coordinates(模型坐标系)

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(王法在哪里?因此,把原点放在模型外面,感觉是没什么卵用的。因为绕原点旋转物体的时候,会增加一个相当大的偏移,这样会让人很蛋疼)

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(通常情况下,这是进行光照计算和物理模拟的地方)

View Coordinates(视口坐标系)

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画画的时候,你使用的是笛卡尔坐标系,在没有任何变换的时候,这个坐标系只能在刚才描述的那个视口坐标系下工作)

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空间中的坐标是一样的)

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

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

东汉书院,等你来玩哦

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享标题:UnderstandingTransformations(理解变换)-创新互联
路径分享:http://pwwzsj.com/article/picdi.html