3D Viewing.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

มุมมองใน 2 มิติ (2-D Viewing)
Objectives Define Clipping Various clipping methods. Line clipping methods.
OPENGL.
Three Dimensional Viewing
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
OpenGL (II). How to Draw a 3-D object on Screen?
2D Viewing. 2D viewing transformation is a mapping of world coordinate scene to device coordinates xw min xw max yw min yw max xv min xv max yv min yv.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Introduction to 3D viewing 3D is just like taking a photograph!
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Camera. Content Coordinate systems and transformations Viewing coordinates Coordinate transformation matrix Projections Window and viewport Acknowledgments:
2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
2 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Fall Computer Engineering METU.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Three-Dimensional Viewing Jehee Lee Seoul National University.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
Basic Projections 2D to 3D
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Chap 3 Viewing and Transformation
CS552: Computer Graphics Lecture 6: Viewing in 2D.
CS552: Computer Graphics Lecture 11: Orthographic Projection.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Perspective View Volume View Volume Far Near Window Far Near Window Center of Projection Center of Projection (a) Original Orientation (b) After Transformation.
Chapter: Viewing.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL LAB III.
3 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Three Dimensional Viewing
Computer Graphic 2 D Viewing.
Rendering Pipeline Fall, 2015.
Computer Graphics CC416 Week 14 3D Graphics.
3D Viewing cgvr.korea.ac.kr.
2D Viewing & Clipping 한신대 류승택
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
Programming with OpenGL Part 2: Complete Programs
Advanced Graphics Algorithms Ying Zhu Georgia State University
WINDOWING AND CLIPPING
OpenGL 2D Viewing Pipeline
Three-Dimensional viewing
WINDOWING AND CLIPPING
Type of View Perspective View COP(Center of Plane) Diminution of size
CSE 411 Computer Graphics Lecture #8 2D Viewing
3D Viewing.
THREE-DIMENSIONAL VIEWING II
THREE-DIMENSIONAL VIEWING
Presentation transcript:

3D Viewing

3D Viewing Transformation Pipeline MC Modeling Transformation xw yw zw xv yv zv xw yw zw xv yv zv V P0 N WC Viewing Transformation VC clipping window view volume xv yv zv PC Projection Transformation Normalization Transformation and Clipping NC znorm ynorm (1,1,1) (-1,-1,-1) viewport screen (xvmin, yvmin, 0) (xvmax, yvmax, 0) Viewport Transformation DC

3D Viewing Transformation Pipeline MC Modeling Transformation WC Viewing Transformation VC Projection Transformation PC Normalization Transformation and Clipping NC Viewport Transformation DC

3D Viewing Transformation Pipeline MC Modeling Transformation WC Viewing Transformation VC Projection Transformation PC Normalization Transformation and Clipping NC Viewport Transformation DC

3D Viewing V view up vector P0 = (x0, y0, z0) view point yw N viewplane normal Viewplane is at point zvp in negative zv direction V is perpendicular to N xw yw zw xv yv zv V P0 N

3D Viewing xv yv zv is a right-handed viewing coordinate system yv xv u n

3D Viewing Transformation from World to Viewing Coordinates: 1. Translate viewing coordinate origin to the origin of world coordinate system 2. Apply rotations to align xv yv zv axes with xw yw zw axes respectively MWC,VC = R . T yv xw yw zw xv zv P0 xw yw zw yv xv zv

3D Viewing Transformation Pipeline MC Modeling Transformation WC Viewing Transformation VC Projection Transformation PC Normalization Transformation and Clipping NC Viewport Transformation DC

Projections isometric axonometric orthogonal Parallel cavalier oblique cabinet Perspective

Projections view plane view plane Perspective projection Parallel projection

Orthogonal Projection

Orthogonal Projection Axonometric: displays more than one face of an object Isometric: projection plane intersects each coordinate axis at the sane distance from the origin Isometric

3D Viewing Transformation Pipeline MC Modeling Transformation WC Viewing Transformation VC Projection Transformation PC Normalization Transformation and Clipping NC Viewport Transformation DC

Orthogonal Projection Clipping view volume clipping window xv yv zv far plane near plane

