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

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

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

Introduction to Computer Graphics with WebGL

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

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

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

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

Computer Viewing Computer Graphics I, Fall 2008

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

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

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

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

Three Main Themes of Computer Graphics

Viewing with Computers (OpenGL)

CS452/552; EE465/505. Models & Viewing

Introduction to Computer Graphics 4. Viewing in 3D

CS452/552; EE465/505. Review & Examples

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

CS 432 Interactive Computer Graphics

CS354 Computer Graphics Viewing and Modeling

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

Introduction to Computer Graphics with WebGL

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

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

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

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

2D and 3D Viewing Basics

Viewing and Modeling

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

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

Overview. By end of the week:

CS 418: Interactive Computer Graphics. Projection

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Fundamental Types of Viewing

Lecture 4. Viewing, Projection and Viewport Transformations

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

5.8.3 Oblique Projections

Virtual Cameras and The Transformation Pipeline

Transformations. Rotation and Scaling

CS 4204 Computer Graphics

Models and The Viewing Pipeline. Jian Huang CS456

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

Viewing. Reading: Angel Ch.5

COMP3421. Introduction to 3D Graphics

Viewing and Projection

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

3.1 Viewing and Projection

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

Chapter 5. Projections and Rendering

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

Viewing and Projection

Lecture 4: Viewing. Topics:

CS452/552; EE465/505. Transformations

Rasterization Overview

COMP3421. Introduction to 3D Graphics

Computer Graphics. Ch 6. 3D Viewing

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Geometry: Outline. Projections. Orthographic Perspective

1 OpenGL - column vectors (column-major ordering)

Virtual Cameras & Their Matrices

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

COMP3421. Introduction to 3D Graphics

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

Models and Architectures

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

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

OpenGL Transformations

Chapter 5-3D Camera & Optimizations, Rasterization

Perspective transformations

COMS 4160: Problems on Transformations and OpenGL

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

3D Viewing Transformations

Three-Dimensional Viewing Hearn & Baker Chapter 7

Computer Graphics 7: Viewing in 3-D

Overview. By end of the week:

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

Viewing and Projection

Chapter 8 Three-Dimensional Viewing Operations

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

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

Advanced Computer Graphics (CS & SE )

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

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

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

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

Fachhochschule Regensburg, Germany, February 15, 2017

Viewing transformations. 2004, Denis Zorin

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

Transforms 3: Projection Christian Miller CS Fall 2011

Transformation Pipeline

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

What does OpenGL do?

3D Viewing. CS 4620 Lecture 8

Viewing. Cliff Lindsay, Ph.D. WPI

CSC 470 Computer Graphics. Three Dimensional Viewing

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

CSC 470 Computer Graphics

Graphics pipeline and transformations. Composition of transformations

Transcription:

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

Project 1: Interactive Viewing of Two Teapots How to create a teapot? Before OpenGL 3., glutsolidteapot However, the function glutsolidteapot is deprecated Create a model or use an existing model

An Obj Model An obj file stores an existing model An obj file is structured in lines. The lines starting with # are comments o introduces a new object For each following line, v introduces a vertex vn introduces a normal f introduces a face, using vertex indices, starting at 1

An Example of a Teapot Model A teapot.obj downloaded from http://graphics.stanford.edu/courses/cs148-1-summer/as3/code/as3/teapot.obj v -3. 1.8. v -2.9916 1.8 -.81 v -2.9916 1.8.81 f 2968 297 34 f 322 321 31 f 31 34 322

An Obj Model Load a model void load_obj(const char* filename, vector<vec4>& vertices, vector<glushort>& elements,vector<vec3>& normals) Use the model glbufferdata( GL_ARRAY_BUFFER, vertices.size()*sizeof(vec4), &vertices[], GL_STATIC_DRAW ); Display gldrawelements( GL_TRIANGLES, elements.size()*sizeof(glushort), GL_UNSIGNED_SHORT, ); The indices in the element array buffer provide the topology of the model. https://en.wikibooks.org/wiki/opengl_programming/modern_opengl_tutorial_load_obj

More Obj Models http://goanna.cs.rmit.edu.au/~pknowles/

Topic Chapter 4. Angel and Shreiner Model view matrix and projection matrix

Three Basic Elements in Viewing One or more objects A viewer with a projection surface Planar geometric projections standard projections project onto a plane preserve lines but not necessarily angles Nonplanar projections are needed for applications such as map construction Projectors that go from the object(s) to the projection surface Projectors are lines that either converge at a center of projection are parallel E. Angel and D. Shreiner

Perspective Projection Projectors coverge at center of projection E. Angel and D. Shreiner

