10 Outline Classical and Computer Viewing Viewing with

  • Slides: 41
Download presentation

计算机图形学讲义-10 Outline • Classical and Computer Viewing • Viewing with a Computer • Positioning

计算机图形学讲义-10 Outline • Classical and Computer Viewing • Viewing with a Computer • Positioning of the Camera • Simple Projections • Projections in Open. GL

计算机图形学讲义-10 Classical and Computer Viewing • • • Classical Viewing Orthographic Projections Axonometric Projections

计算机图形学讲义-10 Classical and Computer Viewing • • • Classical Viewing Orthographic Projections Axonometric Projections Oblique Projections Perspective Viewing

计算机图形学讲义-10 Synthetic-camera Model • • • The projectors meet at the centre of projection

计算机图形学讲义-10 Synthetic-camera Model • • • The projectors meet at the centre of projection (COP). The COP corresponds to the center of the lens in the camera or in the eye. It is the origin of the camera frame in graphics systems. • The projection surface is a plane. The projectors are straight lines, based on geometric optics. The class of projections is also called planar geometric projections. • As the COP is moved to infinity, the projectors become parallel and the COP can be replaced by a direction of projection (DOP). • Views with a finite COP are called perspective views. Views with a COP at infinity is called parallel views. •

计算机图形学讲义-10 • Computer graphics systems have two fundamental types of viewing (parallel and perspective).

计算机图形学讲义-10 • Computer graphics systems have two fundamental types of viewing (parallel and perspective). • Classical graphics appears to permit a host of different views. • Classical viewing intends to show a specific relationship among an object, the viewer and the projection plane. • Computer graphics systems prefers complete independence of all specifications.

计算机图形学讲义-10 Classical Viewing Each classical view is determined by the specific relationship between the

计算机图形学讲义-10 Classical Viewing Each classical view is determined by the specific relationship between the objects and viewer.

计算机图形学讲义-10 Orthographic Projections Orthographic projections Temple and three multiview orthographic projections

计算机图形学讲义-10 Orthographic Projections Orthographic projections Temple and three multiview orthographic projections

计算机图形学讲义-10 Axonometric Projection • 轴测投影 (a) Construction of trimetric-view projection; (b) top view; (c)

计算机图形学讲义-10 Axonometric Projection • 轴测投影 (a) Construction of trimetric-view projection; (b) top view; (c) side view.

计算机图形学讲义-10 Oblique Projections (a) Construction of oblique view projection; (b) top view; (c) side

计算机图形学讲义-10 Oblique Projections (a) Construction of oblique view projection; (b) top view; (c) side view.

计算机图形学讲义-10 Perspective Projection • Projectors converge at center of projection Angel: Interactive Computer Graphics

计算机图形学讲义-10 Perspective Projection • Projectors converge at center of projection Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 10

计算机图形学讲义-10 Vanishing Points • Parallel lines (not parallel to the projection plan) on the

计算机图形学讲义-10 Vanishing Points • Parallel lines (not parallel to the projection plan) on the object converge at a single point in the projection (the vanishing point) vanishing point Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 11

计算机图形学讲义-10 Three-Point Perspective • No principal face parallel to projection plane • Three vanishing

计算机图形学讲义-10 Three-Point Perspective • No principal face parallel to projection plane • Three vanishing points for cube Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 12

计算机图形学讲义-10 Two-Point Perspective • One principal direction parallel to projection plane • Two vanishing

计算机图形学讲义-10 Two-Point Perspective • One principal direction parallel to projection plane • Two vanishing points for cube Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 13

计算机图形学讲义-10 One-Point Perspective • One principal face parallel to projection plane • Two principal

计算机图形学讲义-10 One-Point Perspective • One principal face parallel to projection plane • Two principal directions parallel to projection plane • One vanishing point for cube Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 14

计算机图形学讲义-10 Advantages and Disadvantages • Objects further from viewer are projected smaller than the

计算机图形学讲义-10 Advantages and Disadvantages • Objects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution) – Looks realistic • Equal distances along a line are not projected into equal distances (nonuniform foreshortening) • Angles preserved only in planes parallel to the projection plane • More difficult to construct by hand than parallel projections (but not more difficult by computer) Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 15

计算机图形学讲义-10 Viewing with a Computer • Viewing consists of two fundamental operations. • 1

计算机图形学讲义-10 Viewing with a Computer • Viewing consists of two fundamental operations. • 1 st we must position the camera. – This is the job of the model-view transformations, – After vertices pass through this transformation, they are in the camera frame. • 2 nd step is the application of the projection transformation. – It applies the specified projection – orthographic or perspective – to the vertices and puts objects within the specified clipping volume in a normalized clipping volume. • Default camera in Open. GL – the camera is at the origin, – pointing to the negative zdirection, – orthographic view, – Clipping volume centered at the origin, of side length 2.

