Fundamentals of Computer Graphics Part 5 Viewing

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Three Dimensional Viewing
1 View Shandong University Software College Instructor: Zhou Yuanfeng
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
Introduction to 3D viewing 3D is just like taking a photograph!
Computer Graphics (fall 2009)
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner : Interactive Computer Graphics 6E © Addison-Wesley 2012 Classical Viewing Sai-Keung Wong ( 黃世強 ) Computer Science National.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 Computer Graphics Three-Dimensional Graphics III.
Computer Graphics Bing-Yu Chen National Taiwan University.
Fundamentals of Computer Graphics Part 5 Viewing prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
Computer Graphics I, Fall 2010 Computer Viewing.
Viewing Chapter 5. CS 480/680 2Chapter 5 -- Viewing Introduction: Introduction: We have completed our discussion of the first half of the synthetic camera.
University of North Carolina at Greensboro
2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Chapter 11 Three-Dimensional Geometric and Modeling Transformations
Three Dimensional Viewing
Viewing.
Computer Graphics - Chapter 5 Viewing
University of North Carolina at Greensboro
Computer Viewing.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
Projection Our 3-D scenes are all specified in 3-D world coordinates
Isaac Gang University of Mary Hardin-Baylor
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 18 Classical Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Projections and Normalization
CSC461: Lecture 19 Computer Viewing
Classical Viewing Ed Angel
Viewing Chapter 5.
Isaac Gang University of Mary Hardin-Baylor
Introduction to Computer Graphics with WebGL
Three Dimensional Viewing
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Projections and Hidden Surface Removal
Chap 3 Viewing Pipeline Reading:
Viewing (Projections)
University of New Mexico
Viewing (Projections)
Interactive Computer Graphics Viewing
Computer Graphics Computer Viewing
THREE-DIMENSIONAL VIEWING II
Computer Viewing Ed Angel Professor Emeritus of Computer Science
University of New Mexico
Isaac Gang University of Mary Hardin-Baylor
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

Fundamentals of Computer Graphics Part 5 Viewing prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.: Interactive Computer Graphics – A Top Down Approach with OpenGL, Addison Wesley, 2001

Classical & Computer Viewing Center of projection (COP) – center of the camera lenses origin of the camera frame Direction of Projection (DOP) – viewing from infinity Projections planar geometric projections non-planar projections Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Classical Views principal faces; architectural building-mostly orthogonal faces front, back, top, bottom, right, left faces Fundamentals of Computer Graphics

Orthographic Projections Multi-view orthographic projection (rovnoběžné promítání) 3 views & orthogonal preserves angles Fundamentals of Computer Graphics

Axonometric Projections shortening of distances Views: trimetric top side Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Oblique Projections Views: construction top side Oblique (kosoúhlá) projection – most general parallel views Fundamentals of Computer Graphics

Perspective Projections Vanishing point(s) (úběžník) one-point two-points three-points perspectives Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Camera positioning Vanishing point(s) (úběžník) one-point two-points three-points perspectives ! 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 Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Camera positioning 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); Order: rotate move away from the origin Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Camera positioning 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° 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 */ Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Two viewing API’s 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 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); Fundamentals of Computer Graphics

view-orientation matrix Two viewing API’s 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 Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Two viewing API’s 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 Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Two viewing API’s Vectors u, v, n can be normalized independently to u’, v’, n’ Matrix M is a rotation matrix that orients u’, v’, n’ system with respect to the original system We want inversion matrix R R = 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 Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Look-At Function VRP, VPN & VUP specifies camera 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 ) ; Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Others Viewing APIs 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 Fundamentals of Computer Graphics

Perspective Projections 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 Fundamentals of Computer Graphics

Perspective Projections 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 Fundamentals of Computer Graphics

Orthogonal Projections Orthogonal or orthographic projection is a special case After projection: xp = x yp = y zp = 0 Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Projections in OpenGL 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 Fundamentals of Computer Graphics

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

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

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

Hidden Surface Removal 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 */ Fundamentals of Computer Graphics

Projection Normalization 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 Fundamentals of Computer Graphics

Orthogonal-Projection Matrices glOrtho defines mapping to the standard volume - canonical volume Operations: translate to the center scaling Projection matrix P = S T Fundamentals of Computer Graphics

Orthogonal-Projection Matrices P = S T Study Oblique projection on your own – chapter 5.7.3. Fundamentals of Computer Graphics

Perspective-Projection Matrices Perspective normalization – canonical pyramid x = z y = z (speeds-up pyramidal clipping) near plane z = zmin far plane z = zmax values are negative and therefore zmax > zmin Fundamentals of Computer Graphics

Perspective-Projection Matrices Consider a matrix N p = [ x, y, z, 1]T q = [ 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 Fundamentals of Computer Graphics

Perspective-Projection Matrices 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 Fundamentals of Computer Graphics

Perspective-Projection Matrices 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 Study a non-symmetric frustrum transformations, shadows Chap.5.9. on your own Fundamentals of Computer Graphics

Fundamentals of Computer Graphics Conclusion - Chapter5 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! Fundamentals of Computer Graphics