3.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 3 Viewing Transformation Getting Started with OpenGL Introduction to Projections.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
SI23 Introduction to Computer Graphics
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Computer Graphics Lecture 4 Geometry & Transformations.
Graphics Pipeline.
Three Dimensional Viewing
Geometric Transformations
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
OpenGL (II). How to Draw a 3-D object on Screen?
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
Basic graphics. ReviewReview Viewing Process, Window and viewport, World, normalized and device coordinates Input and output primitives and their attributes.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
1 OpenGL Basics A Graphics Standard ©Mel Slater, Anthony Steed
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Transformation & Projection Feng Yu Proseminar Computer Graphics :
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics I, Fall 2010 Computer Viewing.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Lecture 5: Introduction to 3D
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Computer Graphics Projections.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Viewing Viewing and viewing space (camera space)
Rendering Pipeline Fall, 2015.
Viewing.
Computer Viewing.
3D Viewing cgvr.korea.ac.kr.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CSC461: Lecture 19 Computer Viewing
Three Dimensional Viewing
Chapter V Vertex Processing
Presentation transcript:

3.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 3 Viewing Transformation Getting Started with OpenGL Introduction to Projections

3.2si31_2001 Viewing Transformation

3.3si31_2001 The Story So Far...Lecture 2 local co-ordinate representation world co-ordinate system n We have seen how we can model objects, by transforming them from their local co-ordinate representation into a world co-ordinate system modelling co-ordinates world co-ordinates MODELLING TRANSFORMATION

3.4si31_2001 Viewing n Graphics display devices are 2D rectangular screens n Hence we need to understand how to transform our 3D world to a 2D surface n This involves: observer position – selecting the observer position (or camera position) view plane – selecting the view plane (or camera film plane) projection – selecting the type of projection

3.5si31_2001 Viewing Co-ordinate System - View Reference Point n In our world co-ordinate system, we need to specify where the camera is view reference point... n We call this the view reference point... n n … and transform the world so that camera is at the origin view co- ordinate system n We call this the view co- ordinate system xWxW yWyW zWzW P0P0

3.6si31_2001 Viewing Co-ordinate System - View Plane Normal xWxW yWyW zWzW P0P0 N xWxW yWyW zWzW P0P0 Q view plane normal, N n Next we need to specify the direction in which the camera is pointing - the normal from the view plane to camera is the view plane normal, N n Some graphics systems require you to specify N... look at n... others (including OpenGL) allow you to specify a ‘look at’ point, Q, from which N is calculated as direction from the ‘look at’ point to the view reference point

3.7si31_2001 Viewing Co-ordinate System - View Up Direction upward direction, UP n Next we need to specify the ‘up-direction’ of the camera - this is known as the upward direction, UP n Often we take UP=(0,1,0), the positive y-axis n Both N and UP are normalised - ie unit vectors xWxW yWyW zWzW P0P0 N UP

3.8si31_2001 Viewing Co-ordinate System n This gives us a view reference point P 0, and vectors N (view plane normal) and UP (upwards direction) n We now construct a right- handed viewing co-ordinate system as follows: – construct U = UPxN to create a vector orthogonal to N and to UP – construct V = N x U to complete the viewing co-ordinate system: U, V, N xWxW yWyW zWzW P0P0 N UP U V V

3.9si31_2001 Interlude: Today’s Puzzle n Why does a mirror reflect left-right and not up-down?

3.10si31_2001 Transformation from World to Viewing Co-ordinates n Given an object with positions defined in world co-ordinates, we need to calculate the transformation to viewing co-ordinates n The view reference point must be transformed to the origin, and lines along the U, V, N directions must be transformed to lie along the x, y, z directions

3.11si31_2001 Transformation from World to Viewing Co-ordinates n Translate so that P 0 lies at the origin xWxW yWyW zWzW - apply translation by (-x 0, -y 0, -z 0 ) (x 0, y 0, z 0 ) T = x y z P0P0 V U N

3.12si31_2001 Transformation from World to Viewing Co-ordinates n Apply rotations so that the U, V and N axes are aligned with the x W, y W and z W directions n This involves three rotations Rx, then Ry, then Rz – first rotate around x W to bring N into the x W -z W plane – second, rotate around y W to align N with z W – third, rotate around z W to align V with y W n Composite rotation R = Rz. Ry. Rx

