Presentation is loading. Please wait.

Presentation is loading. Please wait.

2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.

Similar presentations


Presentation on theme: "2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection."— Presentation transcript:

1 2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection Now: Camera with perspective projection Now: Camera with perspective projection 7.2 The Camera Revisited 7.2 The Camera Revisited –Eye, view volume, view angle, near plane, far plane, aspect ratio, viewplane. –Perspective view: P’ determined by finding where line from eye to P intersects viewplane.

2 2003CS Hons RW778 Graphics2 Chapter 7: Three-Dimensional Viewing 7.2.1 Setting the View Volume 7.2.1 Setting the View Volume –Projection matrix –gluPerspective(viewAngle, aspectRatio, N, F) 7.2.2 Positioning and Pointing the Camera 7.2.2 Positioning and Pointing the Camera –Move camera away from default position and point in given direction: Rotation and translation in modelview matrix.

3 2003CS Hons RW778 Graphics3 Chapter 7: Three-Dimensional Viewing –General camera with Arbitrary Orientation and Position »Transformation? Modelview matrix? –Attach explicit coordinate system to camera –Pitch, heading, yaw, roll –Selfstudy: pp.361-366

4 2003CS Hons RW778 Graphics4 Chapter 7: Three-Dimensional Viewing 7.3 Building a Camera in a Program 7.3 Building a Camera in a Program –Selfstudy. 7.4 Perspective Projections of 3D Objects 7.4 Perspective Projections of 3D Objects »Vertex v  modeling transformations  camera position and orientation : Now in eye coordinates »Vertex P in eye coordinates must be projected onto point (x*,y*) on near plane.

