Viewing with Computers (OpenGL)

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

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

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

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

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

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

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

Computer Viewing Computer Graphics I, Fall 2008

Announcement. Project 1 has been posted online and in dropbox. Due: 11:59:59 pm, Friday, October 14

COMP Computer Graphics and Image Processing. a6: Projections. In part 2 of our study of Viewing, we ll look at. COMP27112 Toby Howard

Computer Viewing and Projection. Overview. Computer Viewing. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Computer Graphics 7: Viewing in 3-D

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Overview. By end of the week:

So we have been talking about 3D viewing, the transformations pertaining to 3D viewing. Today we will continue on it. (Refer Slide Time: 1:15)

Lecture 4: Viewing. Topics:

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

Chapter 5. Projections and Rendering

Viewing. Reading: Angel Ch.5

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

CS 4204 Computer Graphics

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

Introduction to Computer Graphics 4. Viewing in 3D

5.8.3 Oblique Projections

Lecture 4. Viewing, Projection and Viewport Transformations

Computer Graphics. P05 Viewing in 3D. Part 1. Aleksandra Pizurica Ghent University

1 OpenGL - column vectors (column-major ordering)

Three-Dimensional Viewing Hearn & Baker Chapter 7

Rasterization Overview

Models and Architectures

COMS 4160: Problems on Transformations and OpenGL

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

CSE328 Fundamentals of Computer Graphics

Graphics pipeline and transformations. Composition of transformations

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

Prof. Feng Liu. Fall /19/2016

Fundamental Types of Viewing

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

COMP3421. Introduction to 3D Graphics

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

Geometry: Outline. Projections. Orthographic Perspective

CSE452 Computer Graphics

COMP3421. Introduction to 3D Graphics

MET71 COMPUTER AIDED DESIGN

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

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

Game Architecture. 2/19/16: Rasterization

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

Introduction to Computer Graphics with WebGL

Transforms 3: Projection Christian Miller CS Fall 2011

3D Viewing Episode 2

COMP3421. Introduction to 3D Graphics

Evening s Goals. Mathematical Transformations. Discuss the mathematical transformations that are utilized for computer graphics

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Lecture 4: 3D viewing and projections

CS452/552; EE465/505. Models & Viewing

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

CS 418: Interactive Computer Graphics. Projection

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

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

CSE 167: Introduction to Computer Graphics Lecture #3: Coordinate Systems

Models and The Viewing Pipeline. Jian Huang CS456

CS451Real-time Rendering Pipeline

Linear and Affine Transformations Coordinate Systems

Chapter 8 Three-Dimensional Viewing Operations

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

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

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

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

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

Computer Graphics and Visualization. Graphics Systems and Models

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

Projection Lecture Series

CS 465 Program 4: Modeller

Computer Graphics. Chapter 10 Three-Dimensional Viewing

3D Viewing. CS 4620 Lecture 8

THE VIEWING TRANSFORMATION

Computer Graphics. Jeng-Sheng Yeh 葉正聖 Ming Chuan University (modified from Bing-Yu Chen s slides)

Transformation Pipeline

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

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

(Refer Slide Time: 00:01:26)

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

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Last week. Machiraju/Zhang/Möller/Fuhrmann

The Graphics Pipeline and OpenGL I: Transformations!

Projection and viewing. Computer Graphics CSE 167 Lecture 4

OpenGL Transformations

CS 432 Interactive Computer Graphics

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

CS354 Computer Graphics Viewing and Modeling

Perspective transformations

Transcription:

We can now return to three-dimension?', graphics from a computer perspective. Because viewing in computer graphics is based on the synthetic-camera model, we should be able to construct any of the classical views. However, there is a fundamental difference. All the classical views were based on a particular relationship among the objects, the viewer, and the projectors. In computer graphics, we stress the independence of the object specifications and camera parameters. In terms of the pipeline architecture, viewing consists of two fundamental operations. First, we must position and orient the camera. This operation is the job of the model-view transformation. After vertices pass through this transformation, they are represented in eye or camera coordinates. The second step is the application of the projection transformation. OpenGL starts with the camera at the origin of the object frame, pointing in the negative z-direction. This camera is set up for orthogonal views and has a viewing volume that is a cube, centered at the origin and with sides of length 2. The default projection plane is the plane z = 0 and the direction of the projection is along the z-axis. Thus, objects within this box are visible and projected. Positioning of the Camera In OpenGL, the model-view and projection matrices are concatenated together to form the matrix that applies to geometric entities such as vertices. We have seen one use of the model-view matrix to position objects in space. The other is to convert from the object frame to the frame of the camera. Initially, the model-view matrix is an identity matrix, so the camera frame and the object frame are identical. In OpenGL, the camera is initially pointing in the negative z-direction (Figure 9.1). In most applications, we model our objects as being located around the origin, so a camera located at the default position with the default orientation does not see all the objects in the scene. Thus, either we must move the camera away from the objects that we wish to have in our image, or the objects must be moved in front of the camera. These are equivalent operations, as either can be looked at as positioning the frame of the camera with respect to the frame of the objects.