Orthogonal Projection Normalization Mortho,norm . R . T ynorm znorm (1,1,1) yv xnorm (-1,-1,-1) xv zv

Oblique Projection Oblique projection: projection path is not perpendicular to the view plane view plane

Oblique Projection yv (xp,yp,zvp) xv zv a f (x,y,zvp) (x,y,z)

Oblique Projection xp = x + L1 (zvp – z) cos f yp = y + L1 (zvp – z) sin f shearing transformation L1 f view plane

Oblique Projection Cavalier Projection Cabinet Projection f = 450

Oblique Projection window a f Vp view volume Vp yv xv zv (xp,yp,zvp) (x,y,zvp) view volume Vp (x,y,z)

Oblique Projection MWC,VC . Morth,norm . Mobl Mobl,norm shear Vp Vp window window shear Vp Vp orthogonal coordinates MWC,VC . Morth,norm . Mobl Mobl,norm

Parallel Projection Viewer’s position View plane

Perspective Projection Viewer’s position View plane

Perspective Projection yv projection reference point (prp) xv zv view plane

Perspective Projection yv (xp,yp,zvp) (xprp,yprp,zprp) xv zv (x,y,z)

Perspective Projection At any point (xp, yp, zp) along the projection line: zp = zvp xp = x (zprp-zvp) / (zprp-z) + xprp (zvp-z) / (zprp-z) yp = y (zprp-zvp) / (zprp-z) + yprp (zvp-z) / (zprp-z)

Perspective Projection Vanishing point y x z One-point perspective projection x-axis vanishing point z-axis vanishing point Two-point perspective projection

Perspective Projection Far plane Near plane Viewer’s position

Perspective Projection Far plane Near plane Viewer’s position

Perspective Projection Clipping window Rectangular Frustum view volume q projection reference point (prp) Far clipping plane Near clipping plane

Perspective Projection P=(x, y, z, 1) Ph=(xh, yh, zh, h) xp = x (zprp-zvp) / (zprp-z) + xprp (zvp-z) / (zprp-z) yp = y (zprp-zvp) / (zprp-z) + yprp (zvp-z) / (zprp-z) h = zprp-z xh = x (zprp-zvp) + xprp (zvp-z) yp = y (zprp-zvp) + yprp (zvp-z) xp = xh /h yp = yh /h

Perspective Projection Ph= Mpers . P Mpers = zprp-zvp 0 -xprp xprpzprp 0 zprp-zvp -yprp yprpzprp 0 0 sz tz 0 0 -1 zprp

Perspective Projection Symmetric Frustum Frustum center line Far plane view volume Clipping window Near plane q view plane (xprp, yprp, zvp) (xprp, yprp, zprp)

Perspective Projection 200 600

Perspective Projection Parallelepiped view volume Symmetric Frustum Perspective Mapping Then apply normalization transformation

Perspective Projection Parallelepiped view volume Oblique Frustum Perspective Mapping (xprp, yprp, zprp)=(0,0,0) 1. Transform to asymmetric frustum (z-axis shear) 2. Normalize viewvolume

Perspective Projection shzx= -(xwmin+xwmax)/2.znear Mshear = shzy= -(ywmin+ywmax)/2.znear assuming that viewplane is at the position of the near plane Mpers = Moblpers= Mpers . Mshear 1 0 shzx 0 0 1 shzy 0 0 0 1 0 0 0 0 1 znear 0 0 0 0 -znear 0 0 0 0 sz tz 0 0 -1 0

Perspective Projection Normalization ynorm (xwmax, ywmaz, zfar) transformed frustum znorm (1,1,1) xnorm yv xv zv PRP (-1,-1,-1) (xwmin, ywmin, znear)

Perspective Projection Mnormpers = Mxyscale . Moblpers = -znearsx 0 sx(xwmin+xwmax)/2 0 0 -znearsy sy(ywmin+ywmax)/2 0 0 0 sz tz 0 0 -1 0 -2znearsx/(xwmax-xwmin) 0 (xwmin+xwmax)/(xwmax-xwmin) 0 0 -2znearsy/(ywmax-ywmin) (ywmin+ywmax)/(ywmax-ywmin) 0 0 0 (znear+zfar)/(znear-zfar) -2.znear.zfar/(znear-zfar) 0 0 -1 0

