reading for this module
play

Reading for This Module CPSC 314 Computer Graphics FCG Chapter 7 - PowerPoint PPT Presentation

University of British Columbia Reading for This Module CPSC 314 Computer Graphics FCG Chapter 7 Viewing Jan-Apr 2013 FCG Section 6.3.1 Windowing Transforms Tamara Munzner RB rest of Chap Viewing RB rest of App Homogeneous Coords


  1. University of British Columbia Reading for This Module CPSC 314 Computer Graphics • FCG Chapter 7 Viewing Jan-Apr 2013 • FCG Section 6.3.1 Windowing Transforms Tamara Munzner • RB rest of Chap Viewing • RB rest of App Homogeneous Coords Viewing • RB Chap Selection and Feedback • RB Sec Object Selection Using the Back http://www.ugrad.cs.ubc.ca/~cs314/Vjan2013 Buffer • (in Chap Now That You Now ) 2 Using Transformations • three ways • modelling transforms • place objects within scene (shared world) • affine transformations Viewing • viewing transforms • place camera • rigid body transformations: rotate, translate • projection transforms • change type of camera • projective transformation 3 4

  2. Rendering Pipeline Rendering Pipeline • result Scene graph Scene graph • all vertices of scene in shared Object geometry Object geometry 3D world coordinate system Modelling Modelling Transforms Transforms Viewing Viewing Transform Transform Projection Projection Transform Transform 5 6 Rendering Pipeline Rendering Pipeline • result • result Scene graph Scene graph • scene vertices in 3D view • 2D screen coordinates of Object geometry Object geometry (camera) coordinate system clipped vertices Modelling Modelling Transforms Transforms Viewing Viewing Transform Transform Projection Projection Transform Transform 7 8

  3. Viewing and Projection Rendering Pipeline • need to get from 3D world to 2D image • projection: geometric abstraction Model/View Geometry Perspective Lighting Clipping • what eyes or cameras do Transform. Database Transform. • two pieces • viewing transform: Frame- • where is the camera, what is it pointing at? Scan Depth Texturing Blending buffer Conversion Test • perspective transform: 3D to 2D • flatten to image 9 10 Rendering Pipeline OpenGL Transformation Storage • modeling and viewing stored together • possible because no intervening operations Geometry Model/View Perspective • perspective stored in separate matrix Lighting Clipping Database Transform. Transform. • specify which matrix is target of operations • common practice: return to default modelview Frame- Scan Depth Texturing Blending mode after doing projection operations buffer Conversion Test glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_PROJECTION); 11 12

  4. Coordinate Systems Projective Rendering Pipeline • result of a transformation object world viewing • names O2W W2V V2C VCS WCS OCS • convenience projection modeling viewing transformation • animal: leg, head, tail transformation transformation clipping C2N • standard conventions in graphics pipeline CCS OCS - object/model coordinate system perspective • object/modelling WCS - world coordinate system normalized divide • world device VCS - viewing/camera/eye coordinate N2D system NDCS • camera/viewing/eye viewport CCS - clipping coordinate system • screen/window transformation • raster/device NDCS - normalized device coordinate device system DCS DCS - device/display/screen coordinate system 13 14 Viewing Transformation Basic Viewing • starting spot - OpenGL y image • camera at world origin VCS plane • probably inside an object z OCS z • y axis is up y • looking down negative z axis Peye y • why? RHS with x horizontal, y vertical, z out of screen x x WCS • translate backward so scene is visible • move distance d = focal length object world viewing OCS WCS VCS • where is camera in P1 template code? modeling viewing • 5 units back, looking down -z axis transformation transformation M mod M cam OpenGL ModelView matrix 15 16

  5. Convenient Camera Motion OpenGL Viewing Transformation • rotate/translate/scale versus gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz) • eye point, gaze/lookat direction, up vector • demo: Robins transformation, projection • postmultiplies current matrix, so to be safe: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(ex,ey,ez,lx,ly,lz,ux,uy,uz) // now ok to do model transformations • demo: Nate Robins tutorial projection 17 18 Convenient Camera Motion Placing Camera in World Coords: V2W • rotate/translate/scale versus • treat camera as if it ’ s just an object • eye point, gaze/lookat direction, up vector • translate from origin to eye • rotate view vector ( lookat – eye ) to w axis • rotate around w to bring up into vw -plane y lookat y x Pref lookat WCS x Pref view WCS up view z v eye VCS up z eye Peye Peye u w 19 20

  6. Deriving V2W Transformation Deriving V2W Transformation • rotate view vector ( lookat – eye ) to w axis 1 0 0 ex � � � � 0 1 0 ey • w : normalized opposite of view/gaze vector g • translate origin to eye � � T = � � 0 0 1 ez g = � g w = � ˆ � � 0 0 0 1 � � g y y lookat lookat x Pref x Pref WCS WCS view view v v VCS VCS up up z z eye eye Peye Peye u u 21 22 w w Deriving V2W Transformation Deriving V2W Transformation • rotate around w to bring up into vw -plane • rotate from WCS xyz into uvw coordinate system with matrix that has columns u , v , w • u should be perpendicular to vw -plane, thus perpendicular to w and up vector t u = t � w g = � g w = � ˆ v = w � u • v should be perpendicular to u and w t � w g u = t � w v = w � u t � w 1 0 0 ex u x v x w x 0 � � � � y lookat � � � � 0 1 0 ey u y v y w y 0 M V2W =TR � � � � R = x Pref T = u z v z w z 0 � 0 0 1 ez � � � WCS view � � v � � 0 0 0 1 0 0 0 1 � � VCS � � up z eye • reminder: rotate from uvw to xyz coord sys with matrix M that has columns u,v,w Peye u 23 24 w

  7. V2W vs. W2V V2W vs. W2V u x v x w x 0 � � 1 0 0 ex � � � � � � u y v y w y 0 0 1 0 ey � � R = � � • M V2W =TR T = • M W2V =(M V2W ) -1 = R -1 T -1 u z v z w z 0 � � � � 0 0 1 ez � � � � 0 0 0 1 0 0 0 1 � � � � � � � � � � u x u y u z 0 1 0 0 � e x u x u y u z � e • u � � � � � � • we derived position of camera as object in world v x v y v z 0 0 1 0 � e y v x v y v z � e • v � � � � � � M world 2 view = = • invert for gluLookAt: go from world to camera! � w x w y w z 0 � � 0 0 1 � e z � � w x w y w z � e • w � � � � � � � • M W2V =(M V2W ) -1 = R -1 T -1 0 0 0 1 0 0 0 1 0 0 0 1 � � � � � � � u x u y u z 0 � � 1 0 0 � ex � � � � � v x v y v z 0 0 1 0 � ey R � 1 = T � 1 = � � � � � u x u y u z � e x � u x + � e y � u y + � e z � u z � w x w y w z 0 � � � � 0 0 1 � ez � � � � � � 0 0 0 1 0 0 0 1 � � v x v y v z � e x � v x + � e y � v y + � e z � v z � � � � M W 2 V = • inverse is transpose for orthonormal matrices � w x w y w z � e x � w x + � e y � w y + � e z � w z � � � • inverse is negative for translations 0 0 0 1 � � 25 26 Moving the Camera or the World? World vs. Camera Coordinates Example • two equivalent operations • move camera one way vs. move world other way • example • initial OpenGL camera: at origin, looking along -z axis a = (1,1) W • create a unit square parallel to camera at z = -10 C2 • translate in z by 3 possible in two ways b = (1,1) C1 = (5,3) W c • camera moves to z = -3 • Note OpenGL models viewing in left-hand coordinates c = (1,1) C2 = (1,3) C1 = (5,5) W • camera stays put, but world moves to -7 b • resulting image same either way • possible difference: are lights specified in world or view coordinates? a C1 W 27 28

  8. Pinhole Camera • ingredients • box, film, hole punch • result • picture Projections I www.kodak.com www.pinhole.org www.debevec.org/Pinhole 29 30 Pinhole Camera Pinhole Camera • theoretical perfect pinhole • non-zero sized hole • light shining through tiny hole into dark space • blur: rays hit multiple points on film plane yields upside-down picture one ray multiple rays of projection of projection actual perfect pinhole pinhole film plane film plane 31 32

  9. Real Cameras Graphics Cameras • pinhole camera has small aperture (lens opening) • real pinhole camera: image inverted • minimize blur aperture eye • problem: hard to get enough light to expose point image the film plane • solution: lens  computer graphics camera: convenient equivalent • permits larger apertures • permits changing distance to film plane without actually moving it lens eye • cost: limited depth of field where image is depth point in focus of field center of image projection plane 33 34 http://en.wikipedia.org/wiki/Image:DOF-ShallowDepthofField.jpg General Projection Perspective Projection • image plane need not be perpendicular to • our camera must model perspective view plane eye point image plane eye point image plane 35 36

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend