Lecture 9 Sections 2.6, 5.1, 5.2. Wed, Sep 16, 2009

Similar documents
The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Geometry: Outline. Projections. Orthographic Perspective

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

CSC 470 Computer Graphics. Three Dimensional Viewing

CSC 470 Computer Graphics

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

OpenGL Transformations

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Computer Graphics. Chapter 10 Three-Dimensional Viewing

CS 4204 Computer Graphics

Computer Viewing Computer Graphics I, Fall 2008

Fundamental Types of Viewing

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

1 (Practice 1) Introduction to OpenGL

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

3D computer graphics: geometric modeling of objects in the computer and rendering them

Computer Graphics. Lecture 04 3D Projection and Visualization. Edirlei Soares de Lima.

COMS 4160: Problems on Transformations and OpenGL

CS 543: Computer Graphics Lecture 6 (Part I): 3D Viewing and Camera Control. Emmanuel Agu

Visualisation Pipeline : The Virtual Camera

Overview. By end of the week:

Computer Graphics (CS 543) Lecture 6a: Viewing & Camera Control. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

Viewing Transformation

Computer Viewing. Prof. George Wolberg Dept. of Computer Science City College of New York

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Three-dimensional Viewing

Advanced Computer Graphics (CS & SE )

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Wire-Frame 3D Graphics Accelerator IP Core. C Library Specification

2D and 3D Viewing Basics

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Lecture 2 Sections 3.6, 3.7. Fri, Aug 28, 2009

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Computer Graphics. Basic 3D Programming. Contents

Graphics and Visualization

MORE OPENGL. Pramook Khungurn CS 4621, Fall 2011

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

CS354 Computer Graphics Viewing and Modeling

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

COMP3421. Introduction to 3D Graphics

Viewing transformations. 2004, Denis Zorin

Viewing and Projection

COMP3421. Introduction to 3D Graphics

Transformations (Rotations with Quaternions) October 24, 2005

Fachhochschule Regensburg, Germany, February 15, 2017

Three-Dimensional Viewing Hearn & Baker Chapter 7

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Overview of Projections: From a 3D world to a 2D screen.

The Projection Matrix

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

CS 428: Fall Introduction to. Viewing and projective transformations. Andrew Nealen, Rutgers, /23/2009 1

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Computer Graphics 7: Viewing in 3-D

Viewing and Projection

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CS1950U Setup Spring 2018

COMP3421. Introduction to 3D Graphics

Precept 2 Aleksey Boyko February 18, 2011

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

1 OpenGL - column vectors (column-major ordering)

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Transformation Pipeline

Jorg s Graphics Lecture Notes Coordinate Spaces 1

CS 591B Lecture 9: The OpenGL Rendering Pipeline

Lecture 4. Viewing, Projection and Viewport Transformations

Overview. By end of the week:

while Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College

3.1 Viewing and Projection

CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection. Emmanuel Agu

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

Mouse Ray Picking Explained

Viewing. Reading: Angel Ch.5

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Virtual Cameras and The Transformation Pipeline

Perspective matrix, OpenGL style

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

The Projection Matrix

Density Curves Sections

Lecture 4 of 41. Lab 1a: OpenGL Basics

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

The Model Stack. Lecture 8. Robb T. Koether. Hampden-Sydney College. Wed, Sep 6, 2017

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

THE CAMERA TRANSFORM

Transcription:

Lecture 9 Sections 2.6, 5.1, 5.2 Hampden-Sydney College Wed, Sep 16, 2009

Outline 1 2 3 4 5 6 Controlling 7

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

View The function gluperspective() establishes the size and shape (but not the position) 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.

Far plane View Far distance Near distance Eye Near plane View angle Top plane Bottom plane Side view of the view frustum.

View Top plane Left plane Height Width Right plane Bottom plane Front view of the view frustum, from the eye point.

View 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. gluperspective(45.0, 4.0/3.0, 1.0, 1000.0);

View The view frustum for a perspective projection may also be created using the function gl(). gl(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.

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

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

Perspective and Example (Perspective and ) The code. The executable.

the View 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 vector, or orientation.

the View 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.

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

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

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

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

The glulookat() function creates the view matrix and multiplies the current matrix by it. The result is the modelview matrix. In a literal sense, it moves the entire scene, thereby creating the illusion that the camera has moved.

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 Position The camera may be movable or fixed. If it is movable, then it is usually controlled by spherical coordinates with the look point at the center. Distance from the look point (camdist). Pitch angle (campitch). Yaw angle (camyaw).

Controlling 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.

Eye Position Example ( Eye Position) // Convert degrees to radians float yaw = camyaw*pi/180.0; float pitch = campitch*pi/180.0; // Compute rectangular coordinates float eye.x = camdist*cos(pitch)*sin(yaw); float eye.y = camdist*sin(pitch); float eye.z = camdist*cos(pitch)*cos(yaw); // Position the camera glulookat(eye.x, eye.y, eye.z, look.x, look.y, look.z, 0.0, 1.0, 0.0);

The keyboard() Function Example (The keyboard() Function) void keyboard(unsigned char key, int x, int y) { switch (key) { case + : case = : camdist /= zoomfactor; break; case - : case _ : camdist *= zoomfactor; break; }. } glutpostredisplay(); return;

The special() Function Example (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; break; }. } glutpostredisplay(); return;

Controlling Position Example (Controlling Position) The code. The executable.

Look Point In a similar way we can control the look point instead of the camera location. The mouse to make the camera to pan left, right, up, or down. The + and keys move the camera (and the look point) forward or backward. How do we calculate the x, y, and z coordinates of the look point?

Look Point Example ( Look Point) The code. The executable.

Homework Homework Read Section 2.6 orthographic viewing. Read Sections 5.1-5.2 perspective viewing.