lecture11-1

# lecture11-1 - Introduction to Computer Graphics CS 445 /...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Computer Graphics CS 445 / 645 Angel: Interactive Computer Graphics Lecture 11 Chapter 7: Camera Transformations Announcements Midterm is one week from today • Old tests will be available • Detailed list of chapter coverage made available • Homework on Thursday to sample coverage • Material covers up to today’s class Taxonomy of Projections FVFHP Figure 6.10 Taxonomy of Projections Parallel Projection Center of projection is at infinity • Direction of projection (DOP) same for all points View Plane DOP Angel Figure 5.4 Orthographic Projections DOP perpendicular to view plane Front Angel Figure 5.5 Top Side Oblique Projections DOP not perpendicular to view plane DOP not φ = 63.4 φ = 45 Cavalier o (DOP α = 45 ) tan(α) = 1 Cabinet o (DOP α = 63.4 ) tan(α) = 2 H&B Oblique Parallel-Projection Oblique View Volume Transformed View Volume Oblique Parallel-Projection Oblique View Volume Transformed View Volume Transformation Matrix x p = x + ( zvp − z ) Vp V px V pz 1 0 0 0 0− 1− 0 0 V px V pz V py V pz 1 0 V px zvp V pz V py zvp V pz 0 1 HB Matrix 7-13 Orthographic Projection Simple Orthographic Transformation Original world units are preserved • Pixel units are preferred Orthographic: Screen Space Transformation left =10 m right = 20 m top=20 m (max pixx, max pixy) (height in pixels) bottom=10 m (0, 0) (width in pixels) Orthographic: Screen Space Transformation (Normalization) HB Matrix: 7-7 left, right, top, bottom refer to the viewing frustum in left, modeling coordinates modeling width and height are in pixel units This matrix scales and translates to accomplish the This transition in units transition Perspective Transformation First discovered by Donatello, Brunelleschi, and DaVinci First during Renaissance during Objects closer to viewer look larger Parallel lines appear to converge to single point Perspective Projection How many vanishing points? 3-Point Perspective 2-Point Perspective 1-Point Perspective Angel Figure 5.10 Perspective Projection In the real world, objects exhibit perspective In foreshortening: distant objects appear foreshortening distant smaller smaller The basic situation: Perspective Projection When we do 3-D graphics, we think of the When screen as a 2-D window onto the 3-D world: screen How tall should this bunny be? Perspective Projection The geometry of the situation is that of similar triangles. The similar View from above: View View plane X x’ = ? (0,0,0) What is x’ ? P (x, y, z) d Z Perspective Projection Desired result for a point [x, y, z, 1]T projected onto the Desired view plane: view x' x =, d z d ⋅x x x' = = , z zd y' y = d z d⋅y y y' = = , z zd What could a matrix look like to do this? z =d A Perspective Projection Matrix Answer: 1 0 Mperspective = 0 0 00 1 0 01 0 1d 0 0 0 0 A Perspective Projection Matrix Example: x 1 y 0 = z 0 z d 0 00 1 0 01 0 1d Or, in 3-D coordinates: 0 x y 0 0 z 01 x z d , y , zd d Projection Matrices Now that we can express perspective Now foreshortening as a matrix, we can compose it onto our other matrices with the usual matrix multiplication multiplication End result: a single matrix encapsulating End modeling, viewing, and projection transforms modeling, Perspective vs. Parallel Perspective projection + Size varies inversely with distance - looks realistic – Distance and angles are not (in general) preserved – Parallel lines do not (in general) remain parallel Parallel projection + Good for exact measurements + Parallel lines remain parallel – Angles are not (in general) preserved – Less realistic looking Less Classical Projections Angel Figure 5.3 Viewing in OpenGL OpenGL has multiple matrix stacks - transformation functions rightOpenGL matrix rightmultiply the top of the stack Two most important stacks: GL_MODELVIEW and GL_PROJECTION Two GL_MODELVIEW GL_PROJECTION Points get multiplied by the modelview matrix first, and then the Points projection matrix projection GL_MODELVIEW: Object->Camera GL_PROJECTION: Camera->Screen glViewport(0,0,w,h): Screen->Device OpenGL Example void SetUpViewing() { // The viewport isn’t a matrix, it’s just state... glViewport( 0, 0, window_width, window_height ); // Set up camera->screen transformation first glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 60, 1, 1, 1000 ); // fov, aspect, near, far // Set up the model->camera transformation glMatrixMode( GL_MODELVIEW ); gluLookAt( 3, 3, 2, // eye point 0, 0, 0, // look at point 0, 0, 1 ); // up vector glRotatef( theta, 0, 0, 1 ); // rotate the model glScalef( zoom, zoom, zoom ); // scale the model } A 3D Scene Notice the presence of the camera, the projection plane, and projection the world the coordinate axes Viewing transformations define how to acquire the image Viewing on the projection plane on Viewing Transformations Create a camera-centered view Camera is at origin Camera is looking along negative z-axis Camera’s ‘up’ is aligned with y-axis 2 Basic Steps Align the two coordinate frames by rotation 2 Basic Steps Translate to align origins Creating Camera Coordinate Space Specify a point where the camera is located in world Specify space, the eye point eye Specify a point in world space that we wish to become Specify the center of view, the lookat point lookat Specify a vector in world space that we wish to space point up in camera image, the up vector up Intuitive camera Intuitive movement movement Constructing Viewing Transformation, V Create a vector from eye-point to lookat-point Normalize the vector Desired rotation matrix should map this Desired vector to [0, 0, -1]T Why? vector Why? Constructing Viewing Transformation, V Construct another important vector from the Construct cross product of the lookat-vector and the vupcross vector This vector, when normalized, should align with This [1, 0, 0]T Why? [1, Why? Constructing Viewing Transformation, V One more vector to define… This vector, when normalized, should align with [0, 1, 0] T Now let’s compose the results Now Compositing Vectors to Form V We know the three world axis vectors (x, y, z) We know the three camera axis vectors (r, u, l) Viewing transformation, V, must convert from world to Viewing camera coordinate systems camera Compositing Vectors to Form V Remember • Each camera axis vector is unit length. • Each camera axis vector is perpendicular to others Camera matrix is orthogonal and normalized • Orthonormal Therefore, M-1 = MT Compositing Vectors to Form V Therefore, rotation component of viewing Therefore, transformation is just transpose of computed vectors vectors Compositing Vectors to Form V Translation component too Multiply it through Final Viewing Transformation, V To transform vertices, use this matrix: And you get this: ...
View Full Document

## This note was uploaded on 01/23/2012 for the course CS 445 taught by Professor Bloomfield,a during the Spring '08 term at UVA.

Ask a homework question - tutors are online