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

Similar documents
Computer Viewing Computer Graphics I, Fall 2008

Introduction to Computer Graphics with WebGL

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

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

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

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

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

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

CS354 Computer Graphics Viewing and Modeling

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

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

CS 432 Interactive Computer Graphics

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

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

Building Models. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Viewing with Computers (OpenGL)

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

Geometry: Outline. Projections. Orthographic Perspective

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

COMS 4160: Problems on Transformations and OpenGL

COMP3421. Introduction to 3D Graphics

Introduction to Computer Graphics 4. Viewing in 3D

Lecture 9: Transformations. CITS3003 Graphics & Animation

Fundamental Types of Viewing

2D and 3D Viewing Basics

CS452/552; EE465/505. Review & Examples

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

Computer Graphics. Basic 3D Programming. Contents

Introduction to Computer Graphics with WebGL

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

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

Transforms 3: Projection Christian Miller CS Fall 2011

COMP3421. Introduction to 3D Graphics

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

Transformations. Rotation and Scaling

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

Advanced Computer Graphics (CS & SE )

Viewing and Modeling

COMP3421. Introduction to 3D Graphics

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Overview. By end of the week:

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

Computer Graphics. Bing-Yu Chen National Taiwan University

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

Lecture 4: Viewing. Topics:

CS 4204 Computer Graphics

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

MORE OPENGL. Pramook Khungurn CS 4621, Fall 2011

CSC 470 Computer Graphics. Three Dimensional Viewing

CGT520 Transformations

CSC 470 Computer Graphics

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

Viewing and Projection

Virtual Cameras and The Transformation Pipeline

CS452/552; EE465/505. Models & Viewing

Viewing and Projection

Lecture 4: 3D viewing and projections

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

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

Viewing. Reading: Angel Ch.5

Fachhochschule Regensburg, Germany, February 15, 2017

5.8.3 Oblique Projections

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

Shading II. CITS3003 Graphics & Animation

Transformations (Rotations with Quaternions) October 24, 2005

3.1 Viewing and Projection

On the Midterm Exam. Monday, 10/17 in class. Closed book and closed notes. One-side and one page cheat sheet is allowed. A calculator is allowed

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

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Viewing Transformation

CS 543: Computer Graphics. Projection

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

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

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

Computer Graphics 7: Viewing in 3-D

Lecture 4 of 41. Lab 1a: OpenGL Basics

Three Main Themes of Computer Graphics

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lecture 10: Input, Interaction & callbacks. CITS 3003 Graphics & Animation

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

Three-Dimensional Viewing Hearn & Baker Chapter 7

Virtual Cameras & Their Matrices

Jorg s Graphics Lecture Notes Coordinate Spaces 1

Computer Graphics: Viewing in 3-D. Course Website:

Lecture 4. Viewing, Projection and Viewport Transformations

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

Lesson 24: Matrix Notation Encompasses New Transformations!

The Importance of Matrices in the DirectX API. by adding support in the programming language for frequently used calculations.

Prof. Feng Liu. Fall /19/2016

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

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

1 Preview. Dr. Scott Gordon Computer Science Dept. CSUS. Virtual Cameras, Viewing Transformations: CSc-155 Advanced Computer Graphics

Overview. By end of the week:

Course no. DIS4566 National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor

Reminder: Affine Transformations. Viewing and Projection. Shear Transformations. Transformation Matrices in OpenGL. Specification via Ratios

Viewing. Announcements. A Note About Transformations. Orthographic and Perspective Projection Implementation Vanishing Points

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

Transcription:

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

Objectives Introduce the mathematics of projection Introduce OpenGL viewing functions Look at alternate viewing APIs E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 2

Computer Viewing There are three aspects of the viewing process, all of which are implemented in the pipeline, - Positioning the camera Setting the model-view matrix - Selecting a lens Setting the projection matrix - Clipping Setting the view volume E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 3

The OpenGL Camera In OpenGL, initially the object and camera frames are the same - The default model-view matrix is an identity The camera is located at the origin and points in the negative zz direction OpenGL also specifies a default view volume that is a cube with sides of length 2 centered at the origin - The default projection matrix is an identity E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 4

The Default Projection The default projection is orthogonal The default clipping volume is a cube of side = 2 centred at the origin. 2 clipped out zz = 0 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 5

Moving the Camera Frame If we want to visualize objects that have both positive and negative zz values we can either - Move the camera in the positive zz direction Translate the camera frame - Move the objects in the negative zz direction Translate the world frame Both of these views are equivalent and are determined by the model-view matrix owant a translation (Translate(0.0,0.0,-d);) owant dd > 0, i.e., we move the objects in the zz direction. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 6

