Three-Dimensional viewing

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Three-dimensional Viewing S. M. Lea University of North Carolina.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003.
CLASS 6 PERSPECTIVE CS770/870. Orthographic projections Isometric ObliqueIn isometric all distances along the major axes are the same.
Based on slides created by Edward Angel
Viewing and Projections
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
Introduction to 3D viewing 3D is just like taking a photograph!
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
3D Viewing.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics 3D Viewing and Projections.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
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.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu.
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.
University of North Carolina at Greensboro
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
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.
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.
Chap 3 Viewing and Transformation
Viewing and Projection
CS 4731: Computer Graphics Lecture 12: More 3D Viewing Emmanuel Agu.
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.
OpenGL LAB III.
3 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
University of North Carolina at Greensboro
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Perspective projection
Rendering Pipeline Fall, 2015.
Computer Graphics CC416 Week 14 3D Graphics.
Viewing.
University of North Carolina at Greensboro
Computer Viewing.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
Isaac Gang University of Mary Hardin-Baylor
3D Viewing cgvr.korea.ac.kr.
3D Computer Graphics (3080/GV10) Week 5-6 Tutorial 3
CSCE 441 Computer Graphics 3-D Viewing
3D Transformation Pipeline
Projection v VP u VPN n.
CSC461: Lecture 19 Computer Viewing
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
Type of View Perspective View COP(Center of Plane) Diminution of size
University of New Mexico
Computer Graphics 3Practical Lesson
Chapter 3 Viewing.
3D Viewing.
Projection v VP u VPN n.
Viewing Transformations II
Presentation transcript:

Three-Dimensional viewing Graphics 455

Perspective Projections of 3-D Objects The graphics pipeline: vertices start in world coordinates; after MV, in eye coordinates, after P, in clip coordinates; after perspective division, in normalized device coordinates; after V, in screen coordinates.

The Viewing Process parallel projection The view volume of the camera is a rectangular parallelepiped. Its side walls are fixed by coordinates of corners

The LookAt Coordinate System Camera in world coordinates:

Camera model - parallel projection y x z Near plane eye P’ Far plane P viewplane normal

Setting the View Volume To view a scene, we move the camera and aim it in a particular direction. glMatrixMode(GL_MODELVIEW); // make the modelview matrix current glLoadIdentity(); // start with a unit matrix gluLookAt(eye.x, eye.y, eye.z, look.x, look.y, look.z, up.x, up.y, up.z);

Example glMatrixMode (GL_PROJECTION); // set the view volume (world coordinates) glLoadIdentity(); glOrtho (-3.2, 3.2, -2.4, 2.4, 1, 50); glMatrixMode (GL_MODELVIEW); // place and aim the camera glLoadIdentity (); gluLookAt (4, 4, 4, 0, 1, 0, 0, 1, 0); // modeling transformations go here

Viewplane normal v -n n eye look_at u n = eye - look_at

gluLookAt and the Camera Coordinate System gluLookAt takes the points eye and look, and the vector up n must be parallel to eye - look, so it sets n = eye - look u points "off to the side", so it makes u perpendicular to both n and up: u = up x n v must be perpendicular to n and u, so it lets v = n x u Note that v and up are not necessarily in the same direction, since v must be perpendicular to n, and up need not be.

Computing vectors of the new coordinate system n = eye – look (new z-coordinate) u = up x n (new x-coordinate) v = n x u (new y-coordinate) v up eye look u

Computing vectors of the new coordinate system Example: glLookAt(4,4,4,0,1,0,0,1,0) eye=(4,4,4) look=(0,1,0) up=(0,1,0) u=(4,0,-4) v=(-12,32,-12) n=(4,3,4) After normalization u = (0.707, 0 , -0.707) v= (-0.331, 0.883, -0.331) n=(0.625, 0.469, 0.625) (dx,dy,dz)=(-eye.u,-eye.v,-eye.n)=(0,-0.883, -6.879)

Computing vectors of the new coordinate system ux uy uz dx eyex 0 vx vy vz dy eyey 0 nx ny nz dz eyez 0 0 0 0 1 1 1 u.eye +dx=0 v.eye +dy=0 n.eye +dz=0 =

