CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

1 Computer Graphics Chapter 8 3D Transformations.
The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003.
Based on slides created by Edward Angel
Viewing and Transformation
Viewing and Projections
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
OpenGL (II). How to Draw a 3-D object on Screen?
Introduction to OpenGL Pipeline From Programmer View Tong-Yee Lee.
Introduction to 3D viewing 3D is just like taking a photograph!
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
Computer Graphics (fall 2009)
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Geometric transformations The Pipeline
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
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.
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.
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.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Advanced Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 31, 2003.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
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.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
©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.
Viewing and Projection
Chap 3 Viewing and Transformation
A Photograph of two papers
Viewing and Projection
CS 4731: Computer Graphics Lecture 12: More 3D Viewing Emmanuel Agu.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
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.
OpenGL LAB III.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Viewing.
Computer Viewing.
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Isaac Gang University of Mary Hardin-Baylor
CSCE 441 Computer Graphics 3-D Viewing
Projection v VP u VPN n.
CSC461: Lecture 19 Computer Viewing
Three-Dimensional viewing
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
Type of View Perspective View COP(Center of Plane) Diminution of size
The View Frustum Lecture 10 Fri, Sep 14, 2007.
University of New Mexico
Viewing (Projections)
Computer Graphics 3Practical Lesson
Computer Graphics Computer Viewing
Chapter 3 Viewing.
Projection v VP u VPN n.
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu

3D Viewing Similar to taking a photograph

Viewing Transformation Control the “lens” of the camera Project the object from 3D world to 2D screen

Viewing Transformation Control the “lens” of the camera Important camera parameters to specify Camera (eye) position (Ex,Ey,Ez) in world coordinate system Center of interest (coi) (cx, cy, cz) or lookAt point Orientation (which way is up?): Up vector (Up_x, Up_y, Up_z) world (cx, cy, cz) (ex, ey, ez) view up vector (Up_x, Up_y, Up_z)

Viewing Transformation Transformation? Form a camera (eye) coordinate frame Transform objects from world to eye space world u v n x y z Eye coordinate frame coi

Viewing Transformation Eye space? Transform to eye space can simplify many downstream operations (such as projection) in the pipeline world u v n x y z (0,0,0) coi (1,0,0) (0,1,0) (0,0,1)

Viewing Transformation OpenGL way: gluLookAt (Ex, Ey, Ez, cx, cy, cz, Up_x, Up_y, Up_z) The view up vector is usually (0,1,0) Remember to set the OpenGL matrix mode to GL_MODELVIEW first Recall: OpenGL uses 3 matrices: Modelview matrix: Projection matrix: Viewport matrix: Modelview matrix: combination of modeling matrix M and Camera transforms V

Viewing Transformation OpenGL Code: void display() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,1,0,0,0,0,1,0); display_all(); // your display routine }

Projection Transformation Different types of projection: parallel, perspective, orthographic, etc Important to control Projection type: perspective or orthographic, etc. Field of view and image aspect ratio Near and far clipping planes

Perspective Projection Similar to real world Characterized by object foreshortening Objects appear larger if they are closer to camera Need: Projection center Projection plane Projection: Connecting the object to the projection center projection plane camera

Projection?

Orthographic Projection No foreshortening effect – distance from camera does not matter The projection center is at infinite Projection calculation – just drop z coordinates

Field of View Determine how much of the world is taken into the picture Larger field of view = smaller object projection size x y z y z  field of view (view angle) center of projection

Near and Far Clipping Planes Only objects between near and far planes are drawn Near plane + far plane + field of view = Viewing Frustum x y z Near plane Far plane

Viewing Frustrum 3D counterpart of 2D world clip window Objects outside the frustum are clipped x y z Near plane Far plane Viewing Frustum

Projection Transformation In OpenGL: Set the matrix mode to GL_PROJECTION Perspective projection: use gluPerspective(fovy, aspect, near, far) or glFrustum(left, right, bottom, top, near, far) Orthographic: glOrtho(left, right, bottom, top, near, far)

gluPerspective(fovy, aspect, near, far) Aspect ratio is used to calculate the window width x y z y z fovy eye nearfar Aspect = w / h w h

glFrustum(left, right, bottom, top, near, far) Can use this function in place of gluPerspective() x y z left right bottom top nearfar

glOrtho(left, right, bottom, top, near, far) For orthographic projection x y z left right bottom top near far

Example: Projection Transformation void display() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJETION); glLoadIdentity(); gluPerspective(fove, aspect, near, far); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,1,0,0,0,0,1,0); display_all(); // your display routine }

Flexible Camera Control Sometimes, we want camera to move Just like control a airplane’s orientation Use aviation terms for this pitch  x y yaw  y x roll 

Yaw, pitch, roll? Think about being in an airplane Pitch: nose up-down Roll: roll body of plane Yaw: move nose side to side

Flexible Camera Control Instead of provide COI, it is possible to just give camera orientation Just like control a airplane’s orientation pitch  x y yaw  y x roll 

Flexible Camera Control How to compute the viewing vector (x,y,z) from pitch() and yaw() ?  y x   = 0  = 0 R R cos() y = Rsin() x y z x = Rcos()cos() z = Rcos()cos(90-) z

Flexible Camera Control gluLookAt() does not let you to control pitch and yaw you need to User supplies ,  or roll angle Compute/maintain the vector by yourself Calculate COI = Eye + (x,y,z) Then, call gluLookAt().

References Hill, chapter 7