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

Slides:



Advertisements
Similar presentations
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Advertisements

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?
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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 2005 Tamara Munzner Transformations III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
Math Review Guest Lecturer: Michiel van de Panne Week 1, Wed Jan 9
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations Week 2,
Transformations II Week 2, Wed Jan 17
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
1 Geometrical Transformation 2 Outline General Transform 3D Objects Quaternion & 3D Track Ball.
Transformations IV Week 3, Wed Jan 23
© Tamara Munzner University of British Columbia Hierarchical modelling recap: composing transforms recap: composing transforms finish: rendering pipeline.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Math Review Week 1, Wed.
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.
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.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Mathematical Fundamentals
COMP 175: Computer Graphics March 10, 2015
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
C O M P U T E R G R A P H I C S Stuff CMSC 435 / 634 Transformations 1/29 Geometric Transformations Readings: Chapters 5-6.
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.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Modeling with OpenGL Practice with OpenGL transformations.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
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.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Math Review Week 1, Fri.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
Transformations 5 University of British Columbia
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Transformations V, Viewing I Week 3, Fri Jan 22
Transformations 6 University of British Columbia
Transformations 3 University of British Columbia
Transformations IV Week 3, Wed Jan 20
Transformations 4 University of British Columbia
Transformations IV Week 3, Mon Jan 22
Transformations III Week 3, Mon Jan 21
Transformations II Week 2, Fri Jan 18
Viewing/Projections I Week 3, Fri Jan 25
Transformations IV Week 3, Wed Jan 23
Hierarchical Modeling
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Transformations V Week 3, Wed Jan 24

2 Reading for Next 3 Lectures FCG Chapter 7 Viewing FCG Section Windowing Transforms RB rest of Chap Viewing RB rest of App Homogeneous Coords

3 Review: Transformation Hierarchies transforms apply to graph nodes beneath them design structure so that object doesn’t fall apart instancing

4 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() Review: Matrix Stacks OpenGL matrix calls postmultiply matrix M onto current matrix P, overwrite it to be PM or can save intermediate states with stack no need to compute inverse matrices all the time modularize changes to pipeline state avoids accumulation of numerical errors

5 Assignments

6 project 1 out today, due 5:59pm Fri Feb 2 you should start very soon! build armadillo out of cubes and 4x4 matrices think cartoon, not beauty template code gives you program shell, Makefile written homework 1 out today, due 3pm Fri Feb 2 theoretical side of material

7 Project 1 Advice do not model everything first and only then worry about animating interleave modelling, animation add body part, then animate it discover if on wrong track sooner depenencies: can’t get anim credit if no model use middle body as scene graph root check from all camera angles

8 Project 1 Advice finish all required parts before going for extra credit playing with lighting or viewing ok to use glRotate, glTranslate, glScale ok to use glutSolidCube, or build your own where to put origin? your choice center of object, range -.5 to +.5 corner of object, range 0 to 1

9 Project 1 Advice visual debugging color cube faces differently colored lines sticking out of glutSolidCube faces thinking about transformations move physical objects around play with demos Brown scenegraph applets

10 Project 1 Advice first: jump cut from old to new position all change happens in single frame do last: add smooth transition change happens gradually over 30 frames key click triggers animation loop explicitly redraw 30 times linear interpolation: each time, param += (new-old)/30 example: 5-frame transition

11 Tail Wag Frame 0

12 Tail Wag Frame 1

13 Tail Wag Frame 2

14 Tail Wag Frame 3

15 Tail Wag Frame 4

16 Tail Wag Frame 5

17 Project 1 Advice transitions safe to linearly interpolate parameters for glRotate/glTranslate/glScale do not interpolate individual elements of 4x4 matrix!

18 Style you can lose up to 15% for poor style most critical: reasonable structure yes: parametrized functions no: cut-and-paste with slight changes reasonable names (variables, functions) adequate commenting rule of thumb: what if you had to fix a bug two years from now? global variables are indeed acceptable

19 Version Control bad idea: just keep changing same file save off versions often after got one thing to work, before you try starting something else just before you do something drastic how? not good: commenting out big blocks of code a little better: save off file under new name p1.almostworks.cpp, p1.fixedbug.cpp much better:use version control software strongly recommended

20 Version Control Software easy to browse previous work easy to revert if needed for maximum benefit, use meaningful comments to describe what you did “started on tail”, “fixed head breakoff bug”, “leg code compiles but doesn’t run” useful when you’re working alone critical when you’re working together many choices: RCS, CVS, subversion RCS is a good place to start easy to use, installed on lab machines

21 RCS Basics setup, just do once in a directory mkdir RCS checkin ci –u p1.cpp checkout co –l p1.cpp see history rcs log p1.cpp compare to previous version rcsdiff p1.cpp checkout old version to stdout co –p1.5 p1.cpp > p1.cpp.5

22 Graphical File Comparison installed on lab machines xfdiff4 (side by side comparison) xwdiff (in-place, with crossouts) Windows: windiff Macs: FileMerge in /Developer/Applications/Utilities

23 Display Lists

24 Display Lists precompile/cache block of OpenGL code for reuse usually more efficient than immediate mode exact optimizations depend on driver good for multiple instances of same object but cannot change contents, not parametrizable good for static objects redrawn often display lists persist across multiple frames interactive graphics: objects redrawn every frame from new viewpoint from moving camera can be nested hierarchically snowman example

25 One Snowman 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();

26 Instantiate Many Snowmen // 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

27 Making Display Lists GLuint createDL() { GLuint snowManDL; // Create the id for the list snowManDL = glGenLists(1); glNewList(snowManDL,GL_COMPILE); drawSnowMan(); glEndList(); return(snowManDL); } snowmanDL = createDL(); 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(); } 36K polygons, 153 FPS

28 Transforming Normals

29 Transforming Geometric Objects lines, polygons made up of vertices just transform the vertices, interpolate between does this work for everything? no!

30 Computing Normals polygon: assume vertices ordered CCW when viewed from visible side of polygon normal for a vertex specify polygon orientation used for lighting supplied by model (i.e., sphere), or computed from neighboring polygons

31 Transforming Normals what is a normal? a direction homogeneous coordinates: w=0 means direction often normalized to unit length vs. points/vectors that are object vertex locations what are normals for? specify orientation of polygonal face used when computing lighting so if points transformed by matrix M, can we just transform normal vector by M too?

32 Transforming Normals translations OK: w=0 means unaffected rotations OK uniform scaling OK these all maintain direction

33 Transforming Normals nonuniform scaling does not work x-y=0 plane line x=y normal: [1,-1,0] direction of line x=-y (ignore normalization for now)

34 Transforming Normals apply nonuniform scale: stretch along x by 2 new plane x = 2y transformed normal: [2,-1,0] normal is direction of line x = -2y or x+2y=0 not perpendicular to plane! should be direction of 2x = -y

35 Planes and Normals plane is all points perpendicular to normal (with dot product) (matrix multiply requires transpose) explicit form: plane =

36 given M, what should Q be? stay perpendicular substitute from above thus the normal to any surface can be transformed by the inverse transpose of the modelling transformation Finding Correct Normal Transform transform a plane