University of British Columbia CPSC 414 Computer Graphics Week 3, Monday 15 Oct 03 © Tamara Munzner 1 Hierarchies, Display Lists recap: matrix hierarchies,

Slides:



Advertisements
Similar presentations
Better Interactive Programs
Advertisements

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.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
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 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.
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.
OpenGL 3D and Animation for Simulating a Solar System
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Better Interactive Programs Ed Angel Professor of Computer Science, Electrical and Computer.
Projections and Picking Wed 24 Sep 2003
OpenGL Display Lists A way to improve performance.
Hierarchical Modeling II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hierarchical ModelingHofstra University1 Modeling Define volumetric objects in terms of surfaces patches that surround the volume Each surface patch is.
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.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Midterm Review Week 7, Wed 16 Oct 2003 midterm review project 1 demos, hall.
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.
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Kinematic Linkages.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Computing & Information Sciences Kansas State University Lecture 20 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 21 of 42 William H. Hsu.
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.
Geometry: 2-D Transformations Course web page: Chapter #3.
1 Better Interactive Programs. 2 Objectives Learn to build more sophisticated interactive programs using ­Picking Select objects from the display Three.
Computing & Information Sciences Kansas State University Lecture 19 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 19 of 42 William H. Hsu.
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.
MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.
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.
David Luebke1/5/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Transformations
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 9.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
OpenGL Objects Finalised. Debugging Tip For Debugging your applications remember: glGetError(); gluErrorString(); Don’t use these in release code (the.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Introduction of OpenGL - 3D Graphic and Animation
Transformations 5 University of British Columbia
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Transformations V, Viewing I Week 3, Fri Jan 22
Better Interactive Programs
Computer Graphics - Hierarchical Models-
Transformations 6 University of British Columbia
CSCE 441: Computer Graphics: Hierarchical Models
Project 1: Into Space! CG Concepts Needed
Transformations IV Week 3, Wed Jan 20
Display Lists & Text Glenn G. Chappell
Better Interactive Programs
Transformations 4 University of British Columbia
Transformations IV Week 3, Mon Jan 22
Transformations III Week 3, Mon Jan 21
Transformations IV Week 3, Wed Jan 23
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

University of British Columbia CPSC 414 Computer Graphics Week 3, Monday 15 Oct 03 © Tamara Munzner 1 Hierarchies, Display Lists recap: matrix hierarchies, stacks display lists

Week 3, Monday 15 Oct 03 © Tamara Munzner2 News Reminders –check web page often for updates index, schedule –check newsgroup News –last week’s slides posted as PDF –project 0 solutions posted

Week 3, Monday 15 Oct 03 © Tamara Munzner3 Readings Week 1 –Chap 1, graphics overview Week 2 –Chap 2, graphics programming –Chap 4, geometry and transformations Week 3 –Chap 9, hierarchical modeling –Chap 3, input and interaction

Week 3, Monday 15 Oct 03 © Tamara Munzner4 Transformation Hierarchies recap hierarchies don’t fall apart when changed transforms apply to graph nodes beneath

Week 3, Monday 15 Oct 03 © Tamara Munzner5 Matrix Stacks recap Push and pop matrix stack –avoid computing inverses or incremental xforms –avoid numerical error World coordinates T 1 (x) T 2 (x) T 3 (x)

Week 3, Monday 15 Oct 03 © Tamara Munzner6 Transformation Hierarchies recap 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)

Week 3, Monday 15 Oct 03 © Tamara Munzner7 Hierarchies Discussion 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

Week 3, Monday 15 Oct 03 © Tamara Munzner8 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

Week 3, Monday 15 Oct 03 © Tamara Munzner9 Single Parameter: complex mechanisms not easily expressible with affine transforms

Week 3, Monday 15 Oct 03 © Tamara Munzner10 Single Parameter: complex mechanisms not easily expressible with affine transforms

University of British Columbia CPSC 414 Computer Graphics Week 3, Monday 15 Oct 03 © Tamara Munzner 11 Display lists

Week 3, Monday 15 Oct 03 © Tamara Munzner12 Display Lists Concept: –If multiple copies of an object are required, it can be compiled into a display list: glNewList( listId, GL_COMPILE ); glBegin( …); … // geometry goes here glEndList(); // render two copies of geometry offset by 1 in z-direction: glCallList( listId ); glTranslatef( 0.0, 0.0, 1.0 ); glCallList( listId) ;

Week 3, Monday 15 Oct 03 © Tamara Munzner13 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

Week 3, Monday 15 Oct 03 © Tamara Munzner14 Display Lists Example: 36 Snowmen efficiency issues

Week 3, Monday 15 Oct 03 © Tamara Munzner15 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();

Week 3, Monday 15 Oct 03 © Tamara Munzner16 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();}

Week 3, Monday 15 Oct 03 © Tamara Munzner17 Display Lists Example: 36 Snowmen benchmarks of 36K polygons –55 FPS: no display list

Week 3, Monday 15 Oct 03 © Tamara Munzner18 Snowmen: 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); }

Week 3, Monday 15 Oct 03 © Tamara Munzner19 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();}

Week 3, Monday 15 Oct 03 © Tamara Munzner20 Display Lists Example: 36 Snowmen benchmarks of 36K polygons –55 FPS: no display list –153 FPS: 1 snowman display list, called 36x

Week 3, Monday 15 Oct 03 © Tamara Munzner21 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); }

Week 3, Monday 15 Oct 03 © Tamara Munzner22 Display Lists Example: 36 Snowmen benchmarks of 36K polygons –55 FPS: no display list –153 FPS: 1 snowman display list, called 36x –108 FPS: single 36 snowman display list

Week 3, Monday 15 Oct 03 © Tamara Munzner23 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); }

Week 3, Monday 15 Oct 03 © Tamara Munzner24 Display Lists Example: 36 Snowmen benchmarks of 36K polygons –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

Week 3, Monday 15 Oct 03 © Tamara Munzner25 Animating redraw entire screen each frame –clear to background color –traverse entire transformation stack –draw all geometry problem: flicker solution: double buffering

Week 3, Monday 15 Oct 03 © Tamara Munzner26 Double buffering two buffers, front and back –while front is on display, draw into back –when drawing finished, swap the two GLUT –glutInitDisplayMode(GLUT_DOUBLE); –glutSwapBuffers(); avoids flicker, but could be slow