1 / 33

Topics Covered

Introduction to Computer Graphics: Viewing Transformations Rama C. Hoetzlein, 2011 Cornell University Lecture Notes. Topics Covered 1. Vector & Matrix Algebra 2. Affine Transformations 3. Homogeneous Coordinates 4. Perspective Projection 5. Projection Pipeline. Complete Perspective Matrix.

frieda
Download Presentation

Topics Covered

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer Graphics:Viewing TransformationsRama C. Hoetzlein, 2011Cornell UniversityLecture Notes

  2. Topics Covered 1. Vector & Matrix Algebra2. Affine Transformations3. Homogeneous Coordinates4. Perspective Projection5. Projection Pipeline

  3. Complete Perspective Matrix Lets us specify all characteristics of the projective volume. glMatrixMode ( GL_PROJECTION )glFrustum ( l, r, b, t, near, far); gluPerspective ( fov, asp, near, far);gluOrtho2D ( l, r, b, t ); OpenGL Red Book

  4. Viewing Pipeline What does the world look like through the camera?

  5. scene with camera camera image Goal: Create a projected image of the scene from viewpoint of camera.

  6. Model Space Local objects coordinates centered on the origin X+ Z+ drawCylinder () p

  7. World Space Objects in their place in the world How do we lookthrough this camera? camera glTranslatef ( .. ) { M glRotatef ( .. ) drawCylinder () p = M p world

  8. Camera Transforms Step 1. Translate everything to camera origin

  9. Camera Transforms Step 2. Rotate around Y-axis by camera angle

  10. Camera Transforms Step 3. Rotate around X-axis by camera tilt

  11. View Space Objects oriented with the camera along the Z-axis glMatrixMode ( MODELVIEW ) V { gluLookAt (..) glTranslatef ( .. ) { M glRotatef ( .. ) drawCylinder () V { p = Rcz Rcy Tcam M p p = V M p view view

  12. NormalizedProjection Space Objects multiplied by perspective matrix,to fit in unit cube. glMatrixMode ( PROJECTION ) P { gluPerspective(..) glMatrixMode ( MODELVIEW ) V { gluLookAt (..) glTranslatef ( .. ) { M glRotatef ( .. ) drawCylinder () p = P V M p eye

  13. Clipping Objects clipped to unit cube for rasterization. glMatrixMode ( PROJECTION ) P { gluPerspective(..) glMatrixMode ( MODELVIEW ) V { gluLookAt (..) Look here! glTranslatef ( .. ) { M glRotatef ( .. ) drawCylinder () p = clip ( P V M p ) clip

  14. Screen Space Objects as they appear (flattened) on the screen.Divide by w to get 2D coordinates. glMatrixMode ( PROJECTION ) P { gluPerspective(..) glMatrixMode ( MODELVIEW ) V { gluLookAt (..) glTranslatef ( .. ) { M glRotatef ( .. ) drawCylinder () p = divw ( clip ( P V M p ) ) screen

  15. Summary…

  16. VIEWING PIPELINE Model Space World Space View Space M V P Screen Space Clipping persp.div clip Normalized Dev.Coordinates Depth Sorting p = divw ( clip ( P V M p ) ) screen Rasterization

  17. VIEWING PIPELINE – in OpenGL OpenGL has two stored matricies, one for the projection, and one for the combined model-view. glMatrixMode ( GL_PROJECTION );gluPerspective ( .. ); glMatrixMode ( GL_MODELVIEW ); gluLookAt ( fx, fy, fz, tx, ty, tz ); glRotatef ( 10, 0, 0, 1 ); drawCylinder ( .. ); tell OpenGL to setup projectioncreates a perspective matrix (P) tell OpenGL to setup model-viewcreates a view matrix (V) assigns rotation as model matrix (M)requests polygons to be drawn The clipping and divide by whappen automatically in hardware.

  18. MULTIPLE OBJECTS The scene has one view matrix (V) for the camera,but.. each object has its own MODELVIEW matrix, VM. glMatrixMode ( GL_PROJECTION );gluPerspective ( .. ); glMatrixMode ( GL_MODELVIEW ); gluLookAt ( fx, fy, fz, tx, ty, tz ); glRotatef ( 10, 0, 0, 1 ); drawCylinder ( .. ); glRotatef ( 20, 1, 0, 0 ); drawCylinder ( .. ); P V M1 M2 Whats wrong with this?

  19. MULTIPLE OBJECTS Right! (I hope).. Each object needs to set up the proper VM matrix. glMatrixMode ( GL_PROJECTION );gluPerspective ( .. ); glMatrixMode ( GL_MODELVIEW ); gluLookAt ( fx, fy, fz, tx, ty, tz ); glGetMatrixfv ( view_matrix ); glLoadMatrixf ( view_matrix ); glRotatef ( 10, 0, 0, 1 ); drawCylinder ( .. ); glLoadMatrixf ( view_matrix ); glRotatef ( 20, 1, 0, 0 ); drawCylinder ( .. ); P V M1 VM2 obj1 = P V M1obj2 = P V M2 save V

More Related