3D Viewing And Projection 5

2y ago
20 Views
3 Downloads
1.11 MB
27 Pages
Last View : 15d ago
Last Download : 3m ago
Upload by : Arnav Humphrey
Transcription

3D Viewing and ProjectionReading: Chapter 5Review: Model to World Coordinatesyworld xworldzworld Describe not just the objects themselves, but specifyalso where in the world they are and how they appear(translated, rotated, scaled).

Today: World to Viewing CoordinatesWorld coordinatesyworldyviewxworldxviewViewing coordinates:Viewers (Camera) position andviewing plane.zviewzworldTransformation oordinates ViewingTransformationViewingCoordinates

The Viewing SystemThree aspects of the viewing process:1. Positioning the camera– Setting the MODELVIEW matrix2. Selecting a lens– Setting the PROJECTION matrix3. Clipping– Setting the view volumeStart with a discussion of OpenGL defaults.OpenGL Viewing Defaults

The OpenGL Camera In OpenGL, initially the world and camera frames are the same The camera is located at origin and points in the ‐z direction OpenGL also specifies a default view volume that is a cube withsides of length 2 centered at the origin:glOrtho(‐1, 1, ‐1, 1, ‐1,1);The OpenGL (default) Projection Default projection is orthogonal (orthographic) Default projection matrix is identityclipped out(z coordinates dropped)

Orthographic Projection in OpenGLglOrtho(xmin, xmax, ymin, ymax, zmin, zmax); We always view in ‐z direction zmin and zmax are specified as positive distances along –z,relative to the cameraHands‐on Session The OpenGL tutor programs Go to the class website, click on the Links section Download and compile the OpenGL tutors Run the projection tutor Use the menu to select orthographic projection Play with the parameters of glOrtho1. Double the viewing volume2. Halve the viewing volume

Positioning the Camera OpenGL viewing defaults have limitations:– fixed origin and fixed projection direction How to obtain arbitrary camera orientations and positions?Positioning the Camera Suppose that we wish to position the camera at (0, 0, 2) w.r.t. theworld. Two (equivalent) possibilities:– Transform the world prior to creation of objects:glTranslatef(0, 0, ‐2);– Position the camera with respect to the world:gluLookAt(0, 0, 2, );

Positioning the Camera – OpenGL CodeMoving the objects:glMatrixMode(GL MODELVIEW)glLoadIdentity();glTranslatef(0.0, 0.0,-2.0);Moving the camera:glMatrixMode(GL MODELVIEW);glLoadIdentity();gluLookAt(0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0. 0.0);Positioning the Camera – View Parameters A minimal view is described in terms of:UPVECTOR– Camera location: position in theworld ‐coordinates representingdistance from the origin– Viewing direction: whichdirection are we aiming thecamera – a direction vector– Camera orientation: usuallydefined by an up vectorDIRECTIONVECTOR{ 0, 0, 0}

OpenGL gluLookAtgluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);αβatequivalent to:glTranslatef(‐eyex, ‐eyey, ‐eyez);glRotatef(α, 1.0, 0.0, 0.0);glRotatef(β, 0.0, 1.0, 0.0);Understanding gluLookAty 2‐unit cube centered at (0,0,0)gluLookAt(1, 1, 1, 0, 0, 0, 0, 1, 0)z Change the eye position to get these:gluLookAt( , , ,0,0,0,0,1,0)x

gluLookAt Up‐vector EffectsySize 2 cube centered at the origin, viewed by:glMatrixMode(GL PROJECTION);glLoadIdentity();glOrtho(-4.0,4.0, -4.0, 4.0, -4.0, 4.0);zxglMatrixMode(GL MODELVIEW);glLoadIdentity();gluLookAt(1,1,1,0,0,0, 0, 1, 0);Viewed by:gluLookAt(1,1,1,0,0,0, , , );Hands‐on Session1. Run again the projection tutor Use the menu to select orthographic projection Double the viewing volume Play with the parameters of gluLookAt1. Modify the eye position2. Modify the LookAt point (center) position3. Modify the up vector. (Turn the image upside‐down.)2. Study the SpecialKey function in the robotSkeleton code How is translation implemented? What about the zoom in /zoom out operations?

Perspective Projection We have determined how objects are placedrelative to camera. But how are the objects projected to the image?(Converting from 3D to 2D)ProjectionViewerImageScenelanePniojectPro The main types of projection in computer graphics are: Parallel (orthographic) projection Perspective projection

Recall: Orthographic Projection Rays travel parallel to the z‐axis (orthogonal to the image) World point (xw, yw, zw) projects to image point (xw, yw, 0)(xw, yw, zw)(xw, yw, 0)Orthographic Projection Matrix xw yw 0 1 xw yw zw 1

Properties of Parallel Projections Parallel projections preserve parallelism (parallel linesremain parallel even after being flattened to 2D) Useful for tech‐drawing, computer aided designarchitecture, schematics etc.– This is because you can infer the original dimensions of 3Dobjects from their 2D images. Do not model what our eyes do:The Visual ConePerspective Projection

Perspective ProjectionPietro Perugino (1481‐82)Perspective Projection Creates more realistic images:– Note how parallel lines in 3D space may appear to convergeto a single point when viewed in perspective Also called central projection:– projection lines passing through the center (eye point)

Perspective ProjectionCenter ofprojectionn plaoitceProjneExtend lines from each point on the scene to the center ofprojection (camera position). Where these lines intersect withthe projection plane is where we draw the object.Orthographic vs. Perspective Object appears same size, nomatter how far from thecamera Farther objects appearsmaller Parallel lines in the worldscene are parallel lines in theimage Parallel lines in the worldscene are not generallyparallel lines in the image

Perspective ProjectionOutline:Pinhole CameraMathematics of PerspectiveOpenGL ImplementationsPinhole Camera Model Pinhole camera ‐ box with a tiny front hole and film at the back Image is upside down ‐‐ models what our eyes do

Human Eye Images are inverted on the retinaReflected Light The colours that we perceive are determined bythe nature of the light reflected from an object For example, if whitelight is shone onto agreen object mostwavelengths areabsorbed, while greenlight is reflected fromthe objectWhite LightColoursAbsorbedGreenLight

Pinhole Camera Principley(xw, yw, zw)I (?, ?, ?)lenszxf (focal length) Determine point I (?,?,?) where projection ray intersects the image.Mathematics of Perspective Determine point I (?,?,?) where the projection rayintersects the image. One coordinate is easy to determine:I (?, ?, )y(xw, yw, zw)I (?, ?, ?)lensxzf

Mathematics Warmup:Parametric Equations for Linesy 1 v 2 x Consider the line passing through origin and parallel to vector v. Line through origin parallel to v is the set of all points x with: y x y Exercise: Give parametric equation for line parallel tothrough 0 :y 5 x 1 1 passing

Parametric Equations in 3D 1 v 1 1 y 2 A 7 0 yx 2 B 2 4 z Line through (0,0,0)parallel to (1,1,1) is:x Line through A in thedirection of B is:Back to Camera Determine point I (?,?,f) where the projection rayintersects the image.y(xw, yw, zw)I (?, ?, f)lensxzf

Projection Ray Parametric equation for projection ray for world point (xw, yw, zw): x xw y t yw z zw By varying t, we can “travel” along the line. What value of t puts us on the image (makes z f)?Projection Ray Now substitute for x and y:fxwzwfy t yw ywzwf fI xw,yw, f )zw zwx t xw

Virtual Image in Front of Camera To simplify things, we form the image in front of the pinhole:y(xw, yw, zw)f fyw, f )I xw,zw zwlenszfxfImage point (?, ?, ?) How are x and ycoordinates affectedby values of zw?Projection Matrix(xw,yw,zw ) maps tof f xw, yw, f )zw zw What is the 4x4 transformation matrix? f xw ? zw f yw ? zw ? f ?1 ?Mperspective? xw ? yw ? zw ? 1

Projection Matrix 1 0Mperspective 0 0 01000110 f0 0 0 0 Does this matrix work?Projection Matrix Example: xw 1 yw 0 zw 0 zw 0 f 00100110 f0 xw 0 yw 0 zw 0 1 Or in 3D coordinates (divide by the 4th coordinate): fff xw, yw, zw f zwzw zw

Perspective in OpenGLPerspective in OpenGL Specifying a perspective view can be done inmany ways OpenGL supports two methods:– glFrustrum and gluPerspective

OpenGL glFrustumglMatrixMode(GL PROJECTION);glLoadIdentity();glFrustum(xmin, xmax, ymin, ymax, zmin, zmax);zmin and zmax are specified as positive distances along ‐zWhy near/far clipping planes? Discard things too close to the camera would block view of rest of scene Discard things too far away from camera distant objects may appear too small to be visually significant,but still take long time to render by discarding them we lose a small amount of detail butreclaim a lot of rendering time

OpenGL gluPerspectivegluPerspective(fov, aspect, near, far);(field of view [0 180])h2θθ tan h 2 near tannear22Only allows the creation of symmetric frustrums.gluPerspective Parameters

Zoom Field of view: Smaller angle means more zoomHands‐on Session Run again the projection tutor Play with projection parametersPlay with camera orientationSwitch betweenglFrustum, gluPerspective, and glOrtho

Summary 3D Viewing– Camera Positioning– Projection 3D Æ 2D Orthographic vs. Perspective Projection Projection Transformation Matrices OpenGL Viewing Functions– gluLookAt, glOrtho, glFrustrum, gluPerspective

Perspective Projection P r o j e c t i o n p l a n e Extend lines from each point on the scene to the center of projection (camera position). Where these lines intersect with the projection plane is where we draw the object. Center of projection Orthographic vs. Perspective Ob

Related Documents:

Orthographic Projection. TOPICS Object representation Glass box concept Line convention Orthographic projection of point, line, plane, surfaceand object. Multiview projection. OBJECT REPRESENTATION Axonometric projection Multiview projection. MULTIVIEW PROJECTION Three principle dimensions

Host Side Single click the control key Approve full-screen projection request from client side Client Side Click and hold the projection key to send the request of projection Host Side Single click the control key Reject projection request from client side Host Side Double click the projection key Close full-screen projection on client side

Orthographic projection is a technique that is used to create multiview drawings. Orthographic projection. is any projection of the features of an object onto an imaginary plane of projection. The . projection plane, projection line, glass box, multiview drawing Created Date:

Perspective Drawing Handbook - Joseph D'Amelio 6 . 7 Projection of 3D defined by straight projection rays called projectors Rays emulate from a center of projection Rays pass through each point of an object and intersect a projection plane to form the projection .

A projection is formed by the intersection of certain lines (projectors) with the view plane. Projectors are lines from the center of projection through each point in the object. Center of Projection Center of projection at infinity results with a parallel projection. A finite center of

Globular projection Orthographic projection Stereographic projection Mercator projection Projected CS Distorts Rule of thumb: map distortion distance 2 Not only do different projections depict shape differently, but re-projection from one projecti

orthographic projection is to imagine an object contained inside a glass box. Orthographic Projection There is a total of six glass walls surrounding the object. Each wall represents a projection plane onto which a two- dimensional object view will be created. Orthographic Projection Also referred to as a plane of projection

Coprigt TCTS n rigt reered Capter nwer e Sprint Round 16. _ 17. _ 18. _ 19. _ 20. _ 50