5.1 Coordinate spaces in the graphics pipeline

来源:互联网 发布:免费sd卡误删数据恢复 编辑:程序博客网 时间:2024/05/18 14:27

5.1 Coordinate spaces in the graphics pipeline

Local or modelling coordinate systems

For ease of modelling it makes sense to store the vertices of a polygon mesh object with respect to some point located in or near the object. For example, we would almost certainly want to locate the origin of a cube at one of the cube vertices, or we would want to make the axis of symmetry of an object generated as a solid of revolution, coincident with the z axis. As well as storing the polygon vertices in a coordinate system that is local to the object, we would also store the polygon normal and the vertex normals. When local transformations are applied to the vertices of an object, the corresponding transformations are applied to the associated normals.

本地或模型坐标系

为了能够使建模变得更简易,可以存储一些位于或者靠近物体旁边的多边形网格物体的顶点。例如,我们很多时候都乐意去把立方体的原点设在其中的一个立方体顶点上;或者,我们会把一个坐标轴(大多时候是Z轴)设为物体的对称轴。把一个物体的多边形定点存储在一个物体的本地坐标系中的时候,我们也会存储多边形的法线或者顶点的法线。当要对物体的定点进行本地变换时,也会对相应的法线进行适当的操作。

 

World coordinate systems

Once an object has been modelled the next stage is to place it in the scene that we wish to render. All objects that together constitute a scene have their separate local coordinate systems. The global coordinate system of the scene is known as the ‘world coordinate system’. All objects have to be transformed into this common space in order that their relative spatial relationships may be defined. The act of placing an object in a scene defines the transformation required to take the object from local space to world space. If the object is being animated, then the animation system provides a time-varying transformation that takes the object into world space on a frame by frame basis.

世界坐标系

当一个物体已经建好模之后,下一步就是把它放到我们将要渲染的场景中去。一个场景中的所有物体都有他们各自独立的本地坐标系。整个场景的全球坐标系就是“世界坐标系”。所有的物体都得转换到这个共同的空间中,使得他们之间的空间关系可以被定义。而放置物体到场景中去的这一举动,需要把物体从本地空间转换到世界空间。如果这个物体具备动画,那么动画系统将会提供一个基于时间变化的转换,把物体按帧的来进行世界坐标的转换。

The scene is lit in world space. Light sources are specified, and if the shaders within the renderer function are in world space then this is the final transformation that the normals of the object have to undergo. The surface attributes of an object – texture, colour and so on – are specified and tuned in this space.

在世界空间中,场景有光照。光源会被设置,如果世界空间的渲染函数中包括了阴影,那么物体的法线所需要的最后一步转换。物体的表面属性——纹理、颜色等等——将会被设置到空间中。

Camera or eye or view coordinate system

The eye, camera or view coordinate system is a space that is used to establish viewing parameters (view point, viewing direction) and a view volume. (A virtual camera is often used as the analogy in viewing systems, but if such an allusion is made we must be careful to distinguish between external camera parameters – its position and the direction it is pointing in – and internal camera parameters or those that effect the nature and size of the image on the film plane. Most rendering systems imitate a camera which in practice would be a perfect pinhole (or lensless) device with a file plane that can be positioned at any distance with respect to the pinhole. However, there are other facilities in computer graphics that cannot be imitated by a camera and because of this the analogy is of limited utility.)

摄像机 视图坐标系

眼睛、摄像机或者视图坐标系是一个空间,这个空间用来创建观察参数(视点、观察方向)和视域。(通常会在观测系统中使用一个虚拟的摄像机,但是我们必须要仔细的区分出外部和内部的摄像机参数——即位置和指向方向,这些都会影响到图片或者影响面板的材质和大小。大多数的渲染系统都会把摄像机实际设置为一个完美的附带着一个可以被放置到任意与针孔相关距离的文件面板的针孔(或者无透镜的)设备。然而,计算机图形还有其他的不能被摄像机模拟的功用,这也就是这个类比(摄像机)的局限。)

We will now deal with a basic view coordinate system and the transformation from world space to view coordinate space. The reasons that this space exists, after all we could do directly from world space to screen space, is that certain operations (and specifications) are most conveniently carried out in view space. Standard viewing systems like that defined in the PHIGS graphics standard are more complicated in the sense that they allow the user to specify more facilities and we will deal with these in later section.

