Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale

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?
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL (II). How to Draw a 3-D object on Screen?
2IV60 Computer Graphics 2D transformations
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. 3D Transformation glVertex3f(x, y,z);
COMP 175: Computer Graphics March 10, 2015
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
2D Transformations.
Hank Childs, University of Oregon
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Hank Childs, University of Oregon Nov. 14th, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 13: CW/CCW, constructing geometry.
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
Geometry: 2-D Transformations Course web page: Chapter #3.
Modeling with OpenGL Practice with OpenGL transformations.
OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,
Computer Graphics I, Fall 2010 OpenGL Transformations.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
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.
3D Transformations. Translation x’ = x + tx y’ = y + ty z’ = z + tz P = P’ = T = P’ = T. P tx ty tz xyz1xyz1 x’ y’ z’ 1 x y.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Introduction to OpenGL & HW1 Announcement 劉軒銘, 網媒所 碩二 ICG 2012 Fall.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Composing Transformations
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
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.
Transformation Example. Order of Transformation Matters Scale, translate Scale, translate Translate scale Translate scale Rotate, Translate Rotate, Translate.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
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.
Hank Childs, University of Oregon
Transformations Introduction to Computer Graphics and Animation
OpenGL Transformations
Hank Childs, University of Oregon
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.
2D Geometric Transformations
Summary of Properties of 3D Affine Transformations
OpenGL Transformations
Computer Graphics OpenGL Transformations
Reference1. [OpenGL course slides by Rasmus Stenholt]
Transformation and Viewing
Class 10 Part 1 What values to use for Frustum The Trick
Geometric Transformations
Unit-5 Geometric Objects and Transformations-II
Computer Graphics, KKU. Lecture 13
Chapters 5/4 part2 understanding transformations working with matrices
Geometric Transformations
More on Widgets, Misc. Topics
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
Geometric Transformations
Geometric Objects and Transformations (II)
Class 10 Part 1 What values to use for Frustum The Trick
Transformations III Week 3, Mon Jan 21
Chapter 3 Viewing.
OpenGL Transformations
Geometric Transformations
Making an Ice Cream Cone
OpenGL Transformations
Presentation transcript:

Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale reflection glRotate composing transformations placing multiple objects

MJBBasicTransformations.cpp rotation scaling translation

Multiple rotation experiment work in pairs: Both, place book face up so you can read it. Person 1, rotate 90 degrees around z-axis, then rotate 180 degrees around y axis. Person 2, rotate 180 degrees around y axis, then rotate 90 degrees around z-axis. Compare.

Multiple rotation experiment Conclutions: Order Matters!

PROJECTION and MODELVIEW Matrices GL_MODELVIEW is for organizing the pieces of the picture - building the model. GL_PROJECTION is for setting viewing box and type of projection for viewing.

PROJECTION and MODELVIEW Matrices Both matrices are alway active and being used. We can only change or set one at a time. To modify one we have to put it in the "matrix modifying machine", eg glMatrixMode(GL_PROJECTION); glMatrixMode(GL_MODELVIEW);

PROJECTION and MODELVIEW Matrices To make sure we start with a clean slate: glLoadIdentity(); Any new changes are made to the matrix that is currently "in Mode". The current state of both is used for whatever is being drawn.

PROJECTION Matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho... or glFrustum... This is usually in resize routine, but it can be modified in display routine. Remember to then return to the MODELVIEW matrix, glMatrixMode(GL_MODELVIEW);

Modeling Transformations Run box.cpp In resize: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0); glMatrixMode(GL_MODELVIEW);

box.cpp in drawScene glLoadIdentity(); // Modeling transformations. glTranslatef(0.0, 0.0, -15.0); glutWireCube(5.0); // Box. //A 5x5 cube, centered at the origin

Moving the box into view

glTranslatef( p, q, r) translate (x,y,z) to (x+p,y+q,z+r); Reminder - away from your eye is NEGATIVE z direction.

boxV2.cpp //Modeling Transformations glTranslatef(0.0, 0.0, -15.0); ... glScalef(.7,2.0,3.0); Run boxV2.cpp

boxV2.cpp Black box is First scaled (while at the origin) Then translated.

glScalef(u,v,w); maps (x, y, z) of an object to (u*x, v*y, w*z)

Reflection glScale(1.0, -1.0, 1.0); Run boxV3.cpp. press m to see before and after reflection. Notice toggle.

boxV4.cpp //Modeling Transformations glTranslatef(0.0, 0.0, -15.0); ... glRotatef(60.0, 0.0,0.0,1.0); glutWireTeapot(3.0); Run and look at boxV4.cpp

boxV4.cpp glRotatef(60.0, 0.0,0.0,1.0); Counterclockwise rotation looking from origin to (0,0,1) or (0,0,1) to origin?

boxV4.cpp glRotatef(60.0, 0.0,0.0,1.0); Counterclockwise rotation looking from origin to (0,0,1) or (0,0,1) to origin?

glRotatef(A, p, q, r) rotate around the vector (p, q, r) A is the angle in degrees, counterclockwise looking from the point (p, q, r) toward the origin

Transformations Run the experiments in the book. Think through the answer before you run it.

Composing Transformations run boxV5.cpp, draw on board Key input t: glTranslatef(10.0,0.0,0.0); glRotatef(45.0, 0.0,0.0,1.0); glutWireCube(5.0); Key input r:

Placing multiple objects Do experiment with Powerpoint:

Trotate.cpp //Modeling Transformations glTranslatef(0.0, 0.0, -15.0); ... glRotatef(60.0, 0.0,0.0,1.0); glBegin(GL_LINES); glVertex3f(0, 0, 0); glVertex3f(3, 0, 0); glVertex3f(3, -1, 0); glVertex3f(3, 1, 0); glEnd(); Run and look at Trotate.cpp

boxV6.cpp original - a box and a sphere draw on board m: translate together o: say translate then rotate, but really rotate then translate Check out the code! try ortho and frustrum

pushPopDemo.cpp Any transformations (rotate,translate, scale) put inside a glPushMatrix() and a glPopMatrix() pair are ignored outside that pair. Other statements (color, draw something,...) are NOT ignored

pushPopDemo.cpp Any transformations (rotate,translate, scale) put inside a glPushMatrix() and a glPopMatrix() pair are ignored outside that pair. Other statements (color, draw something,...) are NOT ignored