University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations III Week.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Computer Graphics 2D & 3D Transformation.
Hierarchical Transformation. Summary Alternatively, OpenGL thinks: A transformation updates the coordinate system. For each change, the transformation.
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Transformations III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Transformations II Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Display Lists, Viewing.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Transformations I, II,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
Transformations II Week 2, Wed Jan 17
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
Transformations IV Week 3, Wed Jan 23
© Tamara Munzner University of British Columbia Hierarchical modelling recap: composing transforms recap: composing transforms finish: rendering pipeline.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Transformations V Week.
Projections and Picking Wed 24 Sep 2003
Hierarchical Modeling II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
University of British Columbia CPSC 414 Computer Graphics Week 3, Monday 15 Oct 03 © Tamara Munzner 1 Hierarchies, Display Lists recap: matrix hierarchies,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Transformations III Week.
University of British Columbia © MIchiel van de Panne An Introduction to Computer Animation Michiel van de Panne.
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
CSC 123 – Animating characters Hierarchical modeling Zoë Wood.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Transformations Dr. Amy Zhang.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Week 4 Lecture 1: Hierarchical Modeling Part 1 Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E ©
Hierarchical Modeling. Instance Transformation Start with a prototype object (a symbol) Each appearance of the object in the model is an instance – Must.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Modeling with OpenGL Practice with OpenGL transformations.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Transformations Tutorial
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.
Computer Graphics I, Fall 2008 Hierarchical Modeling II.
Transformations
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
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.
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
Transformations 5 University of British Columbia
Transformations Introduction to Computer Graphics and Animation
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Transformations V, Viewing I Week 3, Fri Jan 22
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Computer Graphics - Hierarchical Models-
Transformations 6 University of British Columbia
CSCE 441: Computer Graphics: Hierarchical Models
Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale
Transformations 3 University of British Columbia
Transformations IV Week 3, Wed Jan 20
Transformations 4 University of British Columbia
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
Transformations IV Week 3, Mon Jan 22
Transformations III Week 3, Mon Jan 21
Viewing/Projections I Week 3, Fri Jan 25
Transformations IV Week 3, Wed Jan 23
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations III Week 3, Wed Jan 19

2 Corrections to Previous Slides

3 Composing Transformations translation so translations add

Arbitrary Rotation problem: given two orthonormal coordinate systems XYZ and UVW find transformation from one to the other answer: transformation matrix R whose columns are U,V,W: Y Z X W V U

5 Arbitrary Rotation why? similarly R(Y) = V & R(Z) = W

6 Project 1 out today, due 6pm Thu Jan 27 you should start very soon! labs are for help with programming projects, written assignments no separate materials to be handed in build kangaroo out of cubes and 4x4 matrices think cartoon, not beauty build then animate one section at a time helps make sure you’re constructing hierarchy correctly template code gives you program shell

7 Real Kangaroos

8 Articulated Kangaroo

9

10 Review: Composing Transforms order matters 4x4 matrix multiplication not commutative! moving to origin transformation of geometry into coordinate system where operation becomes simpler perform operation transform geometry back to original coordinate system

11 (2,1) (1,1) left to right: changing coordinate system right to left: moving object translate by (-1,0) Review: Interpreting Transformations intuitive? OpenGL

12 Review: Transforming Normals nonuniform scale makes normal nonperpendicular need to use inverse transpose matrix instead

13 Transformation Hierarchies scene graph road stripe1 stripe2... car1car2... w1w3w2w4

14 Transformation Hierarchies torso head RUarm RLarm Rhand RUleg RLleg Rfoot LUarm LLarm Lhand LUleg LLleg Lfootworld trans(0.30,0,0) rot(z, )

15 Matrix Stacks challenge of avoiding unnecessary computation using inverse to return to origin computing incremental T 1 -> T 2 Object coordinates World coordinates T 1 (x) T 2 (x) T 3 (x)

16 Transformation Hierarchies matrix stack glPushMatrix() glPopMatrix() A B C A B C A B C C glScale3f(2,2,2) D = C scale(2,2,2) trans(1,0,0) A B C D DrawSquare() glTranslate3f(1,0,0) DrawSquare() glPushMatrix() glPopMatrix()

17 Composing Transformations OpenGL example FWFWFWFW FhFhFhFh FhFhFhFh glLoadIdentity();glTranslatef(4,1,0);glPushMatrix();glRotatef(45,0,0,1);glTranslatef(0,2,0);glScalef(2,1,1);glTranslate(1,0,0);glPopMatrix(); F1F1F1F1 FhFhFhFh FhFhFhFh FhFhFhFh FhFhFhFh FhFhFhFh

18 Transformation Hierarchies example x y glTranslate3f(x,y,0); glRotatef(,0,0,1); DrawBody();glPushMatrix(); glTranslate3f(0,7,0); glTranslate3f(0,7,0); DrawHead(); DrawHead();glPopMatrix();glPushMatrix(); glTranslate(2.5,5.5,0); glTranslate(2.5,5.5,0); glRotatef(,0,0,1); glRotatef(,0,0,1); DrawUArm(); DrawUArm(); glTranslate(0,-3.5,0); glTranslate(0,-3.5,0); glRotatef(,0,0,1); glRotatef(,0,0,1); DrawLArm(); DrawLArm();glPopMatrix();... (draw other arm)

