1 / 34

Unit-6 Viewing

Course code: 10CS65 | Computer Graphics and Visualization. Unit-6 Viewing. Engineered for Tomorrow. Prepared by : Asst. Prof. Sandhya Kumari Department : Computer Science and Engineering. Date : dd.mm.yyyy. Viewing. Classical and computer viewing Viewing with a computer

pmcclain
Download Presentation

Unit-6 Viewing

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. Course code: 10CS65 | Computer Graphics and Visualization Unit-6 Viewing Engineered for Tomorrow Prepared by : Asst. Prof. Sandhya Kumari Department : Computer Science and Engineering Date : dd.mm.yyyy

  2. Viewing • Classical and computer viewing • Viewing with a computer • Positioning of the camera • Simple projections • Projections in OpenGL • Hidden-surface removal • Interactive mesh displays • Parallel-projection matrices • Perspective-projection matrices • Projections and shadows

  3. Center of projection (COP) – center of the camera lensesorigin of the camera frame Direction of Projection (DOP) – viewing from infinity Projections planar geometric projections non-planar projections Classical & Computer Viewing

  4. principal faces; architectural building-mostly orthogonal faces front, back, top, bottom, right, left faces Classical Views

  5. Multi-view orthographic projection 3 views & orthogonal preserves angles Orthographic Projections

  6. shortening of distances Views: trimetric top side Axonometric Projections

  7. Views: construction top side Oblique projection – most general parallel views Oblique Projections

  8. Vanishing point(s) one-point two-points three-points perspectives Perspective Projections

  9. right-handed x left-handed coordinates glOrtho( ...., near,far) measured from the camera glTranslate (0.0, 0.0, -d); /* moves the camera in positive dir.of z Vanishing point(s) one-point two-points three-points perspectives Camera positioning

  10. Order: rotate move away from the origin We want to see objects from distance d and from x axis direction: glMatrixMode(GL_MODEL_VIEW); glLoadIdentity ( ); glTranslate (0.0, 0.0, -d); glRotate(-90.0, 0.0, 1.0, 0.0); Camera positioning

  11. glMatrixMode(GL_MODELVIEW); glLoadIdentity (); glTranslatef(0.0, 0.0, -d); /* 3-rd */ glRotatef(35.26, 1.0, 0.0, 0.0); /* 2-nd */ glRotatef(45.0, 0.0, 1.0, 0.0); /* 1-st */ Isometric view of a cube [-1,-1,-1] x [1,1,1] Order: rotate about y-axis rotate about x-axis move away from the origin corner [-1,1,1] to be transformed to [0,1,2]  35.26° Camera positioning

  12. VRP – View Reference Point – origin is implicit set_view_reference_point(x,y,z); VPN – View Plane Normal – orientation of projection plane – camera back set_view_plane_normal(nx, ny,nz); VUP – View-UP vector - specifies what direction is up from the camera’s perspective set_view_up(vup_x, vup_y, vup_z); Unsatisfactory camera specification Starting point – world frame – description of camera position and orientation; precise type of image – perspective or parallel defined separately – Projection Matrix specification Two viewing API’s

  13. v vector is obtained by VUP vector projection on the view plane; v is orthogonal to normal n This orthogonal system is referred as viewing-coordinate system or u-v-n system with VRP added - desired camera frame The matrix that DOES the change of frames is the view-orientation matrix p = [x,y,z,1]T – view-reference point n = [nx, ny, nz,0]T – view-plane normal vup = [vupx, vupy, vupz,0]T – view-up vector Two viewing API’s

  14. New frame construction view-reference point as its origin view-plane normal as one coordinate direction two other directions u & v Default x, y, z axes become u, v, n now Model-view matrix V = T R ;v & n must be orthogonal nTv = 0 v is a projection of vup into the plane formed by n & vup – it must be a linear combination of these two vectors v =  n +vup If the length of v is ignored,  = 1 can be set and  = - pTn / nTn v = p – ( pTn / nTn ) n u = v x n Two viewing API’s

  15. Vectors u, v, n can be normalized independently to u’, v’, n’ Matrix M is a rotation matrix thatorients u’, v’, n’ system with respect to the original system We want inversion matrix RR = M-1 = MT Finally the model-view matrix V = T R For our isometric example p = (3/3) [-d,d,d,1]T n = [-1,1,1,0]T vup = [0,1,0,0]T Two viewing API’s

  16. VRP, VPN & VUP specifiescamera position Straightforward method: e – camera position(called eye-point) a – position to look at (called at point) vpn = e – a gluLookAt(eye_x, eye_y, eye_z, at_x, at_y, at_z ) ; Look-At Function

  17. For some applications others viewing transformations are needed flight simulation applications – roll, pitch, yaw angles are specified relative to the center of mass distance is counted from the center of mass of the vehicle astronomy etc. requires polar or spherical coordinates elevation, azimuth camera can rotate – twist angle Others Viewing APIs

  18. Camera is pointing in the negative z-direction , d < 0 x / z = xp / d xp = x / (z /d) yp = y / (z /d) division by z describes non-uniform foreshortening Perspective transformation preserves lines, but it is not affine it is irreversible Perspective Projections

  19. for w  0 - point represented as p = [ wx , wy , wz , w]T Usually w = 1 p = [ x , y , z , 1]T q = M p q = [ x , y , z , z/d]T q’ = [ x / (z/d) , y / (z/d) , d , 1]T = [ xp , yp , zp , 1]T Perspective transformation can be represented by 4 x 4 matrix - perspective division must be part of the pipeline Perspective Projections

  20. Orthogonal or orthographic projection is a special case After projection: xp = x yp = y zp = 0 Orthogonal Projections

  21. We haven’t taken properties of the camera so far angle of view view volume frustrum– truncated pyramid objects not within the view volume are said to be clipped out Projections in OpenGL

  22. Typical sequence: glMatrixMode (GL_PROJECTION); glLoadIdentity ( ); glFrustrum(xmin, xmax, ymin, ymax, near, far); near & far distances must be positive and measured from the COPbe careful about the signs ! Perspective viewing in OpenGL

  23. Typical sequence: glMatrixMode (GL_PROJECTION); glLoadIdentity ( ); gluPerspective (fovy, aspect, near, far); fovy – view angle in y-axis aspect – aspect ratio width/height Perspective viewing in OpenGL

  24. Typical sequence: glMatrixMode (GL_PROJECTION); glLoadIdentity ( ); glOrtho (xmin, xmax, ymin, ymax, near, far); /* restriction far > near */ Parallel viewing in OpenGL

  25. Algorithms object space image space z-buffer – requires depth or z-buffer Typical sequence: glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glEnable(GL_DEPTH_TEST); Clear the buffer before new rendering glClear(GL_DEPTH_BUFFER_BIT); /* study example in chapter 5.6 */ Hidden Surface Removal

  26. Projection Normalization – converts all projections into orthogonal projections by first distorting objects – result after projection is the same perspective view orthographic projection of distorted objects Projection Normalization

  27. glOrtho defines mappingto the standard volume - canonical volume Operations: translate to the center scaling Projection matrix P = S T Orthogonal-Projection Matrices

  28. P = S T Orthogonal-Projection Matrices

  29. Oblique projection • View plane normal not parallel to the direction of projection. It is not implemented by OpenGL; the required operation can be done using glMulMatrixfunction. • The steps are as shown in the figure. – Shear followed by orthogonal projection.

  30. Perspective normalization – canonical pyramid x = z y = z (speeds-up pyramidal clipping) near planez = zmin far planez = zmax values are negative and therefore zmax > zmin Perspective-Projection Matrices

  31. Consider a matrix N p = [ x, y, z, 1]Tq = [ x’, y’, z’, w’]T q = N p x’ = x y’ = y z’ = z + w’ = -z after dividing x’’ = - x /d y’’ = -y /d z’’ = -(+  / z) w’’= 1 if orthographic projection is applied along to z axis p’ = MorthN p = [ x, y, 0, -z ]T Perspective-Projection Matrices

  32. Pyramidal sides x = z y = z are transformed to x = 1 y = 1 front plane z = zmin to back plane z = zmax to If then z = zmin is mapped to z’’ = -1 z = zmax is mapped to z’’ = +1 Perspective-Projection Matrices

  33. Matrix N transforms the viewing frustrum to a right parallelpiped and an orthogonal projection in the transformed volume yields to the same image as does perspective projection. N is called perspective normalization matrix Perspective-Projection Matrices

  34. You have learnt mathematical background and API for projections – parallel, oblique and perspective Try to find a solution for: define transformations needed for flight simulator as a composition of existing ones application of projections for a display walls (4 x 3 screens, using non-symmetric viewing frustrum) imagine a cube in perspective projection. Observer is in front of the object inside of the object what he will see, what you will get if you use geometric transformations and projection matrices and what OpenGL gives you? Discuss results! Conclusion

More Related