4BA6 - Topic 4 Dr. Steven Collins. Chap. 5 3D Viewing and Projections

Similar documents
Realtime 3D Computer Graphics Virtual Reality

CS 4204 Computer Graphics

Transformations in the pipeline

Basic Problem: Map a 3D object to a 2D display surface. Analogy - Taking a snapshot with a camera

3D Viewing. Chapter 7. Projections. 3D clipping. OpenGL viewing functions and clipping planes

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

CS 4204 Computer Graphics

2D Geometrical Transformations. Foley & Van Dam, Chapter 5

Geometric Camera Parameters

The Geometry of Perspective Projection

INTRODUCTION TO RENDERING TECHNIQUES

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

521493S Computer Graphics. Exercise 2 & course schedule change

Geometry for Computer Graphics

SOEM 024: Computer Aided Design. E. Rozos

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

From 3D to 2D: Orthographic and Perspective Projection Part 1

2D Geometric Transformations

Lecture 3: Coordinate Systems and Transformations

Computer Graphics Labs

w = COI EYE view direction vector u = w ( 010,, ) cross product with y-axis v = w u up vector

Affine Transformations

How to read Plans and Do Basic Drawings

Introduction to Computer Graphics

Introduction to Computer Graphics. Reading: Angel ch.1 or Hill Ch1.

Aston University. School of Engineering & Applied Science

SketchUp Instructions

Chapter 8. Lines and Planes. By the end of this chapter, you will

An introduction to 3D draughting & solid modelling using AutoCAD

Graphics Pipeline in a Nutshell

Traditional Drawing Tools

Creating 2D Drawings from 3D AutoCAD Models

Pro/ENGINEER Wildfire 4.0 Basic Design

Lecture 2: Homogeneous Coordinates, Lines and Conics

TABLE OF CONTENTS. INTRODUCTION... 5 Advance Concrete... 5 Where to find information?... 6 INSTALLATION... 7 STARTING ADVANCE CONCRETE...

Solving Simultaneous Equations and Matrices

2.1 Three Dimensional Curves and Surfaces

Section 11.4: Equations of Lines and Planes

Understand the Sketcher workbench of CATIA V5.

Kankakee Community College

Introduction to Matrices for Engineers

Methodology for Lecture. Review of Last Demo

Teacher Page. 1. Reflect a figure with vertices across the x-axis. Find the coordinates of the new image.

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

An Introduction to. Graphics Programming

4. CAMERA ADJUSTMENTS

CATIA Drafting TABLE OF CONTENTS

CATIA V5 Tutorials. Mechanism Design & Animation. Release 18. Nader G. Zamani. University of Windsor. Jonathan M. Weaver. University of Detroit Mercy

Freehand Sketching. Sections

OD1641 PRINCIPLES OF DRAFTING AND SHOP DRAWINGS

INVESTIGATIONS AND FUNCTIONS Example 1

Welcome to Corel DESIGNER, a comprehensive vector-based drawing application for creating technical graphics.

Essential Mathematics for Computer Graphics fast

Advanced Computer Graphics (2IV40) ~ 3D Transformations. Types (geometric) Types (algebraic) 3D Transformations. y + c 1. x = a 1.

Anamorphic Projection Photographic Techniques for setting up 3D Chalk Paintings

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

SEMTech Solutions. Leaders in Refurbished SEMs. SEMTech Solutions Windows 7 SOFTWARE CONTROL SYSTEM

Lecture Notes. Fundamentals of Computer Graphics. Prof. Michael Langer School of Computer Science McGill University

Geometric Optics Converging Lenses and Mirrors Physics Lab IV

x y The matrix form, the vector form, and the augmented matrix form, respectively, for the system of equations are

basicdim DGC Compact control module

GeoGebra. 10 lessons. Gerrit Stols

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

LIST OF CONTENTS CHAPTER CONTENT PAGE DECLARATION DEDICATION ACKNOWLEDGEMENTS ABSTRACT ABSTRAK

