DOC PREVIEW
CMU CS 15462 - 06-viewing

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Computer Graphics 15-462AnnouncementsProgramming assignment 1 due tomorrow (am/pm)Written assignment 1 posted later today3D Viewing & ClippingWhere do geometries come from?Pin-hole cameraPerspective projectionViewing transformationClipping lines & polygonsWhere do geometries come from?Pin-hole cameraPerspective projectionViewing transformationClipping lines & polygonsCOMPUTER GRAPHICS15-46211 Sept 2003Angel Chapter 54Computer Graphics 15-462Getting Geometry on the Screen• Transform to camera coordinate system• Transform (warp) into canonical view volume• Clip • Project to display coordinates• (Rasterize)Given geometry in the world coordinate system, how do we get it to the display?5Computer Graphics 15-462Vertex Transformation Pipeline6Computer Graphics 15-462Vertex Transformation PipelineglMatrixMode(GL_MODELVIEW)glMatrixMode(GL_PROJECTION)glViewport(…)7Computer Graphics 15-462OpenGL Transformation OverviewglMatrixMode(GL_MODELVIEW)gluLookAt(…)glMatrixMode(GL_PROJECTION)glFrustrum(…)gluPerspective(…)glOrtho(…)glViewport(x,y,width,height)8Computer Graphics 15-462Viewing and Projection• Our eyes collapse 3-D world to 2-D retinal image(brain then has to reconstruct 3D)• In CG, this process occurs by projection• Projection has two parts:–Viewing transformations: camera position and direction–Perspective/orthographic transformation: reduces 3-D to 2-D• Use homogeneous transformations• As you learned in Assignment 1, camera can be animated by changing these transformations—the root of the hierarchy12Computer Graphics 15-462Image FormationFImageWorld• Projecting a shape– project each point onto the image plane– lines are projected by projecting end points onlyFImageWorldIWNote: Since we don't want the image to be inverted, from now on we'll put F behind the image plane.Note: Since we don't want the image to be inverted, from now on we'll put F behind the image plane.13Computer Graphics 15-462Orthographic Projection• when the focal point is at infinity the rays are parallel and orthogonal to the image plane• good model for telephoto lens. No perspective effects.• when xy-plane is the image plane (x,y,z) -> (x,y,0) front orthographic viewImageWorldF14Computer Graphics 15-462A Simple Perspective Camera• Canonical case:–camera looks along the z-axis–focal point is the origin–image plane is parallel to the xy-plane at distance d– (We call d the focal length, mainly for historical reasons)Image Planeyxz[0,0,d]F=[0,0,0]15Computer Graphics 15-462Similar TrianglesYZ[0, d][0, 0][Y, Z][(d/Z)Y, d]– vup: a vector that is pointing straight up in the image usually want world “up” direction• Diagram shows y-coordinate, x-coordinate is similar• Using similar triangles– point [x,y,z] projects to [(d/z)x, (d/z)y, d]16Computer Graphics 15-462A Perspective Projection Matrix•Projection using homogeneous coordinates:– transform [x, y, z] to [(d/z)x, (d/z)y, d]• 2-D image point:– discard third coordinate– apply viewport transformation to obtain physical pixel coordinatesd 0 0 00 d 0 00 0 d 00 0 1 0         xyz1         =dx dy dz z[ ]dzxdzy d     Divide by 4thcoordinate(the “w” coordinate)17Computer Graphics 15-462Wait, there’s more!Perspective transformation can also• map rectangle in the image plane to the viewport• specify near and far clipping planes–instead of mapping z to d, transform z between znearand zfar on to a fixed range–used for z-buffer hidden surface removal• specify field-of-view (fov) angle18Computer Graphics 15-462The View Volume• Pyramid in space defined by focal point and window in the image plane (assume window mapped to viewport)• Defines visible region of space• Pyramid edges are clipping planes• Frustum = truncated pyramid with near and far clipping planes– Why near plane? Prevent points behind the camera being seen– Why far plane? Allows z to be scaled to a limited fixed-point value (z-buffering)19Computer Graphics 15-462But wait...• What if we want the camera somewhere other than the canonical location?• Alternative #1: derive a general projection matrix. (hard)• Alternative #2: transform the world so that the camera is in canonical position and orientation (much simpler)• These transformations are viewing transformations• They can be specified in many ways - some more sensible than others (beware of Foley, Angel and Watt are ok)20Computer Graphics 15-462Camera Control Values• All we need is a single translation and angle-axis rotation (orientation), but...• Good animation requires good camera control--we need better control knobs• Translation knob - move to the lookfrom point• Orientation can be specified in several ways:– specify camera rotations– specify a lookat point (solve for camera rotations)21Computer Graphics 15-462A Popular View Specification Approach• Focal length, image size/shape and clipping planes are in the perspective transformation• In addition:– lookfrom: where the focal point (camera) is– lookat: the world point to be centered in the image• Also specify camera orientation about the lookat-lookfromaxis22Computer Graphics 15-462ImplementationImplementing the lookat/lookfrom/vup viewing scheme(1) Translate by -lookfrom, bring focal point to origin(2) Rotate lookat-lookfrom to the z-axis with matrix R:» v = (lookat-lookfrom) (normalized) and z = [0,0,1]» rotation axis: a = (vxz)/|vxz|» rotation angle: cosθ = v•z and sinθ = |vxz|glRotate(q, ax, ay, az)(3) Rotate about z-axis to get vup parallel to the y-axis23Computer Graphics 15-462The Whole PictureLOOKFROM: Where the camera isLOOKAT: A point that should be centered in the imageVUP: A vector that will be pointing straight up in the imageFOV: Field-of-view angle.d: focal lengthWORLD COORDINATES24Computer Graphics 15-462It's not so complicated…Translate LOOKFROM to the originMultiply by the projection matrix and everything will be in the canonical camera positionRotate the view vector(lookat -lookfrom) ontothe z-axis. Rotate about z to bring vup to y-axisSTART HERElookatlookfromvupxyzyxxxyyzzz26Computer Graphics 15-462Clipping• There is something missing between projection and viewing...• Before projecting, we need to eliminate the portion of scene that is outside the viewing frustumxyzimage planenearfarclipped line•Need to clip objects to the


View Full Document

CMU CS 15462 - 06-viewing

Download 06-viewing
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 06-viewing 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 06-viewing 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?