Figure 9.1 Consider the sequence illustrated in Figure 9.2. In part (a), we have, the initial configuration. A vertex specified at p has the same representation in both frames. In part (b), we have changed the model-view matrix to C by a sequence of transformations. The two frames are no longer the same, although C contains the information to move from the camera frame to the object frame or, equivalently, contains the information that moves the camera away from its initial position at the origin of the object frame. Figure 9.2 The next problem is how we specify the desired position of the camera through the API and how we implement camera positioning in OpenGL. Our first approach is to specify the position indirectly by applying a sequence of rotations and translations to the model-view matrix. This approach is a direct application of the instance transformation that we presented in Transformation lectures, but we must be careful for two reasons. First, we usually want to define the camera before we position any objects in the scene. Second, transformations on the camera may appear to be backward from what you might expect.

Orthogonal View : Suppose that we want to look at the same object from the positive x-axis. Now, not only do we have to move away from the object, but we also have to rotate the camera about the y-axis, as shown in Figure 9.3. We must do the translation after we rotate the camera by 90 degrees about the y-axis. In the program, the calls must be in the reverse order, as we discussed in Transformation Lectures, so we expect to see code like the following: Figure 9.3 In terms of the two frames, first we rotate the object frame relative to the camera frame, and then we move the two frames apart. Isometric View : Consider creating an isometric view of the cube. Suppose that again we start with a cube centered at the origin and aligned with the axes. Because the default camera is in the middle of the cube, we want to move the camera away from the cube by a translation. We obtain an isometric view when the camera is located symmetrically with respect to three adjacent faces of the cube. Starting with the default camera, suppose that we are now looking at the cube from somewhere on the positive z-axis. We can obtain one of the eight isometric views there is one for each vertex by first rotating the cube about the x-axis until we see the two faces symmetrically, as shown in Figure 9.4. Clearly, we obtain this view by rotating the cube by 45 degrees. The second rotation is about the y-axis. We rotate the

cube until we get the desired isometric. The required angle of rotation is 35.26 degrees about the y-axis. Figure 9.4 However, we need a clockwise rotation, so the angle must be negative. Finally, we move the camera away from the origin. Thus, our strategy is first to rotate the frame of the camera relative to the frame of the object and then to separate the two frames; the model-view matrix is of the form In OpenGL, the code for setting the model-view matrix is as follows:

Note that the clipping volume as set by glortho is relative to the camera frame. Thus, for an orthographic view, the translation of the camera does not affect the size of the image of any object, but it can affect whether or not objects are clipped because the clipping volume is measured relative to the camera. Trimetric Viewing : Consider the situation illustrated in Figure 9.5. Here a camera is located at a point e called the eye point, specified in the object frame, and it is pointed at a second point a, called the at point. The view-reference point is the eye point. Hence, we need only to add the desired up direction for the camera. The OpenGL utility function: Figure 9.5 alters the model-view matrix for a camera pointed along this line. Thus, we usually use the sequence.

Perspective Projection : As we saw in Viewing lecture, we can place the projection plane in front of the center of projection. If we do so for the configuration of Figure 9.6(a), we get the views shown in Figure 9.6. A point in space (x, y, z) is projected along a projector into the point (xp, yp, zp). All projectors pass through the origin and, because the projection plane is perpendicular to the z-axis, Figure 9.6 From the top view shown in Figure 9.6(b), we see two similar triangles whose tangents must be the same. Hence, Using the side view shown in Figure 9.6(c), we obtain a similar result for y p These equations are nonlinear. The division by z describes non-uniform scaling The images of objects farther from the center of projection are reduced in size (diminution) compared to the images of objects closer to the COP. In OpenGL, we have two functions for specifying perspective views and one for specifying parallel views. Alternatively, we can form the projection matrix directly, either by loading it, or by applying rotations, translations, and scaling to an initial identity matrix. We can specify a perspective camera view by the function:

These parameters are shown in Figure 9.7 in the camera frame. The near and far distances are measured from the COP (the origin in eye coordinates) to front and back clipping planes, both of which are parallel to the plane z 0. Because the camera is pointing in the negative z-direction, the front (near) clipping plane is the plane z = near, and the back (far) clipping plane is the plane z = far. The left, right, top, and bottom values are measured in the near (front clipping) plane. The plane x = left is to the left of the camera as viewed from the COP in the direction the camera is pointing. Similar statements hold for right, bottom, and top. Although in virtually all applications far > near > 0, as long as near far, the resulting projection matrix is valid although objects behind the center of projection the origin will be inverted in the image if they lie between the near and far planes. Figure 9.7