The View Frustum Lecture 10 Fri, Sep 14, 2007.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Defining the Viewing Coordinate System
The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003.
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
Viewing and Projections
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
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?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
Informationsteknologi Wednesday, November 14, 2007Computer Graphics - Class 81 Today’s class Orthogonal matrices Quaternions Shears Synthetic camera Viewing.
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.
Events and Coordinates Lecture 5 Fri, Sep 5, 2003.
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.
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003.
V part 1 Obtained from a Guildford County workshop-Summer, 2014.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics Zhen Jiang West Chester University.
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.
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)
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
A Photograph of two papers
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
OpenGL LAB III.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Three Dimensional Viewing
Visible Surface Detection
Perspective projection
Navigating in 3D MAX V part 1.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
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.
CSCE 441 Computer Graphics 3-D Viewing
CENG 477 Introduction to Computer Graphics
Projections and Normalization
CSC461: Lecture 19 Computer Viewing
A Photograph of two papers
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Panther Creek High V part 1
Computer Graphics Imaging
Computer Graphics Lecture 20
Computer Graphics (Spring 2003)
Three-Dimensional Viewing
Projection in 3-D Glenn G. Chappell
Chapter V Vertex Processing
Last Time Canonical view pipeline Projection Local Coordinate Space
Type of View Perspective View COP(Center of Plane) Diminution of size
2D Graphics Lecture 4 Fri, Aug 31, 2007.
Orthogonal Base Cartesian Coordinate System Works in general:
Viewing (Projections)
Viewing (Projections)
Interactive Computer Graphics Viewing
Computer Graphics 3Practical Lesson
3D Viewing.
Guilford County SciVis V part 1
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

The View Frustum Lecture 10 Fri, Sep 14, 2007

The View Frustum Recall that a frustum is a truncated pyramid. The view frustum is the region of world coordinate space that contains the part of the scene that will be rendered. It is bounded by six planes. Left and right planes Top and bottom planes Near and far planes

Creating the View Frustum The function gluPerspective() establishes the size and shape of the view frustum. It takes four parameters The vertical view angle The aspect ratio (width/height) The distance to the near plane The distance to the far plane

Creating the View Frustum Side view of the view frustum Top plane Far distance Near dist. Far plane Eye Near plane View angle (vertical) Bottom plane

Creating the View Frustum Front view of the view frustum, from the eye point. Top plane width Left plane Right plane height Near plane Bottom plane

The View Frustum Read Run

Creating the View Frustum The aspect ratio is the width divided by the height. Typical aspect ratios are 4/3 and 5/4. For example, if the screen has a resolution of 1024 768, then its aspect ratio is 4/3. Example: glPerspective(45.0, 4.0/3.0, 1.0, 1000.0);

Creating the View Frustum The view frustum may also be created using the function glFrustum(). glFrustum(left, right, bottom, top, near, far); left, right, top, and bottom are the x and y boundary values at the near plane. near and far are always given as positive distances from the viewpoint.

Orthogonal Projections The view frustum produces a perspective view on the screen. The projection is along lines that converge at the view point. On the other hand, an orthogonal projection projects along parallel lines. It is as though the view point is at infinity.

Orthogonal Projections To create an orthogonal projection, use gluOrtho() instead of gluPerspective(). gluOrtho(left, right, bottom, top, near, far); Again, near and far are always given as positive distances from the viewpoint. left, right, bottom, and top are the x and y coordinates of the planes.

Perspective and Orthogonal Projections Read Run

Positioning the View Frustum The function gluLookAt() positions the view frustum in space. It takes nine parameters, representing two points and a vector, expressed in world coordinates. The eye point, or position of the camera. The look point. The up, or orientation, vector.

Positioning the View Frustum In eye coordinates, The eye point is at (0, 0, 0), The look point is (0, 0, -1), The up vector is (0, 1, 0). The gluLookAt() function computes the transformation matrix from world coordinates to eye coordinates.

Positioning the View Frustum In world coordinates, The up vector is almost always (0, 1, 0). The look point is often the origin. The eye point is wherever we want the camera to be. Example: gluLookAt(5.0, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

Positioning the View Frustum In world coordinates, The up vector is almost always (0, 1, 0). The look point is often the origin. The eye point is wherever we want the camera to be. Example: gluLookAt(5.0, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Eye point

Positioning the View Frustum In world coordinates, The up vector is almost always (0, 1, 0). The look point is often the origin. The eye point is wherever we want the camera to be. Example: gluLookAt(5.0, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Look point

Positioning the View Frustum In world coordinates, The up vector is almost always (0, 1, 0). The look point is often the origin. The eye point is wherever we want the camera to be. Example: gluLookAt(5.0, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Up vector

The View Matrix The gluLookAt() function creates a transformation matrix and multiplies the current matrix by it. This is the view matrix. In a literal sense, it “moves” the entire scene, thereby creating the illusion that the camera has moved.

The View Matrix For this reason, it is important to call gluLookAt() after loading the identity matrix and before performing any other transformations. Typically, this is one of the first things done in the display() function.

Controlling the Camera Position The camera may be movable or fixed. If it is movable, then it is usually controlled by spherical coordinates Distance from the origin (camDist). Pitch angle (camPitch). Yaw angle (camYaw).

Controlling the Camera Position The following formulas compute the x, y, and z coordinates of the camera: x = r cos  sin  y = r sin  z = r cos  cos  where r = distance,  = pitch angle, and  = yaw angle.

Controlling the Camera Position float yawAngle = camYaw*PI/180.0; float pitchAngle = camPitch*PI/180.0; float camX = camDist*cos(pitchAngle) *sin(yawAngle); float camY = camDist*sin(pitchAngle); float camZ = camDist*cos(pitchAngle) *cos(yawAngle); gluLookAt(camX, camY, camZ, lookX, lookY, lookZ, 0.0, 1.0, 0.0);

Modifying the Angles The keyboard() function responds to the pressing of the ASCII keys. The special() function responds to the pressing of the function keys and the arrow keys.

The keyboard() Function void keyboard(unsigned char key, int x, int y) { switch (key) case '+': case '=': camDist /= zoomFactor; break; case '-': case '_': camDist *= zoomFactor; : } glutPostRedisplay(); return;

The special() Function void special(int key, int x, int y) { switch (key) case GLUT_KEY_LEFT: camYaw -= yawIncr; break; case GLUT_KEY_RIGHT: camYaw += yawIncr; : } glutPostRedisplay(); return;

Controlling the Camera Position Read Run

Controlling the Look Point In a similar way we can control the look point instead of the camera location. The arrow keys cause the camera to pan left, right, up, or down. The + and – keys cause the look point to zoom in or out from the camera. How do we calculate the x, y, and z coordinates of the look point?

Controlling the Look Point Read Run