计算机图形学讲义-10 Positioning of the Camera • Our starting point is the world frame. •

计算机图形学讲义-10 Positioning of the Camera • Our starting point is the world frame. • We describe the camera’s position and orientation in this frame. • The precise type of image that we wish to obtain – perspective or parallel – is determined by the projection matrix in Open. GL, the normalization transformation. • The camera is positioned initially at its default location and orientation, pointing to the negative zdirection.

计算机图形学讲义-10 • Its desired location is centered at a point called the view-reference point

计算机图形学讲义-10 • Its desired location is centered at a point called the view-reference point (VRP), given in the world frame. • Its orientation is specified by the view-plane normal (VPN) and view-up vector (VUP). – VPN gives the orientation of the projection plane, or back of the camera. – VUP fixes the projection plane or the back of the camera. • We project the VUP vector on the view plane to obtain the up-direction vector v. • We can compute a 3 rd orthogonal direction u. • This new orthogonal system is called the viewing-coordinate system or the u-v-n system. • It is the camera frame with the addition of the VRP. • The final transformation matrix.

计算机图形学讲义-10 The Look-at Function • The camera is located at a point e called

计算机图形学讲义-10 The Look-at Function • The camera is located at a point e called the eye point, specified in the world frame. • It points at a second point a, called the at point. • These points determine a VPN and VRP. – vpn = e –a. – vrp = e • We only need to specify the VUP direction for the camera. • The Open. GL utility function – glu. Look. At (eyex, eyey, eyez, atx, aty, atz, upx, upy, upz); • alters the model-view matrix for a camera.

计算机图形学讲义-10 Other Viewing APIs

计算机图形学讲义-10 Other Viewing APIs

计算机图形学讲义-10 Simple Projections • Perspective Projections • Orthogonal Projections

计算机图形学讲义-10 Simple Projections • Perspective Projections • Orthogonal Projections

计算机图形学讲义-10 Perspective Projections The division by z describes non-uniform foreshortening (透视缩短) –– images of

计算机图形学讲义-10 Perspective Projections The division by z describes non-uniform foreshortening (透视缩短) –– images of objects farther from the COP are reduced in size (diminution) compared to those close to the COP.

计算机图形学讲义-10 • General homogeneous coordinate • The perspective transformation can be represented as an

计算机图形学讲义-10 • General homogeneous coordinate • The perspective transformation can be represented as an affine projective transformation.

计算机图形学讲义-10 • The perspective projection can be carried out as an affine projective transformation

计算机图形学讲义-10 • The perspective projection can be carried out as an affine projective transformation by a 4 x 4 matrix. • We must perform a perspective division at the end.

计算机图形学讲义-10 Orthogonal Projections

计算机图形学讲义-10 Orthogonal Projections

计算机图形学讲义-10 Projections in Open. GL • • The previous projections does not take into

计算机图形学讲义-10 Projections in Open. GL • • The previous projections does not take into account the properties of the camera – the focal length of its lens or the size of the film plane. Only objects within a semi-infinite pyramid – the view volume – whose • apex (顶点) is the COP, can appear in the image. Other objects are clipped out of the scene. • • • Most graphic APIs define clipping parameters through the specification of a projection. It allows a finite clipping volume by specifying the front and back clipping planes in addition to the angle of view. The resulting view volume is a frustum.

计算机图形学讲义-10 Perspective in Open. GL • gl. Frustum (xmin, xmax, ymin, ymax, near, far);

计算机图形学讲义-10 Perspective in Open. GL • gl. Frustum (xmin, xmax, ymin, ymax, near, far); • The near and far distances must be positive and are measured from the COP to the planes, parallel to z = 0. Because the camera is pointing to the negative z direction: • – – The front clipping plane is z = - near; The back clipping plane is z = -far

计算机图形学讲义-10 • glu. Perspective (fovy, aspect, near, far) front plane • • fov: field

计算机图形学讲义-10 • glu. Perspective (fovy, aspect, near, far) front plane • • fov: field of view, i. e. , ange of view aspect: w/h