Perspective Projection For symmetric frustum with field-of-view angle q: Mnormsymmpers = Mnormsymmpers . R . T cot(q/2)/aspect 0 0 0 0 cot(q/2) 0 0 0 0 (znear+zfar)/(znear-zfar) -2.znear.zfar/(znear-zfar) 0 0 -1 0

3D Viewing Transformation Pipeline MC Modeling Transformation WC Viewing Transformation VC Projection Transformation PC Normalization Transformation and Clipping NC Viewport Transformation DC

Viewport Transformation ynorm (xvmax, yvmax, 0) znorm viewport screen (1,1,1) xnorm (-1,-1,-1) (xvmin, yvmin, 0) Mnormviewvol,3Dscreen = (xvmax-xvmin)/2 0 0 (xvmin+xvmax)/2 0 (yvmax-yvmin)/2 0 (yvmin+yvmax)/2 0 0 1/2 1/2 0 0 0 1

3D Clipping Inside if: -h≤xh≤h, -h≤yh≤h, -h≤zh≤h 6 5 4 3 2 1 Inside if: -h≤xh≤h, -h≤yh≤h, -h≤zh≤h Use sign bits of h±xh, h±yh, h±zh to set bit1-bit6 far near top bottom right left ynorm znorm (1,1,1) xnorm (-1,-1,-1)

Point Clipping Test sign bits of h±xh, h±yh, h±zh If region code is 000000 then inside otherwise eliminate

Line Clipping 1. Test region codes if 000000 for both endpoints => inside if RC1 V RC2 = 000000 => trivially accept if RC1 Λ RC2 ≠ 000000 => trivially reject 2. If a line fails the above tests, use line equation to determine whether there is an intersection

Polygon Clipping 1. Check coordinate limits of the object if all limits are inside all boundaries => save the entire object if all limits are outside any one of the boundaries => eliminate the entire object 2. Otherwise process the vertices of the polygons Apply 2D polygon clipping Clip edges to obtain new vertex list. Update polygon tables to add new surfaces If the object consists of triangle polygons, use Sutherland-Hodgman algorithm.

OpenGL Orthogonal projection glMatrixMode (GL_PROJECTION) gluOrtho (xwmin, xwmax, ywmin, ywmax, dnear, dfar) Orthogonal projection gluPerspective (theta, aspect, dnear, dfar) theta: field-of-view angle (00 – 1800) aspect: aspect ratio of the clipping window (width/height) dnear, dfar: positions of the near and far planes (must have positive values) glFrustum (xwmin, xwmax, ywmin, ywmax, dnear, dfar) if xwmin = -xwmax and ywmin = -ywmax then symmetric view volume

OpenGL glMatrixMode (GL_MODELVIEW) gluLookAt (x0, y0, z0, xref, yref, zref, Vx, Vy, Vz) Designates the origin of the viewing reference frame as, the world coordinate position P0=(x0, y0, z0) the reference position Pref=(xref, yref, zref) and the viewup vector V=(Vx, Vy, Vz) xw yw zw xv yv zv V P0

OpenGL float eye_x, eye_y, eye_z; void init (void) { glClearColor (1.0, 1.0, 1.0, 0.0); // Set display-window color to white. glMatrixMode (GL_PROJECTION); // Set projection parameters. glLoadIdentity(); gluPerspective(80.0, 1.0, 50.0, 500.0); // degree, aspect, near, far glMatrixMode (GL_MODELVIEW); eye_x = eye_y = eye_z = 60; gluLookAt(eye_x, eye_y, eye_z, 0,0,0, 0,1,0); // eye, look-at, view-up } void main (int argc, char** argv) { glutInit (&argc, argv); // Initialize GLUT. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set display mode. glutInitWindowPosition (50, 500); // Set top-left display-window position. glutInitWindowSize (400, 300); // Set display-window width and height. glutCreateWindow ("An Example OpenGL Program"); // Create display window. glViewport (0, 0, 400, 300); init ( ); // Execute initialization procedure. glutDisplayFunc (my_objects); // Send graphics to display window. glutReshapeFunc(reshape); glutKeyboardFunc(keybrd); glutMainLoop ( ); // Display everything and wait.