The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

Math, Trigonometry and Vectors. Geometry. Trig Definitions. sin(θ) = opp hyp. cos(θ) = adj hyp. tan(θ) = opp adj. Here's a familiar image.

A Short Introduction to Computer Graphics

3D Drawing. Single Point Perspective with Diminishing Spaces

Given a point cloud, polygon, or sampled parametric curve, we can use transformations for several purposes:

Relating Vanishing Points to Catadioptric Camera Calibration

A System for Capturing High Resolution Images

Manual for simulation of EB processing. Software ModeRTL

B4 Computational Geometry

Section V.2: Magnitudes, Directions, and Components of Vectors

Projective Geometry. Projective Geometry

Chapter 2 - Graphics Programming with JOGL

SkillsUSA 2014 Contest Projects 3-D Visualization and Animation

Technical Regulations

MMGD0203 Multimedia Design MMGD0203 MULTIMEDIA DESIGN. Chapter 3 Graphics and Animations

Quick Start Tutorial Metric version

MAT 1341: REVIEW II SANGHOON BAEK

F1 in Schools World Finals Technical Regulations WORLD FINALS Technical Regulations

Introduction to CATIA V5

SECTION 7-4 Algebraic Vectors

IES <Virtual Environment> Tutorial. ModelIT (Version 6.0)

sin(θ) = opp hyp cos(θ) = adj hyp tan(θ) = opp adj

Microsoft Picture Manager. Picture Manager

MAT188H1S Lec0101 Burbulla

Image Formation. 7-year old s question. Reference. Lecture Overview. It receives light from all directions. Pinhole

LEAVING CERT DCG SCHEME OF WORK

CATIA for Design and Engineering. Version 5 Releases 14 & 15. David S. Kelley. Central Michigan University SDC

Light and its effects

Producing 2D Documentation from 3D Models in AutoCAD

Technical Drawing. MEC1000 Spring 2006 Instructor: David Anderson

Transcription:

4BA6 - Topic 4 Dr. Steven Collins Chap. 5 3D Viewing and Projections

References Computer graphics: principles & practice, Fole, vandam, Feiner, Hughes, S-LEN 5.644 M23*;-6 (has a good appendix on linear algebra) Advanced Animation and Rendering Techniques, Watt and Watt, S-LEN 5.8 N26;2-5 The OpenGL Programming Guide, Woo, Neider & Davis, S- LEN 5.8 N72;-2 Interactive Computer Graphics, Edward Angel 2

OpenGL Geometr Pipeline x z w original vertex MODELVIEW matrix x z w ee ee ee ee vertex in the ee coordinate space PROJECTION matrix x w proj proj proj 2D projection of vertex onto viewing plane perspective division x dev dev normalised device coordinates (foreshortened) viewport transformation x win win final window coordinates 3

The Camera Sstem To create a view of a scene we need: a description of the scene geometr a camera or view definition Default OpenGL camera is located at the origin looking down the -z axis. The camera definition allows projection of the 3D scene geometr onto a 2D surface for displa. This projection can take a number of forms: orthographic (parallel lines preserved) perspective (foreshortening): -point, 2-point or 3-point skewed orthographic 4

Camera Tpes Before generating an image we must choose our viewer: The pinhole camera model is most widel used: infinite depth of field (everthing is in focus) Advanced rendering sstems model the camera double gauss lens as used in man professional cameras model depth of field and non-linear optics (including lens flare) Photorealistic rendering sstems often emplo a phsical model of the ee for rendering images model the ees response to varing brightness and colour levels model the internal optics of the ee itself (diffraction b lens fibres etc.) 5

Pinhole Camera Model 6

Modeling the Ee s Response Adaptation Glare & Diffraction 7

Camera Sstems A camera model implemented in Princeton Universit (995) 8

Viewing Sstem We are onl concerned with the geometr of viewing at this stage. The camera s position and orientation define a viewvolume or view-frustrum. objects completel or partiall within this volume are potentiall visible on the viewport. objects full outside this volume cannot be seen clipped clipped view frustrum clipping planes 9