Perspective Projection Objects further from viewer are projected smaller than the same sized objects closer to the viewer (diminution) Looks realistic Equal distances along a line may be not projected into equal distances (nonuniform foreshortening) Angles are preserved only in planes parallel to the projection plane More difficult to construct by hand than parallel projections (but not more difficult by computer) E. Angel and D. Shreiner : Interactive Computer Graphics 6E Addison-Wesley 212

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 Transforming the coordinates in the object frame to the camera frame Selecting a lens Setting the projection matrix Attributes of the camera, e.g., focal length, etc Transforming the coordinates in the camera frame to the clip coordinates frame Clipping Setting the view volume

Important Transformations in OpenGL Object (or model) coordinates World coordinates Eye (or camera) coordinates Clip coordinates Normalized device coordinates Window (or screen) coordinates Model-view transformation 4D 4D Projection transformation 4D 4D Perspective division 4D 3D Viewport transformation 3D 2D+depth

Pipeline View modelview transformation projection transformation perspective division 4D 3D clipping against default cube Viewport transformation 3D 2D E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212

Step1: Derive the Model-view Matrix In OpenGL, initially the object and camera frames are the same Default model-view matrix is an identity The camera is located at origin and points in the negative z direction Problem: Cannot see the objects behind the camera -- objects with positive z values E. Angel and D. Shreiner

Moving the Camera Frame we can either Move the objects along the negative z direction Classical viewing: viewer is fixed Translate the object/world frame Move the camera along the positive z direction Camera viewing: objects are fixed Translate the camera frame They are equivalent and are determined by the model-view matrix M representing a translation (Translate(.,.,-d), d >

Moving the Camera Frame default frames frames after translation by d d > E. Angel and D. Shreiner P c = MP M = T = 1 1 1 d 1

Moving the Camera We can move the camera to any desired position by a sequence of rotations and translations Example: side view Rotate the camera Move it away from origin Model-view matrix M = TR E. Angel and D. Shreiner

OpenGL code Last transformation specified is first to be applied // Using mat.h mat4 t = Translate (.,., -d); mat4 ry = RotateY(9.); mat4 m = t*ry; E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212

Example: Create an Isometric View of a Cube Step 1: rotate the cube about the x-axis by 45 degrees see the other two faces symmetrically M = TR y R x E. Angel and D. Shreiner Step 2: rotate the cube about the y-axis by -35.26 degrees Step 3: move the camera away from the cube

The LookAt Function The GLU library contained the function glulookat to form the required modelview matrix through a simple interface Replaced by LookAt() in mat.h Can concatenate with modeling transformations mat4 mv = LookAt(vec4 eye, vec4 at, vec4 up); Need to set an up direction

LookAt(eye, at, up) Objective: construct a new frame with the origin at the eye point, The view plane normal (vpn) as one coordinate direction Two other orthogonal directions as the other two coordinate directions at point the point (e.g., the object center) the camera looks at vpn eye point camera specified in the object frame E. Angel and D. Shreiner

LookAt(eye, at, up) M = u x u y u z u vvv v x v y v z v vvv n x n y n z n vvv 1

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 Elevation, azimuth, twist Direction angles E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212

Step2: Projections and Normalization The default projection is orthogonal (orthographic) projection For points within the view volume x p = x y p = y z p = In homogeneous coordinates p p = M orth p E. Angel and D. Shreiner M orth = 1 1 1

Orthogonal Normalization Default projection: the orthographic camera is at origin the default volume is enclosed in x = ±1, y = ±1, z = ±1 Ortho(-1.,1.,-1.,1.,- 1.,1.) A general orthogonal projection: Ortho(left,right,bottom,top, near,far) The clipping volume is different than the default 2 clipped out z=

OpenGL Orthogonal Viewing Ortho(left,right,bottom,top,near,far) The 4 sides of clipping volume: x = rrrrr x = llll y = ttt y = bbbbbb Form a projection matrix All are measured in the camera frame E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 212

Orthogonal Normalization Find transformation to convert specified clipping volume to default E. Angel and D. Shreiner

Affine Transformation for Orthogonal Normalization Two steps: Move center to origin T( (llll + rrrrr)/2, (bbbbbb + ttt)/2, (nnnn + fff)/2)) Scale to have sides of length 2 S(2/(llll rrrrr), 2/(ttt bbbbbb), 2/(nnnn fff)) 2 right left N = ST = 2 top bottom 2 near far right left right left top + bottom top bottom far + near far near 1

Final Orthographic Projection Matrix General orthogonal projection in 4D is P = M orth ST