19 Modularization drawing a scaled square void drawBlock(float k) { glPushMatrix(); glPushMatrix(); glScalef(k,k,k); glScalef(k,k,k); glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP); glVertex3f(0,0,0); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(1,1,0); glVertex3f(0,1,0); glVertex3f(0,1,0); glEnd(); glEnd(); glPopMatrix(); glPopMatrix();}

20 Demo: Brown Applets freeSoftware/catalogs/scenegraphs.html

21 Transformation Hierarchies hierarchies don’t fall apart when changed transforms apply to graph nodes beneath

22 Hierarchical Modeling advantages: matrix stacks make it feasible to have multiple copies of one object no need to compute inverse matrices all the time avoids incremental changes to coordinate systems accumulation of numerical errors modularize changes to pipeline state practical issues: in graphics hardware, depth of matrix stacks is limited (typically 16 for model/view and about 4 for projective matrix)

23 Hierarchies Limits advantages often good control knobs maintain structural constraints limitations expressivity: not always the best controls can’t do closed kinematic chains keep hand on hip can’t do other constraints e.g. don’t walk through walls

24 Single Parameter: simple parameters as functions of other params clock: control all hands with seconds s m = s/60, h=m/60, theta_s = (2 pi s) / 60, theta_m = (2 pi m) / 60, theta_h = (2 pi h) / 60

25 Single Parameter: complex mechanisms not easily expressible with affine transforms

26 Single Parameter: complex mechanisms not easily expressible with affine transforms

27 Snowmen Example hierarchical modelling display lists OpenGL efficiency trick make list of OpenGL commands for later use

28 drawSnowMan void drawSnowMan() { glColor3f(1.0f, 1.0f, 1.0f); // Draw Body glTranslatef(0.0f,0.75f, 0.0f); glutSolidSphere(0.75f,20,20); // Draw Head glTranslatef(0.0f, 1.0f, 0.0f); glutSolidSphere(0.25f,20,20); // Draw Nose glColor3f(1.0f, 0.5f, 0.5f); glRotatef(0.0f,1.0f, 0.0f, 0.0f); glutSolidCone(0.08f,0.5f,10,2); } // Draw Eyes glPushMatrix(); glColor3f(0.0f,0.0f,0.0f); glTranslatef(0.05f, 0.10f, 0.18f); glutSolidSphere(0.05f,10,10); glTranslatef(-0.1f, 0.0f, 0.0f); glutSolidSphere(0.05f,10,10); glPopMatrix();

29 Snowmen: No Lists // Draw 36 Snowmen for(int i = -3; i < 3; i++) for(int j=-3; j < 3; j++) { for(int j=-3; j < 3; j++) { glPushMatrix(); glPushMatrix(); glTranslatef(i*10.0,0,j * 10.0); glTranslatef(i*10.0,0,j * 10.0); // Call the function to draw a snowman // Call the function to draw a snowman drawSnowMan(); drawSnowMan(); glPopMatrix(); glPopMatrix();} 36K polygons, 55 FPS

30 Making Display Lists GLuint createDL() { GLuint snowManDL; // Create the id for the list snowManDL = glGenLists(1); // start list glNewList(snowManDL,GL_COMPILE); // call the function that contains the rendering commands drawSnowMan(); // endList glEndList(); return(snowManDL); }

31 Display Lists advantages: more efficient than individual function calls for every vertex/attribute can be cached on the graphics board (bandwidth!) display lists exist across multiple frames represent static objects in an interactive application

32 Snowmen: Display Lists // Draw 36 Snowmen for(int i = -3; i < 3; i++) for(int j=-3; j < 3; j++) { for(int j=-3; j < 3; j++) { glPushMatrix(); glPushMatrix(); glTranslatef(i*10.0,0,j * 10.0); glTranslatef(i*10.0,0,j * 10.0); // Call the function to draw a snowman // Call the function to draw a snowman glCallList(Dlid); glCallList(Dlid); glPopMatrix(); glPopMatrix();}

33 Performance 55 FPS: no display list 153 FPS: 1 snowman display list, called 36x

34 Snowmen: One Big List GLuint createDL() { GLuint snowManDL; snowManDL = glGenLists(1); glNewList(snowManDL,GL_COMPILE); for(int i = -3; i < 3; i++) for(int j=-3; j < 3; j++) { glPushMatrix(); glTranslatef(i*10.0,0,j * 10.0); drawSnowMan(); glPopMatrix(); } glEndList(); return(snowManDL); }

35 Performance 55 FPS: no display list 153 FPS: 1 snowman display list, called 36x 108 FPS: single 36 snowman display list

36 Snowmen: Nested Lists GLuint createDL() { GLuint snowManDL,loopDL; snowManDL = glGenLists(1); loopDL = glGenLists(1); glNewList(snowManDL,GL_COMPILE); drawSnowMan(); glEndList(); glNewList(loopDL,GL_COMPILE); for(int i = -3; i < 3; i++) for(int j=-3; j < 3; j++) { glPushMatrix(); glTranslatef(i*10.0,0,j * 10.0); glCallList(snowManDL); glPopMatrix(); } glEndList(); return(loopDL); }

37 Performance 55 FPS: no display list 153 FPS: 1 snowman display list, called 36x 108 FPS: single 36 snowman display list 153 FPS: nested display lists exploit hierarchical structure