Camera Models CTM= Current Transformation Matrix Each vertex in our model must be projected onto the 2D camera viewport plane in order to be displa on the screen. The CTM is emploed to determine the location of each vertex in the camera coordinate sstem: x = MCTM x We then emplo a projection matrix defined b GL_PROJECTION to map this to a 2D viewport coordinate. Finall, this 2D coordinate is mapped to device coordinates using the viewport definition (given b glviewport()).

Camera Modeling in OpenGL camera coordinate sstem viewport coordinate sstem device/screen coordinate sstem glmatrixmode(gl_modelview)... glviewport(,,xres,res) glmatrixmode(gl_projection)...

3D 2D Projection Tpe of projection depends on a number of factors: location and orientation of the viewing plane (viewport) direction of projection (described b a vector) projection tpe: Projection Perspective Parallel -point Orthographic 2-point Axonometric 3-point Oblique 2

Parallel Projections axonometric orthographic oblique 3

Perspective Projections 3-point perspective -point perspective 2-point perspective 4

5 Orthogonal Projections The simplest of all projections, parallel project onto viewplane. Usuall view-plane is axis aligned (often at z=) = = where M MP P x z x

Multiple Projections It is often useful to have multiple projections available at an given time usuall: plan (top) view, front & left or right elevation (side) view Perspective Top Front Right 6

Orthogonal Projections The result is an orthographic projection if the object is axis aligned, otherwise it is an axonometric projection. If the projection plane intersects the principle axes at the same distance from the origin the projection is isometric. x + + z = 7

Parallel Projections in OpenGL glortho(xmin, xmax, min, max, zmin, zmax); Note: we alwas view in -z direction need to transform world in order to view in other arbitrar directions. 8

Perspective Projections Perspective projections are more complex and exhibit foreshortening (parallel appear to converge at points). Parameters: centre of projection (COP) field of view (θ,φ) projection direction up direction 9

2 Perspective Projections Consider a perspective projection with the viewpoint at the origin and a viewing direction oriented along the positive -z axis and the view-plane located at z = -d p d z d z P P = = -z d = = z x d d z z x d d z d z x z x P P P divide b homogenous ordinate to map back to 3D space a similar construction for x p

2 Perspective Projections Details = d z z x d d z d z x z x P P P = z x z x Flip z to transform to a left handed co-ordinate sstem increasing z values mean increasing distance from the viewer. PROJECTION matrix perspective division

Perspective Projection Depending on the application we can use different mechanisms to specif a perspective view. Example: the field of view angles ma be derived if the distance to the viewing plane is known. Example: the viewing direction ma be obtained if a point in the scene is identified that we wish to look at. OpenGL supports this b providing different methods of specifing the perspective view: glulookat, glfrustrum and gluperspective 22

Perspective Projections glfrustrum(xmin, xmax, min, max, zmin, zmax); 23

glfrustrum Note that all points on the line defined b (xmin,min,- zmin) and COP are mapped to the lower left point on the viewport. Also all points on the line defined b (xmax,max,-zmin) and COP are mapped to the upper right corner of the viewport. The viewing direction is alwas parallel to -z It is not necessar to have a smmetric frustrum like: glfrustrum(-.,., -.,., 5., 5.); Non smmetric frustrums introduce obliqueness into the projection. zmin and zmax are specified as positive distances along -z 24

Perspective Projections gluperspective(fov, aspect, near, far); h 2 θ = tan h = 2near tan θ near 2 2 25

gluperspective A utilit function to simplif the specification of perspective views. Onl allows creation of smmetric frustrums. Viewpoint is at the origin and the viewing direction is the -z axis. The field of view angle, fov, must be in the range [..8] aspect allows the creation of a view frustrum that matches the aspect ratio of the viewport to eliminate distortion. 26

Perspective Projections 27

