1 / 49

CSCE 441: Computer Graphics: Hierarchical Models

CSCE 441: Computer Graphics: Hierarchical Models. Jinxiang Chai. Summary: 3D Geometry Pipeline. Object space. World space. View space. Normalized project space. Image space. 2. Complex Models. Outline. Hierarchical Models

isanne
Download Presentation

CSCE 441: Computer Graphics: Hierarchical Models

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCE 441: Computer Graphics:Hierarchical Models Jinxiang Chai

  2. Summary: 3D Geometry Pipeline Object space World space View space Normalized project space Image space 2

  3. Complex Models

  4. Outline Hierarchical Models Reading: HB chapter 14, OpenGL Programming Guide, chapter 3, and course slides

  5. Symbols and Instances • Most graphics API supports a few primitives: - sphere - cube - cylinders • These symbols are instanced using instance transformation:

  6. Symbols and Instances • Most graphics API supports a few primitives: - sphere - cube - cylinders • These symbols are instanced using instance transformation: What’s the matrix for the instance transformation above?

  7. Symbols and Instances • Most graphics API supports a few primitives: - sphere - cube - cylinders • These symbols are instanced using instance transformation:

  8. Sample Instance Trans. • In opengl, instance transformation is created by modifying the Model-view matrix: glMatrixMode(GL_MODELVIEW); glLoadIdentity(…);// set current matrix to the identity glTranslate(…); // translate glRotate(…); //rotate glScale(…);//scale house();

  9. Sample Instance Trans. • In opengl, instance transformation is created by modifying the Model-view matrix: glMatrixMode(GL_MODELVIEW); glLoadIdentity(…); glTranslate(…); glRotate(…); glScale(…); house(); Does the transform seem to be backward?

  10. Composite Transformation: Opengl Implementation • Opengl postmultiplies transformation matrices as they are called • Each subsequent transformation call concatenates the designated transformation matrix on the right of the composite matrix • We must invoke the transformation in the opposite order from which they are applied. glMatrixMode(GL_MODELVIEW); glLoadIdentity(…); M4; M3; M2; M1; …

  11. Lamp What’s the current coordinate A ? 11

  12. Lamp What’s the current coordinate A ? 12

  13. Lamp What’s the current coordinate A ? 13

  14. Lamp What’s the current coordinate A ? 14

  15. Lamp What’s the current coordinate A ? 15

  16. Lamp Implementation lamp() { M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm(); } Matrix M_model; Main() { … lamp(); } The lamp can be displayed by computing a global matrix and computing it at each step

  17. Lamp Implementation lamp() { M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm(); } Matrix M_model; Main() { … lamp() } Can we make it more efficiently? The lamp can be displayed by computing a global matrix and computing it at each step

  18. Better Implementation lamp() { M_model *= base(); M_model *= upper_arm(); M_model *= middel_arm(); M_model *= lower_arm(); } Matrix M_model; Main() { … M_model=Identity() lamp(); } • Instead recalculating the global matrix each time, we can just update it in place

  19. Opengl Implementation • Opengl maintains a global state matrix called model-view matrix Main() { … glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 2D_lamp(a,b,c,d,e,f) … } 2D_lamp(x, y, θ0,θ1,θ2,θ3) { glTranslatef(x,y,0) glRotatef(θ0,0,0,1,); base(); glTranslatef(0,l0,0) glRotatef(θ1,0,0,1,); upper_arm(); glTranslatef(0,l1,0) glRotatef(θ2,0,0,1,); middel_arm(); glTranslatef(0,l2,0) glRotatef(θ3,0,0,1,); lower_arm(); } //set current matrix to identity

  20. Hierarchical Modeling • Consider a model of a car – how many symbols? – how many instances?

  21. Hierarchical Modeling • Consider a model of a car – 2 symbols : – 5 instances :

  22. Hierarchical Modeling Chasis system World system front-left wheel system • Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel

  23. Hierarchical Modeling • Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel • We can represent our car as a tree to show the relationship between the parts

  24. Hierarchical Modeling • Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel • We can represent our car as a tree to show the relationship between the parts • However, since all 4 wheels are instances of the same model, we’d like to only have that model appear once

  25. Hierarchical Modeling • Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry

  26. Hierarchical Modeling • Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry What might we draw the tree for the lamp?

  27. Hierarchical Modeling • Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry

  28. Hierarchical Modeling world base Upper arm middle arm lower arm • Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry

  29. A More Complex Example: Human Figure torso

  30. A More Complex Example: Human Figure torso

  31. A More Complex Example: Human Figure torso What’s the most efficient way to draw this figure?

  32. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  33. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  34. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  35. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  36. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  37. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  38. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  39. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  40. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  41. A More Complex Example: Human Figure torso What’s the most sensible way to traverse this tree?

  42. Opengl Implementation: Human Figure torso Mh Mlua Mlla

  43. Opengl Implementation: Human Figure torso Mh Mlua Mlla Is this correct?

  44. Opengl Implementation: Human Figure I torso Mh Mh*Mlua should be Mlua Mh*Mlua*Mlla should be Mlua*Mlla Is this correct? No

  45. Matrix Stack • glMatrixMode(GL_MODELVIEW) - Initially, each of the stacks contains one matrix, an identity matrix. - The top matrix in the stack is “current matrix” - The depth is at least 32 Mc … I

  46. Push and Pop the Current Matrix • glPushMatrix() copy the current matrix at the top of the stack Mc Mc Mc … I … I

  47. Push and Pop the Current Matrix • glPopMatrix() destroies the matrix at the top of stack Mtop-1 Mtop Mtop-1 … … I I

  48. Opengl Implementation: Human Figure

  49. Opengl Implementation: Human Figure I Mh Mlua Mlua Mlla

More Related