3.13si31_2001 Rotation Matrix n Fortunately there is an easy way to calculate R, from U, V and N: R =u 1 u 2 u 3 0 v 1 v 2 v 3 0 n 1 n 2 n where U = (u 1 u 2 u 3 ) T etc

3.14si31_2001 Viewing Transformation n Thus the viewing transformation is: ViewMatrix = R T n This transforms object positions in world co-ordinates to positions in the viewing co-ordinate system.... with camera pointing along negative z-axis at a view plane parallel to x-y plane n We can then apply the projection transformation - to be described later

3.15si31_2001 Exercises n Convince yourself that the rotation matrix on ‘Rotation Matrix’ slide will have the required effect n Build the view matrix that results from: – camera at (1,2,3) – looking at (3,2,1) – with up direction (0,1,0)

3.16si31_2001 Getting Started with OpenGL

3.17si31_2001 What is OpenGL? n OpenGL provides a set of routines (API) for advanced 3D graphics – derived from Silicon Graphics GL – acknowledged industry standard, even on PCs (OpenGL graphics cards available) – integrates 3D drawing into X (and other window systems such as Windows NT) – draws simple primitives (points, lines, polygons) but NOT complex primitives such as spheres – provides control over transformations, lighting, etc – Mesa is publically available equivalent

3.18si31_2001 Geometric Primitives n Defined by a group of vertices - for example to draw a triangle: glBegin (GL_POLYGON); glVertex3i (0, 0, 0); glVertex3i (0, 1, 0); glVertex3i (1, 0, 1); glEnd(); n See Chapter 2 of the OpenGL Programming Guide

3.19si31_2001 Modelling, Viewing and Projection n OpenGL maintains two matrix transformation modes – MODELVIEW to specify modelling transformations, and transformations to align camera – PROJECTION to specify the type of projection (parallel or perspective) and clipping planes n See Chapter 3 of OpenGL Programming Guide

3.20si31_2001 Modelling n For modelling… set the matrix mode, and create the transformation... n Thus to set a scaling on each axis... glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScaled(sx,sy,sz);

3.21si31_2001 Viewing For viewing, use gluLookAt() to create a view transformation matrix gluLookAt(eyex,eyey,eyez, lookx,looky,lookz, upx,upy,upz) n Thus glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScaled(sx,sy,sz); gluLookAt(eyex,eyey,eyez, lookx,looky,lookz, upx,upy,upz); creates a model-view matrix

3.22si31_2001 OpenGL Utility Library (GLU) OpenGL Utility Toolkit (GLUT) n GLU: – useful set of utility routines written in terms of OpenGL … such as gluLookAt() n GLUT (Appendix D of OpenGL Guide): – Set of routines to provide an interface to the underlying windowing system - plus many useful high-level primitives (even a teapot - glutSolidTeapot() !) – Allows you to write ‘event driven’ applications – you specify call back functions which are executed when an event (eg window resize) occurs

3.23si31_2001 How to Get Started n Look at the SI31/AGR resources page: – resources.html n Points you to: – example programs – information about GLUT – information about OpenGL – information about Mesa 3D – a simple exercise

3.24si31_2001 Introduction to Projections

3.25si31_2001 Viewing Pipeline So Far n We now should understand the viewing pipeline mod’g co-ords world co-ords viewing co-ords Modelling Transform’n Viewing Transform’n The next stage is the projection transformation…. Projection Transform’n

3.26si31_2001 Puzzle from Lecture 2

3.27si31_2001 Ames Room n For further reading see: html/ames_room.html Douglas/Winter99/01/ Ames.html

3.28si31_2001 Another Example

3.29si31_2001 Perspective Projections perspectiveparallel n There are two types of projection: perspective and parallel perspective n In a perspective projection, object positions are projected onto the view plane along lines which converge at the observer P1 P2 P1’ P2’ view plane camera

3.30si31_2001 Parallel Projection n In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallel P1 P2 view plane

3.31si31_2001 Perspective and Parallel Projection n Parallel projection preserves the relative proportions of objects, but does not give a realistic view n Perspective projection gives realistic views, but does not preserve proportions – Projections of distant objects are smaller than projections of objects of the same size which are closer to the view plane

3.32si31_2001 Perspective and Parallel Projection perspective parallel