Lens Configurations mm Lens (fov = 22 ) 2mm Lens (fov = 84 ) 35mm Lens (fov = 54 ) 2mm Lens (fov = ) 28

Positioning the Camera The previous projections had limitations: usuall fixed origin and fixed projection direction To obtain arbitrar camera orientations and positions we manipulate the MODELVIEW matrix prior to creation of the models. This positions the camera w.r.t. the model. We wish to position the camera at (, 2, ) w.r.t. the world Two possibilities: transform the world prior to creation of objects using translatef and rotatef: gltranslatef(-, -2, -); use glulookat to position the camera with respect to the world co-ordinate sstem: glulookat(, 2,, ); Both are equivalent. 29

Positioning the Camera glulookat(eex, ee, eez, lookx, look, lookz, upx, up, upz); equivalent to: gltranslatef(-eex, -ee, -eez); glrotatef(theta,.,.,.); glrotatef(phi,.,.,.); 3

Projection window The projection matrix defines the mapping from a 3D world co-ordinate to a 2D viewport co-ordinate. The window extents are defined as a parameter of the projection: glfrustrum(l,r,b,t,n,f) (r,t,-n) (l,b,-n) (w,h,-n) gluperspective(f,a,n,f) (-w,-h,-n) h w f = n tan 2 = h a 3

Projection window We need to associate the 2D window co-ordinate sstem with the viewport co-ordinate sstem in order to determine the correct pixel associated with each vertex. normalised device co-ordinates viewport co-ordinates 32

Window to Viewport Transformation: review An affine planar transformation is used. After projection to the window, all points are transformed to normalised device co-ordinates: [-,]x[,] x n n x = 2 x max = 2 p p max x x min min min min glviewport used to relate the co-ordinate sstems: glviewport(int x, int, int width, int height); 33

Window to Viewport Transformation: review (x,) = location of bottom left of viewport within the window width,height = dimension in pixels of the viewport x w = width + 2 height + 2 ( x + ) x = ( + ) n w n normall we re-create the window after a window resize event to ensure a correct mapping between window and viewport dimensions: static void reshape(int width, int height) { glviewport(,, width, height); glmatrixmode(gl_projection); glloadidentit(); gluperspective(85.,., 5, 5); } 34

Aspect Ratio The aspect ratio defines the relationship between the width and height of an image. Using gluperspective an viewport aspect ratio ma be explicitl provided, otherwise the aspect ratio is a function of the supplied viewport width and height. The aspect ratio of the window (defined b the user) must match the viewport aspect ratio to prevent unwanted affine distortion: aspect ratio =.25 aspect ratio =.5 35

Sample Viewport Application // top left: top view glviewport(, win_height/2, win_width/2, win_height/2); glmatrixmode(gl_projection); glloadidentit(); glortho(-3., 3., -3., 3.,., 5.); glulookat(., 5.,.,.,.,.,.,., -.); glmatrixmode(gl_modelview); glloadidentit(); glcalllist(object); // top right: right view glviewport(win_width/2, win_height/2, win_width/2, win_height/2); glmatrixmode(gl_projection); glloadidentit(); glortho(-3., 3., -3., 3.,., 5.); glulookat(5.,.,.,.,.,.,.,.,.); glmatrixmode(gl_modelview); glloadidentit(); glcalllist(object); // bottom left: front view glviewport(,, win_width/2, win_height/2); glmatrixmode(gl_projection); glloadidentit(); glortho(-3., 3., -3., 3.,., 5.); glulookat(.,., 5.,.,.,.,.,.,.); glmatrixmode(gl_modelview); glloadidentit(); glcalllist(object); // bottom right: rotating perspective view glviewport(win_width/2,, win_width/2, win_height/2); glmatrixmode(gl_projection); glloadidentit(); gluperspective(7.,.,, 5); glulookat(.,., 5.,.,.,.,.,.,.); glmatrixmode(gl_modelview); glloadidentit(); glrotatef(3.,.,.,.); glrotatef(angle,.,.,.); glcalllist(object); 36