2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.

Slides:



Advertisements
Similar presentations
Computer Graphics 2D & 3D Transformation.
Advertisements

Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CLASS 4 CS770/870. Translation Scale Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales?
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Transformations II Week 2, Wed Jan 17
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
Viewing and Transformation
1 Lecture 7 Geometrical Transformations: 2D transformations 3D transformations Matrix representation OpenGL functions.
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Part I: Basics of Computer Graphics Viewing Transformation and Coordinate Systems Chapter
6/15/2015©Zachary Wartell 1 OpenGL Transforms with Object-Oriented Framework Revision 1.1 Copyright Zachary Wartell, University of North Carolina at Charlotte,
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
OpenGL (II). How to Draw a 3-D object on Screen?
2IV60 Computer Graphics 2D transformations
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
COMP 175: Computer Graphics March 10, 2015
Transformations Dr. Amy Zhang.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Geometric transformations The Pipeline
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Geometry: 2-D Transformations Course web page: Chapter #3.
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics Bing-Yu Chen National Taiwan University.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
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.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Transformations: Projection CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Chap 3 Viewing and Transformation
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
OpenGL LAB III.
The Modelview Stack Lecture 9 Wed, Sep 12, The Modelview Stack OpenGL maintains a stack of matrices. The matrix on top of the stack is the current.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360/4360.
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
CSCE 441 Computer Graphics 3-D Viewing
Reference1. [OpenGL course slides by Rasmus Stenholt]
Geometric Transformations
Unit-5 Geometric Objects and Transformations-II
Chapters 5/4 part2 understanding transformations working with matrices
Transformations 3 University of British Columbia
Computer Graphics (Spring 2003)
Geometric Transformations
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
Geometric Objects and Transformations (II)
Transformations III Week 3, Mon Jan 21
Geometric Transformations
Presentation transcript:

2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric rasterization and clipping algorithms

3 COEN Computer Graphics I Modeling Objects n Recall objects are composed of geometric primitives each primitive is composed of vertices n Model around the origin model just means “determine an object’s vertices”

4 COEN Computer Graphics I Modeling Transformations n Position objects in world coordinates n Move coordinate systems, not objects n Affects all objects rendered after transformation n Types translation scale rotation shear

5 COEN Computer Graphics I Translation n Move the origin to a new location

6 COEN Computer Graphics I glTranslate[fd]() glTranslatef( t x, t y, t z );

7 COEN Computer Graphics I Scale n Stretch, mirror or decimate a coordinate direction Note, there’s a translation applied here to make things easier to see

8 COEN Computer Graphics I glScale[fd]() glScalef( s x, s y, s z );

9 COEN Computer Graphics I Rotation n Rotate coordinate system about an axis in space Note, there’s a translation applied here to make things easier to see

10 COEN Computer Graphics I glRotate[fd]() glRotatef( angle, x, y, z ); M

11 COEN Computer Graphics I Some Additional Rotation Examples

12 COEN Computer Graphics I Shear n Scaling in one dimension depends on another n For example n No OpenGL command load custom matrix

13 COEN Computer Graphics I Shear n Making a shear matrix

14 COEN Computer Graphics I Other OpenGL Matrix Commands n glMultMatrix( m ) multiples the current matrix by m n glLoadMatrix( m ) replaces the current matrix by m n glLoadIdentity() replace the current matrix with an identity matrix

15 COEN Computer Graphics I OpenGL Matrix Format GLfloat m[16];

16 COEN Computer Graphics I Modeling Transforms and our Pipeline World Coordinates Eye Coordinates Clip Coordinates NDC’s Perspective Divide Projection Transformation Model Coordinates Modeling Transformations

17 COEN Computer Graphics I Using Multiple Modeling Transforms n Multiple modeling transforms form a composite modeling transform n Individual transform matrices are multiplied together for example

18 COEN Computer Graphics I Multiplying Matrices n Matrix multiplication is not commutative in general, order of operations is important n OpenGL multiples matrices on the right

19 COEN Computer Graphics I Independent vs. Dependent Transforms n Every modeling transform affects the model coordinate system n Transformations accumulate we record every transformation every made to undo a transform, we’d need to do the inverse transform –this is very inconvenient

20 COEN Computer Graphics I A Stack Based Solution n We create a stack containing matrices n Any transform multiples the top of stack n Push makes a copy and pushes it onto the stack n Pop discards the top of stack

21 COEN Computer Graphics I A Stack Based Solution ( cont. ) Projection Transformation Modeling Transformations

22 COEN Computer Graphics I OpenGL Matrix Stack Commands Top of stack matrix is called the current matrix n glPushMatrix() copy the current matrix and pushes it n glPopMatrix() pop the current matrix

23 COEN Computer Graphics I OpenGL Matrix Stacks n Why multiple matrix stacks? certain techniques are done in different spaces glMatrixMode( mode ) choose which stack to manipulate –GL_MODELVIEW –GL_PROJECTION

24 COEN Computer Graphics I Current Transformation Pipeline World Coordinates Eye Coordinates Clip Coordinates NDC’s Perspective Divide Projection Transformation Model Coordinates Model Coordinates Model Coordinates Modeling Transformations

25 COEN Computer Graphics I Eye coordinates are nice, but... n Eye coordinates are restrictive eye’s positioned at the origin looking down the -z axis n What if we want to look at the scene from somewhere else? use a viewing transformation

26 COEN Computer Graphics I Viewing Transformations n Reorient world coordinates to match eye coordinates n Basically just a modeling transform affects the entire scene usually a translation and a rotation n Usually set up after the projection transform, but before any modeling transforms

27 COEN Computer Graphics I The Simplest Viewing Transform n “Push” the origin into the viewing frustum near far

28 COEN Computer Graphics I polarview() n Useful if you want to view an entire object polarview( dist, elev, azim, twist ) { glTranslatef( 0, 0, -dist ); glRotatef( -twist, 0, 0, 1 ); glRotatef( -elev, 1, 0, 0 ); glRotatef( azim, 0, 0, 1 ); } update elev and azim for interactive viewing

29 COEN Computer Graphics I Transforming World to Eye Coordinates n Viewing transform gluLookAt( eye x, eye y, eye z, look x, look y, look z, up x, up y, up z ); n Creates an orthonormal basis a set of linearly independent vectors of unit length

30 COEN Computer Graphics I Creating an Orthonormal Basis

31 COEN Computer Graphics I gluLookAt( eye x, eye y, eye z, look x, look y, look z, up x, up y, up z ) { /* Create matrix m */ glMultMatrixf( m ); glTranslatef( -eye x, -eye y, -eye z ); }

32 COEN Computer Graphics I Our Final Transformation Pipeline World Coordinates Eye Coordinates Clip Coordinates NDC’s Perspective Divide Projection Transformation Viewing Transformation Model Coordinates Model Coordinates Model Coordinates Modeling Transformations

33 COEN Computer Graphics I Retrieving Matrix information GLfloat m[16]; glGetFloatv( which, m ); n which is which matrix stack to access GL_MODELVIEW_MATRIX GL_PROJECTION_MATRIX

34 COEN Computer Graphics I Putting it all Together n General flow of transformations À projection transformation Á viewing transformation  push matrix à modeling transformation Ä render Å pop matrix Å goto  as necessary