Moving Camera back from Origin default frames frames after translation by dd where dd > 0 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 7

Moving the Camera We can move the camera to any desired position by a sequence of rotations and translations Example: side view at the +xx axis looking towards the origin - Rotate the camera - Move it away from origin - Model-view matrix CC = TTTT E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 8

Moving the Camera OpenGL code Remember that the last transformation specified is first to be applied // Using mat.h mat4 t = Translate (0.0, 0.0, -d); mat4 ry = RotateY(90.0); mat4 m = t*ry; E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 9

The LookAt() Function 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. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 10

The LookAt() Function The GLU library contains the function glulookat which can be used to form the required model-view matrix. glulookat(eyex, eyey, eyez, centrex, centrey, centrez, upx, upy, upz) We need to define the eye (camera) position, the centre (fixation point), and an up direction. All are of type GLdouble. Alternatively, we can use LookAt() defined in mat.h - The function returns a mat4 matrix. - Can concatenate with modeling transformations Example: Type: GLfloat mat4 mv = LookAt(vec4 eye, vec4 at, vec4 up); E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 11

The LookAt() Function (cont.) mat4 viewmat = LookAt(eye, at, up); E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 12

Other Viewing APIs The LookAt() function is only one possible API for positioning the camera Others include - View reference point, view plane normal, view up (PHIGS, GKS-3D) - Yaw, pitch, roll (angles) - Elevation, azimuth, twist (angles) - Direction angles E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 13

PROJECTION E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 14

Default Orthographic Projection The default projection in the eye (camera) frame is orthogonal For a point pp = xx, yy, zz, 1 T within the default view volume, it is projected to pp pp = (xxxx, yyyy, zzzz, wwww) T, where xx pp = xx, yyyy = yy, zzzz = 0, wwww = 1 i.e., we can define MM = 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 and we can then write PP pp = MMMM In practice, we can let MM = II and set zz term to 0 later E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 15

Orthogonal Viewing The OpenGL orthogonal viewing function is: glortho(left, right, bottom, top, near, far) Alternatively, we can use Ortho() defined in mat.h: Type: GLdouble mat4 Ortho(left,right,bottom,top,near,far) Type: Glfloat Should be +ive near and far are measured from camera E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 16

Simple Perspective In orthographic projection, the camera s focal length is considered to be infinite (i.e., the camera lens is at infinity) In perspective projection, the camera s focal length dd is finite A simple perspective projection: - Center of projection is at the origin - Projection plane zz = dd, where dd < 0 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 17

Simple Perspective (cont.) Consider the top and side views (top view) (side view) i.e., xx pp = xx pp dd = xx zz xx zz/dd yy pp dd = yy zz i.e., yy pp = yy zz/dd zz pp = dd Recall: the OpenGL synthetic camera model in an earlier lecture E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 18

Simple Perspective (cont.) Consider qq = MMpp where MM = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1/dd 0 and pp = qq = xx yy zz 1 xx yy zz zz/dd In OpeGL, this is the w term E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 19

Perspective Division However, since ww = zz dd 1, so we must divide by w to return back to nonhomogeneous coordinates. This perspective division yields xx pp = xx yy zz/dd dd = yy zz zz/dd pp = dd which are the desired perspective equations, as on slide 18. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 20

Perspective Viewing To define a perspective transformation matrix for the camera, we can use mat4 Frustum(left,right,bottom,top,near,far) defined in mat.h: All are of type GLfloat Combines perspective projection and clipping E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 21

Perspective Viewing Using Field of View With Frustum() it is often difficult to get the desired view. Another way to get perspective projection is: mat4 Perpective(fovy, aspect, near, far) which often provides a better interface front plane All are of type GLfloat Note: aspect = w/h fovy is an angle in degrees E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 22

References Interactive Computer Graphics A Top-Down Approach with Shader-Based OpenGL by Edward Angel and Dave Shreiner, 6 th Ed, 2012 Secs. 4.1. Classical and Computer Viewing; 4.1.2. Orthographic Projections; 4.1.5 Perspective Viewing Sec. 4.2. Viewing with a Computer Sec. 4.3.1. Positioning of the Camera Frame; 4.3.3. The Look- At Function Sec. 4.4.1. Orthographic Projections; 4.4.2. Parallel Viewing with OpenGL; 4.4.4. Orthogonal-Projection Matrices; (optional) 4.4.6 An Interactive Viewer Secs. 4.5. 4.7. Projections Perspective-Projection Matrices E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 23