5 2003CS Hons RW778 Graphics5 Chapter 7: Three-Dimensional Viewing 7.4.1 Perspective Projection of a Point 7.4.1 Perspective Projection of a Point –Fundamental operation: Projecting 3D point into 2D coordinates on a plane. –Construct local coordinate system on near plane –(x*,y*) = (N(P x /(-P z )), N(P y,/(-P z ))

6 2003CS Hons RW778 Graphics6 Chapter 7: Three-Dimensional Viewing –Note »-P z achieves perspective foreshortening »P z =0 if P lies on plane z=0: Clip before projecting »If P z lies behind eye, also clipped before projecting. »N scales picture (size only) »Straight lines project to straight lines (proof given) –Selfstudy: Example 7.4.2 IMPORTANT!

7 2003CS Hons RW778 Graphics7 Chapter 7: Three-Dimensional Viewing 7.4.2 Perspective Projection of a Line 7.4.2 Perspective Projection of a Line –Lines parallel in 3D project to lines, but not necessarily parallel. –Lines that passed behind the eye cause “passage through infinity” – should be clipped. –Perspective projections produce geometrically realistic pictures, except for very long lines parallel to viewplane.

8 2003CS Hons RW778 Graphics8 Chapter 7: Three-Dimensional Viewing –Projecting Parallel Lines »3D line P(t) = A + c(t) »Yields (parametric form) for projection »If A+ct parallel to viewplane, then c z =0, and p(t) = N(A x +c x t,A y +c y t)/(-A z ) Slope is c y /c x »If two lines in 3D are parallel to each other and to the viewplane, they project two parallel lines.

9 2003CS Hons RW778 Graphics9 Chapter 7: Three-Dimensional Viewing »Suppose c not parallel to viewplane (c z !=0): »For large t, p(  )=(Nc x /(-c z ), Nc y /(-c z )) : vanishing point »Depends only on direction c  all parallel lines share same vanishing point, i.e. project to lines that are not parallel.

10 2003CS Hons RW778 Graphics10 Chapter 7: Three-Dimensional Viewing –Lines that pass behind the eye »B projects to B’: wrong side of viewplane »Let C move from A to B; as C moves, its projection slides further to right until it spurts off to infinity »When C moves behind eye, projection appears to left on viewplane. –Selfstudy: Example 7.4.3, –Anomaly of Viewing Long Parallel Lines

11 2003CS Hons RW778 Graphics11 Chapter 7: Three-Dimensional Viewing Perspective and the Graphics Pipeline Perspective and the Graphics Pipeline –Adding pseudodepth – if two points project to the same point, we only need to know which is nearer –Efficiency: (x*,y*,z*) = (N(P x /(-P z )), N(P y,/(-P z ), (aP z +b)/(-P z )) –Choose –1<=a,b<=1 –Let pseudodepth be –1 when P z = -N, 1 when P z = -F. –Then a = -((F+N)/(F-N)) and b = (-2FN)/(F-N). –Due to precision problems, pseudodepth values may be equal for two different pints as –P z approaches F.

12 2003CS Hons RW778 Graphics12 Chapter 7: Three-Dimensional Viewing Using Homogeneous Coordinates Using Homogeneous Coordinates –Point (P x,P y,P z,1); vector (v x,v y,v z,0) –Extend: Point has family of homogeneous coordinates (wP x,wP y,wP z,w) for any w except w=0. –To convert point from ordinary to homogeneous coordinates, append 1. –To convert point from homogenous to ordinary coordinates, divide all components by last, and discard last component.

13 2003CS Hons RW778 Graphics13 Chapter 7: Three-Dimensional Viewing –Transforming points in homogeneous coordinates: »If matrix M has last row (0 0 0 1), affine transformation MP=Q, last component of Q is w. »If M doesn’t have last row (0 0 0 1), MP=Q gives point; can divide by last component to find coordinates : perspective division. »If M doesn’t have last row (0 0 0 1), not affine but perspective transformation. »Note: perspective projection = perspective transformation + orthographic projection

14 2003CS Hons RW778 Graphics14 Chapter 7: Three-Dimensional Viewing –Geometric Nature of Perspective Transformation »Lines through eye map into lines parallel to z-axis. »Lines perpendicular to z-axis map into lines perpen- dicular to z-axis. »Transformation warps objects into new shapes. »Perspective transformation warps objects so that, when viewed with an orthographic projection, they appear the same as the original objects do when viewed with a perspective projection.

15 2003CS Hons RW778 Graphics15 Chapter 7: Three-Dimensional Viewing Transformed View Volume; Canonical View Volume –top to y=top –bottom to y=bott –left to x=left –right to x=right –parallelepiped with dimensions related to camera’s properties –Scale and shift into canonical view volume (cube from –1 to 1 in each dimension) –Transformation matrix known as projection matrix. –OpenGL: glFrustrum()

16 2003CS Hons RW778 Graphics16 Chapter 7: Three-Dimensional Viewing Projection matrix :

17 2003CS Hons RW778 Graphics17 Chapter 7: Three-Dimensional Viewing 7.4.4 Clipping Faces against View Volume 7.4.4 Clipping Faces against View Volume –As Cyrus-Beck, but in 4D. »Clip AC against six infinite planes. »For each wall, test whether A and C same side. If not, clip. »Calculate six boundary coordinates (BC) for A and C. All 6 positive: point inside CVV, else outside. »Both same side: trivial accept, reject. Else clip.

18 2003CS Hons RW778 Graphics18 Chapter 7: Three-Dimensional Viewing –Selfstudy: Rest of clipping algorithm, pp.387- 389. –Selfstudy: Why clip against CVV? –Selfstudy; Why clip in Homogeneous Coordinates? –Selfstudy: The Viewport Transformation.

19 2003CS Hons RW778 Graphics19 Chapter 7: Three-Dimensional Viewing 7.5 Producing Stereo Views 7.5 Producing Stereo Views –Not for exam purposes. 7.6 Taxonomy of Projections 7.6 Taxonomy of Projections

20 2003CS Hons RW778 Graphics20 Chapter 7: Three-Dimensional Viewing 7.6.1 One-, Two-, Three Point Perspective 7.6.1 One-, Two-, Three Point Perspective –Suppose n-axis of camera is perpendicular to one principal axis or another; therefore vanishing point at infinity. –Count number of finite vanishing points, i.e. number of principal exis not perp. to n. –One point Perspective »n perp. to two principal axes; two of (n x,n y,n z ) must be 0.

21 2003CS Hons RW778 Graphics21 Chapter 7: Three-Dimensional Viewing –

22 2003CS Hons RW778 Graphics22 Chapter 7: Three-Dimensional Viewing 7.6.2 Parallel Projections 7.6.2 Parallel Projections –Perspective projection: Points projected along projectors that converge on eye –Parallel projection: All projectors have same direction d. –Two types: oblique orthographic

23 2003CS Hons RW778 Graphics23 Chapter 7: Three-Dimensional Viewing Orthographic Projections Orthographic Projections –d x =d y =0 –Orthographic projection in OpenGL: READ. –Types of Orthographic Projections –Multiview: »Top, front, side views »n made parallel to each of k, i, j in turn.

24 2003CS Hons RW778 Graphics24 Chapter 7: Three-Dimensional Viewing –Axonometric: »n not parallel to any principal axis »Foreshortening factor sin(  ) Isometric: all 3 principal axes foreshortened equally Isometric: all 3 principal axes foreshortened equally Dimetric: 2 foreshortened equally Dimetric: 2 foreshortened equally Trimetric: all 3 foreshortened unequally Trimetric: all 3 foreshortened unequally

25 2003CS Hons RW778 Graphics25 Chapter 7: Three-Dimensional Viewing –Oblique projections: Selfstudy.

26 2003CS Hons RW778 Graphics26 Chapter 7: Three-Dimensional Viewing Programming Task 5 : Implement Case Study 7.1 (Flying a camera through a scence), p. 405, in Hill. Programming Task 5 : Implement Case Study 7.1 (Flying a camera through a scence), p. 405, in Hill.


Download ppt "2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection."

Similar presentations


Ads by Google