Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11CSC 480 Computer GraphicsK. KirbySpring 2006FRUST-RATIONViewing and projection.NKU CSC 480 KirbyzxyglMatrixMode( GL_PROJECTION) ;glLoadIdentity() ;gluPerspective(fovy, aspect, zNear, zFar) ;gluLookAt( eyePoint, targetPoint, upVector ) ;zFarzNearfovyeyePointtargetPointupVectorfrustumSetting up the Camera/EyeNKU CSC 480 KirbyNKU CSC 480 KirbyA Euclidean point (x,y,z) is represented by all nonzero multiples of the column vector xyz1This diagram shows thepoints represented by e1, e2, e3, e4.A point at infinity in the direction from the origin to (x,y,z) is represented by all nonzero multiples of the column vector xyz0Homogenous Coordinates for Projective GeometryNKU CSC 480 KirbyHomogenous Coordinates for Projective Geometry, continuedThe column vector does not represent any point.0000If v and w are two 4D column vectors, write v ~ w if v = kw, that is, if they represent the same point.xyzwkxkykzkw~k 0The End of the (Pipe)Linecanonical view volume(clip coordinates)ALWAYS [-1,1]3(x/w, y/w)xyzwx/wy/w 0 1zxyNKU CSC 480 Kirbyx/wy/wz/w 1perspectivedivisionprojectionverticesafter multiplication by Modelview and Projectionmatricesfor w 0 ~Perspective ProjectionNKU CSC 480 Kirby"screen"~ 1500Perspective ProjectionNKU CSC 480 Kirbyz=d(x,y,z)(x,y,z)(x,y,0)(x,y,0)"screen"Find a matrix P such thatxyz1Pxy01~zxyProjection MatrixClip Coordinates[-1,1]3Eye CoordinatesPP'P''projection matrix stackglOrthoglFrustumdepthNKU CSC 480 KirbyPerspective Projection Matriceszy-1 +1-1+1glFrustum( -d, d, -d, d, n, n+w ) ;glFrustum( left, right, bottom, top, near, far ) ;-d+dw nmust be positive xmin, xmax ymin, ymaxdepth-(n+w)/d 0 0 0 0 -(n+w)/d 0 0 0 0 -(2n+w)/w 2n(n+w)/w 0 0 -1 0P=NKU CSC 480 Kirby1/d 0 0 0 0 1/d 0 0 0 0 -2/w -(2n+w)/w 0 0 0 1Orthographic Projection Matriceszy-1 +1-1+1glOrtho( -d, d, -d, d, n, n+w ) ;glOrtho( left, right, bottom, top, near, far ) ;-d+dwn xmin, xmax ymin, ymaxP=depthnegative sign, since depth and z are conventionally oppositeNKU CSC 480 Kirby1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1Orthographic Projection Matrices: ExamplezyglOrtho( -1, 1, -1, 1, -1, 1 ) ;glOrtho( left, right, bottom, top, near, far ) ;-1+1w=2n= -1 xmin, xmax ymin, ymaxP=-1 +1-1+1depthNKU CSC 480
View Full Document