UT CS 354 - Viewing II: Camera,Projections and their Relations

Unformatted text preview:

Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Viewing II: Camera,Projections and their RelationsPositioning and Orienting the Camera• Positioned (VRP=view reference point) byset_view_reference_point(x,y,z)• Orientation (VPN=view plane normal and VUP = view-up vector) byset_view_plane_normal(nx,ny,nz) and set_view_up(vup_x,vup_y,vup_z)• The projection of the VUP onto the view-plane is a up-direction vector v• u = v x n a vector orthogonal to v and n . The (u,v,n) and the VRP yields the viewingcoordinate system• Camera is usually located at a point e called the eye point, and it is pointed at the atpoint a. This defines VRP, and VPN = e - a. Finally use the OpenGL utitility functiongluLookAt ()glMatrixMode(GL_MODELVIEW); glLoadIdentity();gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz);The University of Texas at Austin 1Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Projections• Mapping from 3 dimensional space to 2 dimensional subspace• Range of any projection P : R3→ R2called a projection plane• P maps lines to points• The image of any point p under P is the intersection of a projection line through p withthe projection plane.The University of Texas at Austin 2Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Taxonomy of Projections• Parallel– orthographic– oblique• Perspective– 1-pt– 2-pt– 3-ptThe University of Texas at Austin 3Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Parallel Projections• All projection lines are parallel.• An orthographic projection has projection lines orthogonal to projection plane.• Otherwise a parallel projection is an oblique projection• Particularly interesting oblique projections are the cabinet projection and the cavalierprojection.The University of Texas at Austin 4Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)The OpenGL Orthographic Matrix(1, 1, 1)(-1, -1, -1)fn• The visible volume in world space is known as the viewing volume.• Specify with the call glOrtho(l, r, b, t, n, f)•In OpenGL, the window is in the near plane• l and r are u-coordinates of left and right window boundaries in the near plane• b and t are v-coordinates of bottom and top window boundaries in the near plane• n and f are positive distances from the eye along the viewing ray to the near and farplanes• The left and right clipping planes are x = −1 and x = 1•The bottom and top clipping planes are y = −1 and y = 1•The near and far clipping planes are z = −1 and z = 1The University of Texas at Austin 5Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)x′y′z′1=1 0 0 00 1 0 00 0 0 00 0 0 1xyz1The University of Texas at Austin 6Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Perspective Projection• All projection lines pass through the center of projection (eyepoint).• Therefore also called central projection• This is not affine, but rather a projective transformation, (also discussed in previouslecture).• Differences in Perspective– 1-pt– 2-pt– 3-ptThe University of Texas at Austin 7Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Perspective Transform in Eye Coordinates• Given a point p, find its projection P(p)•Convenient to do this in eye coordinates, with center of projection at origin and z = nprojection plane• Note that eye coordinates are left-handed(0,0)zProjection plane, z = nyp’=(x’,y’,n)p=(x,y,z)yzy’n• Due to similar triangles P(p) = (nx/z, ny/z, d)• For any other point q = (kx, ky, kz), k 6= 0 on same projection line P(q) =(nx/z, ny/z, n)• If we have surfaces, we need to know which ones occlude others from the eye position• This projection loses all z information, so we cannot do occlusion testing after projectionThe University of Texas at Austin 8Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)The OpenGL Perspective Matrix• The visible volume in world space is known as the viewing pyramid or frustum.• Specify with the call glFrustum(l, r, b, t, n, f)•In OpenGL, the window is in the near plane• l and r are u-coordinates of left and right window boundaries in the near plane• b and t are v-coordinates of bottom and top window boundaries in the near plane• n and f are positive distances from the eye along the viewing ray to the near and farplanes• Maps the left and right clipping planes to x = −1 and x = 1•Maps the bottom and top clipping planes to y = −1 and y = 1•Maps the near and far clipping planes to z = −1 and z = 1(1, 1, 1)(-1, -1, -1)fnThe University of Texas at Austin 9Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Manipulating the Cameraviewing frustumyxxyzviewing frustum[-(r-l)/2,(t-b)/2,-n][(r-l)/2,-(t-b)/2,-n](t+b)/2z(r+l)/2fnblrtfn• After applying the modelview matrix, we are looking down the −z axis.• We need to move the ray from the origin through the window center onto the −z axis.• Rotation won’t do since the window wouldn’t be orthogonal to the z axis.• Translation won’t do since we need to keep the eye at the origin.The University of Texas at Austin 10Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)•We need differential translation as a function of z, i.e. shear.• When z = −n, δx should be −r+l2nand δy should be −t+b2n, so we getx′= x +r + l2nzy′= y +t + b2nzz′= zx′y′z′1=1 0r+l2n00 1t+b2n00 0 1 00 0 0 1xyz1The University of Texas at Austin 11Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Adjusting the Clipping Boundaries• For ease of clipping, we want the oblique clipping planes to have equations x = ±z andy = ±z.• This will make the window square, with boundaries l = b = −n and r = t = n.• This requires a scale to make the window this size.[-(r-l)/2,(t-b)/2,-n][n,-n,-n][(r-l)/2,-(t-b)/2,-n]zyxyxz[-n,n,-n]Thus the mapping isThe University of Texas at Austin 12Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)x′=2nxr − ly′=2nyt − bz′= zor in matrix form:x′y′z′1=2nr−l0 0 002nt−b0 00 0 1 00 0 0 1xyz1The University of Texas at Austin 13Department of Computer Sciences Graphics – Fall 2005 (Lecture 7)Field


View Full Document

UT CS 354 - Viewing II: Camera,Projections and their Relations

Download Viewing II: Camera,Projections and their Relations
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Viewing II: Camera,Projections and their Relations and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Viewing II: Camera,Projections and their Relations 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?