Transformation matrix of the new coordinate system 0.707 0 -0.707 dx=0 -0.331 0.883 -0.331 dy=-0.883 0.625 0.469 0.625 dz=-6.879 0 0 0 1 V= Coordinates of vector D=(dx,dy,dz )are chosen to fulfill equation: V x(eyex, eyey,eyez,1 )T=(0,0,0,1) new center of coordinate system is point eye

Camera model – perspective projection y x z Near plane eye Far plane viewplane normal

Perspective projections of 3D- objects The new center of coordinate system after aplication glLookAt(..) function is in the point eye and the direction of projection is z-axis. x,y,z x*,y* focus Projection plane

Perspective projections of 3D- objects How to realize perspective projection in graphical program? Projection plane x P(x,y,z) x*,y* F z z N x*/Px=N/-Pz y

Perspective projections of 3D- objects A similar situation for y* coordinate: (x*,y*)=(N.Px /-Pz , N.Py /-Pz ) Properties of perspective projection 1. Perspective foreshortening, distances between projected points depend on the distance from projective plane B B’ A’ A

Perspective projections of 3D- objects 2. denominator 0 means that the projected point is in the camera position. We clip all objects into predefined volume. 3. By clipping we avoid also situation when projected point is “behind” focal point (positive z-coordinate). 4. Distance N serves as scaling factor. Choosing a new projective plane that is parallel to previous one create similar scaled image. 5. straight line is projected to straight line or to a point.

Projections in Open GL glFrustum(left,right,bott,top,N,F) gluPerspective(viewAngle,aspect,N,F) Both functions work together with LookAt function. After transformation to a new coordinate system, view volume is defined.

Example: Projections of the Barn View #1: The near plane coincides with the front of the barn. In camera coordinates all points on the front wall of the barn have Pz = -1 and those on the back wall have Pz = -2. So any point (Px, Py, Pz) on the front wall projects to P’ = (Px, Py) and any point on the back wall projects to P’ = (Px /2, Py / 2). The foreshortening factor is two for points on the back wall. Note that edges on the rear wall project at half their true length. Also note that edges of the barn that are actually parallel in 3D need not project as parallel.

Example (2) In part b, the camera has been moved right, but everything else is the same.

Example (3) In part c, we look down from above and right on the barn.

Projections in Open GL glFrustum(left,right,bott,top,N,F) gluPerspective(viewAngle,aspect,N,F) Both functions work together with LookAt function. After transformation to a new coordinate system, view volume is defined.

Projections in Open GL glFrustrum(left,right,bott,top,N,F) l,t B B’ eye A’ A N F r,b

Projections in Open GL gluPerspective(viewAngle,aspect,N,F) aspect alpha B B’ eye A’ A N F

Projections in Open GL Adding pseudodepth (x*,y*,z*)=(N.Px /-Pz, N.Py /-Pz, (a.Pz+b)/-Pz,) value of z* varies from -1 to 1 a=-((F+N)/(F-N)), b=(-2FN/F-N) for Pz = -N z*=-1 for Pz = -F z*=1

Projections in Open GL Projection matrix – simple case L=-(R)=B=-(T) N 0 0 0 0 N 0 0 0 0 a b 0 0 -1 0 M.(Px ,Py, Pz ,1)T=(N.Px /-Pz, N.Py /-Pz, (a.Pz+b)/-Pz,)T (N.Px /-Pz, N.Py /-Pz, (a.Pz+b)/-Pz,,1)  (N.Px /-Pz, N.Py /-Pz, 0) Projection

Transformation of the view volume glFrustum(left,right,bottom,top,N,F);

Transformation of the view volume glFrustum(-2,2,-2,2,1,10); glFrustum(-2,2,-2,2,1,10);

Transformation of the view volume glFrustum(-2,2,-2,2,1,10); glFrustum(-2,2,-2,2,1,10);

Frustum – Perspective transformation top=N tan(π/180 . viewAngle/2) bott=-top right=top*aspect left-=-right