计算机图形学讲义-10 Parallel Viewing in Open. GL • gl. Ortho (xmin, xmax, ymin, ymax, near,

计算机图形学讲义-10 Parallel Viewing in Open. GL • gl. Ortho (xmin, xmax, ymin, ymax, near, far); • No restriction on the near and far distances.

计算机图形学讲义-11 Projection Matrices The Open. GL projection matrices are not quite as simple as

计算机图形学讲义-11 Projection Matrices The Open. GL projection matrices are not quite as simple as the projection matrices we derived in the previous lecture, because they support more general viewing volumes. • Projection Normalization • Open. GL Orthogonal-Projection Matrices • Oblique Projections • Open. GL Perspective-Projection Matrices

计算机图形学讲义-11 Projection Normalization • Our approach is based on a technique called projection normalization,

计算机图形学讲义-11 Projection Normalization • Our approach is based on a technique called projection normalization, which converts all projections into orthogonal projections by first distorting the objects such that the orthogonal projection of the distorted objects is the same as the desired projection of the original objects. • We can then concatenate the distortion transform with an orthogonal-projection matrix to form the desired projection matrix.

计算机图形学讲义-11 Open. GL Orthogonal-Projection Matrices • The default view volume of Open. GL is

计算机图形学讲义-11 Open. GL Orthogonal-Projection Matrices • The default view volume of Open. GL is a cube with sides given by • Equivalently we can use the function calls gl. Matrix. Mode (GL_PROJECTION); gl. Load. Identity (); gl. Ortho (-1. 0, -1. 0, 1. 0); • This volume is called the canonical view volume.

计算机图形学讲义-11 • • • gl. Ortho (xmin, xmax, ymin, ymax, near, far); Parameters near

计算机图形学讲义-11 • • • gl. Ortho (xmin, xmax, ymin, ymax, near, far); Parameters near and far are distances to the near and far clipping planes measured from a camera at the origin, relative to the camera frame (p. 229, p. 231). near and far specify the distances to the nearer and farther depth clipping planes. They can be positive or negative. These values are negative if the plane is to be behind the viewer. - gl. Ortho (-1. 0, -1. 0, 1. 0); -The near plane is at z = 1. 0, which is behind the camera; -The far plane is at z = - 1. 0, which is in front of the camera. -Open. GL looks down at z = -1. 0. - glu. Ortho 2 D(); -is the same as calling gl. Ortho() with near=0 and far=1.

计算机图形学讲义-11 • gl. Ortho (xmin, xmax, ymin, ymax, near, far); • The projection matrix

计算机图形学讲义-11 • gl. Ortho (xmin, xmax, ymin, ymax, near, far); • The projection matrix that Open. GL sets up is to transform the volume, whose – – right side is the plane x = xmin, left side is x = xmin; top is the plane y = ymax, bottom is y = ymin; front near clipping plane is z = zmax = - near, back far clipping plane is z = zmin = -far. • to the default cube. View coordinate system Normalized device coordinate system http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 Oblique Projections • Parallel oblique projections are not provided directly by the Open.

计算机图形学讲义-11 Oblique Projections • Parallel oblique projections are not provided directly by the Open. GL API. • We can obtain such view by setting up a projection matrix from scratch, or by modifying one of the standard views.

计算机图形学讲义-11 Open. GL Perspective Transformations • gl. Frustum (left, right, bottom, top, near, far);

计算机图形学讲义-11 Open. GL Perspective Transformations • gl. Frustum (left, right, bottom, top, near, far); • Parameters are similar to those for gl. Ortho (). • Both distances near and far must be positive. http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 • We consider a matrix of the following form • The choice of

计算机图形学讲义-11 • We consider a matrix of the following form • The choice of the coefficient of -1, which makes w = z, is arbitrary. Scaling this number can be matched by scaling each of the other parameters. • The perspective transform is http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 http: //www. dgp. toronto. edu/~karan/courses/csc 418/fall_2002/notes/ogl_vvol. html

计算机图形学讲义-11 Walking Through a Scene • cubeview. c – 1. 2. 3. Why the

计算机图形学讲义-11 Walking Through a Scene • cubeview. c – 1. 2. 3. Why the behavior in changing the viewer along the z-direction is not as “expected”, as that along the x- or y- directions? The look-at point is always (0, 0, 0) from the viewer. The projection transform is changed continuously when the viewer is changing along x- or y- direction. When the viewer is changing along the z-direction and viewer[2] is negative, the z-direction is reflected. This induces a sudden change in the projection transform defined by gl. Frustum.

计算机图形学讲义-11 Projections and Shadows • • • [EA, p. 261] The creation of simple

计算机图形学讲义-11 Projections and Shadows • • • [EA, p. 261] The creation of simple shadow is an interesting application of projection matrices. Although shadows are not geometric objects, they are important components of realistic images. Advanced techniques are discussed later. Simple scenes can be rendered with projection techniques by obtaining the vertices of the shadow polygon. However, this method is impractical for complex scenes.