接下来,将会涉及到一个基本的视图坐标系及从世界空间到视图空间的转换。这个空间存在,是因为当我们已经把世界空间转化为屏幕空间后,很多操作和设置可以很简单的实现。诸如在PHIGS图像标准中定义的更为复杂的标准观察系统(它允许用户可以定义更多的功能)那样。

We define a viewing system as being the combination of a view coordinate system together with the specification of certain facilities such as a view volume. The simplest or minimum system would consist of the following:

·         A view point which establishes the viewer’s position in world space; this can either be the origin of the view coordinate system or the centre of projection together with a view direction N.

·         A view coordinate system defined with respect to the view point

·         A view plane onto which the two-dimensional image of the scene is projected.

·         A view frustum or volume which defines the field of view.

观测系统是视图坐标系及一些特定的功能例如视域的组合。一个最简单的系统包含如下:

·         在世界空间中有一个代表观察者位置的视点;这可以是视图坐标系统的原点或者是一个指向N的投影中心

·         一个视图坐标系的定义与视点相关

·         场景的二维图像被投影到一个视图面板上

·         定义视域的视图平截头体或体积

These entities are shown in Figure 5.2. The view coordinate, UVN, has N coincident with the viewing direction and V and U lying in a plane parallel to the view plane. We can consider the origin of the system to be the view point C. The view plane containing U and V is of infinite extent and we specify a view volume or frustum which defines a window in the view plane. It is the contents of this window – the projection of that part of the scene that is contained within the view volume – that finally appears on the screen.

视图坐标UVNN即是观测方向,UV组成了观测平面。我们可以把视点C作为坐标原点。包含UV的视图平面可以无限延伸,同时视域或截体也就定义了一个视图面板。整个窗口的内容——包括在视域中的部分场景的投影——将会最终出现在屏幕上。

Thus, using the virtual camera analogue we have a camera that can be positioned anywhere in world coordinate space, pointed in any direction and rotated about the viewing direction N.

因此,使用虚拟摄像机就是假设我们有一个可以放置在任意世界坐标空间位置的摄像机,它可以指向任意方向并且围绕着观测方向N旋转。

To transform points in world coordinate space we invoke a change of coordinate system transformation and this splits into two components: a translational one and a rotational one. Thus:

在世界坐标空间中转换点,我们通常会使用一个坐标系统转换,这分为两个部分:平移和旋转:

The only problem now is specifying a user interface for the system and mapping whatever parameters are used by the interface into U, V and N. a user needs to specify C, N and V. C is easy enough. N, the viewing direction or view plane normal, can be entered say, using two angles in a spherical coordinate system – this seems reasonably intuitive:

接下来的,就是为系统和映射定义一个用户界面,其中UVN的参数可以由界面任意输入。用户需要设置CNVC非常的简单。N是观测方向或者说是视图面板的法向量,可以在球面坐标系中很直观的用两个角度来定义。

q           The azimuth angle          方位角

y          The colatitudes or elevation angle       仰角

Where

Nx = siny cosq

Ny = sinycosq

Nz = cosy

V is more problematic. For example, a user may require ‘up’ to be the same sense as ‘up’ in the world coordinate system. However, this cannot be achieved by setting:

V = (0, 0, 1)

Because V must be perpendicular to N. A sensible strategy is to allow a user to specify an approximate orientation for V, say V’ and have the system calculate V. Figure 5.3 demonstrates this. V’ is the user-specified up vector. This is projected onto the view plane:

相比之下,V就复杂一些。例如,一个用户可能会要求“上”就是世界坐标系中的“上”。然后,这不能只是通过设置V=(0,0,1)来完成,因为V必须与N垂直。一个合理的做法是让用户为V定义一个大概的方向,称为V’,并让系统计算出V。投影到视图面板上:

V = V’-(V’.N) N

And normalized. U can be specified or not depending on the user’s requirements. If U is unspecified, it is obtained from:

U则可以定义或者不用取决于用户的要求。如果U没有被设置的话,那么可以通过以下方法获得:

U = N*V

This results in a left-hand coordinate system, which although somewhat inconsistent, conforms with our intuition of a practical viewing system, which has increasing distances from the view point as increasing values along the view direction axis. Having established the viewing transformation using UVN notation, we will in subsequent sections use (Xv, Yv, Zv) to specify points in the view coordinate system.

结果是一个左手坐标系,可能会有一些不一致;符合我们对于实际的观测系统的直观想法,随着观测方向的值的增加,它到视点的距离也会增加。用UVN标记法建立起观测转换,在接下来的小节中,我们将会用(Xv, Yv Zv)来定义点坐标。