SI23 Introduction to Computer Graphics

Slides:



Advertisements
Similar presentations
Computer Graphics: 2D Transformations
Advertisements

3D Transformations Assist. Prof. Dr. Ahmet Sayar
Computer Graphics: 3D Transformations
OpenGL Computer Graphics
Computer Graphics - Viewing -
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Points, Vectors, Lines, Spheres and Matrices
10.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 10 – Introduction to 3D Graphics.
7.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 7 Introducing SVG Transformations on Elements.
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
SI23 Introduction to Computer Graphics
1GR2-00 GR2 Advanced Computer Graphics AGR Ken Brodlie Lecture 1 - Overview.
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
SI23 Introduction to Computer Graphics
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
1Computer Graphics Homogeneous Coordinates & Transformations Lecture 11/12 John Shearer Culture Lab – space 2
6.4 Best Approximation; Least Squares
25 seconds left…...
Computer Graphics 2D & 3D Transformation.
02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas
Transformations Ed Angel Professor Emeritus of Computer Science
Computer Graphics Lecture 4 Geometry & Transformations.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Transformations Rüdiger Westermann Lehrstuhl für Computer Graphik und.
University of North Carolina at Greensboro
Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
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,
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
3.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 3 Viewing Transformation Getting Started with OpenGL Introduction to Projections.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 450: Computer Graphics 2D TRANSFORMATIONS
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. 3D Transformation glVertex3f(x, y,z);
CS 4731: Computer Graphics Lecture 9: Introduction to 3D Modeling Emmanuel Agu.
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
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.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
CS 4731: Computer Graphics Lecture 12: More 3D Viewing Emmanuel Agu.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
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.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441 Computer Graphics: 2D Transformations
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Viewing.
Computer Viewing.
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
Summary of Properties of 3D Affine Transformations
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Geometric Objects and Transformations (II)
Presentation transcript:

SI23 Introduction to Computer Graphics Lecture 11 – 3D Graphics Transformation Pipeline: Modelling and Viewing Getting Started with OpenGL

3D Transformation Pipeline 3D graphics objects pass through a series of transformations before they are displayed Objects created in modelling co-ordinates mod’g co-ords world viewing Viewing Transform’n Projection Transform’n Modelling Transform’n Position object in world Project view from camera onto plane Position world with respect to camera

Modelling Objects and Creating Worlds We have seen how boundary representations of simple objects can be created Typically each object is created in its own co-ordinate system To create a world, we need to understand how to transform objects so as to place them in the right place - translation, at the right size - scaling, in the right orientation- rotation This process is known as MODELLING 8

Transformations The basic linear transformations are: translation: P = P + T, where T is translation vector scaling: P’ = S P, where S is a scaling matrix rotation: P’ = R P, where R is a rotation matrix As in 2D graphics, we use homogeneous co-ordinates in order to express all transformations as matrices and allow them to be combined easily 9

Homogeneous Co-ordinates In homogeneous coordinates, a 3D point P = (x,y,z)T is represented as: P = (x,y,z,1)T That is, a point in 4D space, with its ‘extra’ co-ordinate equal to 1 Note: in homogeneous co-ordinates, multiplication by a constant leaves point unchanged ie (x, y, z, 1)T = (wx, wy, wz, w)T 10

Translation Suppose we want to translate P (x,y,z)T by a distance (Tx, Ty, Tz)T We express P as (x, y, z, 1)T and form a translation matrix T as below The translated point is P’ = x y z 1 x’ y’ z’ 1 1 0 0 Tx 0 1 0 Ty 0 0 1 Tz 0 0 0 1 = x + Tx y + Ty z + Tz 1 = T P P’ 11

Scaling Scaling by Sx, Sy, Sz relative to the origin: = x’ y’ z’ 1 0 0 0 1 x y z P’ = S P Sx . x Sy . y Sz . z 1 12

Rotation Rotation is specified with respect to an axis - easiest to start with co-ordinate axes To rotate about the x-axis: x’ y’ z’ 1 = 1 0 0 0 0 cos -sin 0 0 sin cos 0 0 0 0 1 x y z P’ Rx () P a positive angle corresponds to counterclockwise direction looking at origin from positive position on axis EXERCISE: write down the matrices for rotation about y and z axes 13

Composite Transformations The attraction of homogeneous co-ordinates is that a sequence of transformations may be encapsulated as a single matrix For example, scaling with respect to a fixed position (a,b,c) can be achieved by: translate fixed point to origin- say, T(-a,-b,-c) scale- S translate fixed point back to its starting position- T(a,b,c) Thus: P’ = T(a,b,c) S T(-a,-b,-c) P = M P 14

Rotation about a Specified Axis It is useful to be able to rotate about any axis in 3D space This is achieved by composing 7 elementary transformations 15

Rotation through  about Specified Axis y z y y P2 P1 x x initial position translate P1 to origin rotate so that P2 lies on z-axis (2 rotations) rotate axis to orig orientation translate back z z y y x y z P2 P1 x x z z rotate through requ’d angle,  16

Inverse Transformations As in this example, it is often useful to calculate the inverse of a transformation ie the transformation that returns to original state Translation: T-1 (a, b, c) = T (-a, -b, -c) Scaling: S-1 ( Sx, Sy, Sz ) = S ............ Rotation: R-1z () = Rz (…….) Exercise: Check T-1 T = I (identity matrix)

Rotation about Specified Axis Thus the sequence is: T-1 R-1x() R-1 y() Rz() Ry() Rx() T EXERCISE: How are  and  calculated? READING: Hearn and Baker, chapter 11 18

Interlude: Question Why does a mirror reflect left-right and not up-down?

Getting Started with OpenGL

What is OpenGL? 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 MS Windows) draws simple primitives (points, lines, polygons) but NOT complex primitives such as spheres provides control over transformations, lighting, etc Mesa is publically available equivalent 4 4

Geometric Primitives 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(); See OpenGL supplement pp3-6 for output primitives 5 5

Modelling, Viewing and Projection 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 6 6

Modelling For modelling… set the matrix mode, and create the transformation... Thus to set a scaling on each axis... glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(sx,sy,sz); This creates a 4x4 modelview matrix Other transformation functions are: glRotatef(angle, ux, uy, uz); glTranslatef(tx, ty, tz); See p10 of OpenGL supplement

OpenGL Utility Library (GLU) OpenGL Utility Toolkit (GLUT) useful set of utility routines written in terms of OpenGL … GLUT: 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 See pp1-3 of OpenGL supplement 8 8

How to Get Started Look at the SI23 resources page: Points you to: http://www.comp.leeds.ac.uk/kwb/si23/ resources.html Points you to: example programs information about GLUT information about OpenGL information about Mesa 3D a simple exercise

Viewing Transformation

Camera Position y In OpenGL (and many other graphics systems) the camera is placed at a fixed position At origin Looking down negative z-axis Upright direction in positive y-axis x z VIEWING transforms the world so that it is in the required position with respect to this camera

Specifying the Viewing Transformation Look at position OpenGL will build this transformation for us from: Where camera is to be Point we are looking at Upright direction Becomes part of an overall MODELVIEW matrix Upright position Eye position

Specifying the Viewing Transformation in OpenGL For viewing, use gluLookAt()to create a view transformation matrix gluLookAt(eyex,eyey,eyez, lookx,looky,lookz, upx,upy,upz) Thus glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(sx,sy,sz); gluLookAt(eyex,eyey,eyez, lookx,looky,lookz, upx,upy,upz); creates a model-view matrix See pp11-12 of OpenGL Supp.

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

Perspective and Parallel Projection