110 likes | 246 Views
CSC 480 Computer Graphics K. Kirby Spring 2006. FRUST-RATION Viewing and projection. NKU CSC 480 Kirby. x. z. y. Setting up the Camera/Eye. frustum. upVector. eyePoint. fovy. targetPoint. zNear. zFar. glMatrixMode ( GL_PROJECTION) ; glLoadIdentity () ;
E N D
CSC 480 Computer Graphics K. Kirby Spring 2006 FRUST-RATION Viewing and projection. NKU CSC 480 Kirby
x z y Setting up the Camera/Eye frustum upVector eyePoint fovy targetPoint zNear zFar glMatrixMode( GL_PROJECTION) ; glLoadIdentity() ; gluPerspective(fovy, aspect, zNear, zFar) ; gluLookAt( eyePoint, targetPoint, upVector ) ; NKU CSC 480 Kirby
x y z 1 x y z 0 A Euclidean point (x,y,z) is represented by all nonzero multiplesof the column vector A point at infinity in the direction from the origin to (x,y,z) is represented by all nonzero multiples of the column vector This diagram shows the points represented by e1, e2, e3, e4. Homogenous Coordinates for Projective Geometry NKU CSC 480 Kirby
0 0 0 0 x y z w If v and w are two 4D column vectors, write v ~ w if v = kw, that is, if they represent the same point. kx ky kz kw k 0 ~ The column vector does not represent any point. Homogenous Coordinates for Projective Geometry, continued NKU CSC 480 Kirby
x y z w The End of the (Pipe)Line x/w y/w 0 1 x/w y/w z/w 1 perspective division projection (x/w, y/w) ~ vertices after multiplication by Modelview and Projection matrices for w 0 x z y canonical view volume (clip coordinates) ALWAYS [-1,1]3 NKU CSC 480 Kirby
Perspective Projection "screen" ~ 1500 NKU CSC 480 Kirby
x y 0 1 x y z 1 (x,y,0) (x,y,0) P Find a matrix P such that ~ Perspective Projection y (x,y,z) x z z=d (x,y,z) "screen" NKU CSC 480 Kirby
P depth P' P'' Projection Matrix Clip Coordinates [-1,1]3 Eye Coordinates projection matrix stack glOrtho glFrustum NKU CSC 480 Kirby
depth ymin, ymax xmin, xmax must be positive Perspective Projection Matrices -(n+w)/d 0 0 0 0 -(n+w)/d 0 0 0 0 -(2n+w)/w 2n(n+w)/w 0 0 -1 0 P= y +1 +d z -d -1 -1 +1 w n glFrustum( -d, d, -d, d, n, n+w ) ; glFrustum( left, right, bottom, top, near, far ) ; NKU CSC 480 Kirby
depth ymin, ymax xmin, xmax Orthographic Projection Matrices 1/d 0 0 0 0 1/d 0 0 0 0 -2/w -(2n+w)/w 0 0 0 1 P= y negative sign, since depth and z are conventionally opposite +d +1 z -1 -d -1 +1 n w glOrtho( -d, d, -d, d, n, n+w ) ; glOrtho( left, right, bottom, top, near, far ) ; NKU CSC 480 Kirby
depth +1 -1 -1 +1 xmin, xmax ymin, ymax Orthographic Projection Matrices: Example 1 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 P= y +1 z w=2 n= -1 -1 glOrtho( -1, 1, -1, 1, -1, 1 ) ; glOrtho( left, right, bottom, top, near, far ) ; NKU CSC 480 Kirby