cs 4204 computer graphics
play

CS 4204 Computer Graphics Structure Graphics and Structure Graphics - PowerPoint PPT Presentation

CS 4204 Computer Graphics Structure Graphics and Structure Graphics and Hierarchical Modeling Hierarchical Modeling Yong Cao Yong Cao Virginia Tech Virginia Tech References: References: Interactive Computer Graphics, Fourth Edition, Ed


  1. CS 4204 Computer Graphics Structure Graphics and Structure Graphics and Hierarchical Modeling Hierarchical Modeling Yong Cao Yong Cao Virginia Tech Virginia Tech References: References: Interactive Computer Graphics, Fourth Edition, Ed Angle Interactive Computer Graphics, Fourth Edition, Ed Angle

  2. Objectives Examine the limitations of linear modeling Examine the limitations of linear modeling Examine the limitations of linear modeling • Symbols and instances Symbols and instances • • Symbols and instances Introduce hierarchical models Introduce hierarchical models Introduce hierarchical models • Articulated models Articulated models • • Articulated models • Robots Robots • • Robots Introduce Tree and DAG models Introduce Tree and DAG models Introduce Tree and DAG models

  3. Instance Transformation Start with a prototype object (a symbol symbol ) ) Start with a prototype object (a Start with a prototype object (a symbol ) Each appearance of the object in the model Each appearance of the object in the model Each appearance of the object in the model is an instance instance is an is an instance • Must scale, orient, position Must scale, orient, position • • Must scale, orient, position • Defines instance transformation Defines instance transformation • • Defines instance transformation

  4. Symbol-Instance Table Can store a model by assigning a number to Can store a model by assigning a number to Can store a model by assigning a number to each symbol and storing the parameters for each symbol and storing the parameters for each symbol and storing the parameters for the instance transformation the instance transformation the instance transformation

  5. Relationships in Car Model Symbol- -instance table does not show relationships instance table does not show relationships Symbol Symbol-instance table does not show relationships between parts of model between parts of model between parts of model Consider model of car Consider model of car Consider model of car • Chassis + 4 identical wheels Chassis + 4 identical wheels • • Chassis + 4 identical wheels • Two symbols Two symbols • • Two symbols Rate of forward motion determined by rotational Rate of forward motion determined by rotational Rate of forward motion determined by rotational speed of wheels speed of wheels speed of wheels

  6. Structure Through Function Calls car(speed) car(speed) { { chassis() chassis() wheel(right_front); wheel(right_front); wheel(left_front); wheel(left_front); wheel(right_rear); wheel(right_rear); wheel(left_rear); wheel(left_rear); } } Fails to show relationships well relationships well Fails to show Look at problem using a graph Look at problem using a graph

  7. Graphs Set of nodes nodes and and edges (links) edges (links) Set of Set of nodes and edges (links) Edge connects a pair of nodes Edge connects a pair of nodes Edge connects a pair of nodes • Directed or undirected • Directed or undirected • Directed or undirected Cycle : directed path that is a loop : directed path that is a loop Cycle Cycle : directed path that is a loop loop

  8. Tree Graph in which each node (except the root) has Graph in which each node (except the root) has Graph in which each node (except the root) has exactly one parent node exactly one parent node exactly one parent node • May have multiple children • May have multiple children • May have multiple children • Leaf or terminal node: no children • Leaf or terminal node: no children • Leaf or terminal node: no children root node leaf node

  9. Tree Model of Car

  10. DAG Model If we use the fact that all the wheels are identical, If we use the fact that all the wheels are identical, If we use the fact that all the wheels are identical, we get a directed acyclic graph directed acyclic graph we get a we get a directed acyclic graph • Not much different than dealing with a tree Not much different than dealing with a tree • • Not much different than dealing with a tree

  11. Modeling with Trees Must decide what information to place in Must decide what information to place in Must decide what information to place in nodes and what to put in edges nodes and what to put in edges nodes and what to put in edges Nodes Nodes Nodes • What to draw What to draw • • What to draw • Pointers to children Pointers to children • • Pointers to children Edges Edges Edges • May have information on incremental changes to May have information on incremental changes to • • May have information on incremental changes to transformation matrices (can also store in nodes) transformation matrices (can also store in nodes) transformation matrices (can also store in nodes)

  12. coordinate systems parts in their own Robot Arm robot arm

  13. Articulated Models Robot arm is an example of an articulated articulated Robot arm is an example of an Robot arm is an example of an articulated model model model • Parts connected at joints Parts connected at joints • • Parts connected at joints • Can specify state of model by Can specify state of model by • • Can specify state of model by giving all joint angles giving all joint angles giving all joint angles

  14. Relationships in Robot Arm Base rotates independently Base rotates independently Base rotates independently • Single angle determines position Single angle determines position • • Single angle determines position Lower arm attached to base Lower arm attached to base Lower arm attached to base • Its position depends on rotation of base Its position depends on rotation of base • • Its position depends on rotation of base • Must also translate relative to base and rotate Must also translate relative to base and rotate • • Must also translate relative to base and rotate about connecting joint about connecting joint about connecting joint Upper arm attached to lower arm Upper arm attached to lower arm Upper arm attached to lower arm • Its position depends on both base and lower arm Its position depends on both base and lower arm • • Its position depends on both base and lower arm • Must translate relative to lower arm and rotate Must translate relative to lower arm and rotate • • Must translate relative to lower arm and rotate about joint connecting to lower arm about joint connecting to lower arm about joint connecting to lower arm

  15. Required Matrices Rotation of base: R Rotation of base: R b Rotation of base: R b b • Apply Apply M M = = R R b to base • b to base • Apply M = R b to base Translate lower arm relative relative to base: to base: T Translate lower arm T lu Translate lower arm relative to base: T lu lu Rotate lower arm around joint: R Rotate lower arm around joint: Rotate lower arm around joint: R lu R lu lu • Apply Apply M M = = R R b T lu R lu to lower arm • lu to lower arm • Apply M = R b T lu R lu to lower arm b T lu R Translate upper arm relative relative to upper arm: to upper arm: T Translate upper arm Translate upper arm relative to upper arm: T uu T uu uu Rotate upper arm around joint: R Rotate upper arm around joint: Rotate upper arm around joint: R uu R uu uu • Apply Apply M M = = R R b T lu R lu T uu R uu to upper arm • b T lu R lu T uu R uu to upper arm • Apply M = R b T lu R lu T uu R uu to upper arm

  16. OpenGL Code for Robot robot_arm() { glRotate(theta, 0.0, 1.0, 0.0); base(); glTranslate(0.0, h1, 0.0); glRotate(phi, 0.0, 1.0, 0.0); lower_arm(); glTranslate(0.0, h2, 0.0); glRotate(psi, 0.0, 1.0, 0.0); upper_arm(); }

  17. Tree Model of Robot Note code shows relationships between parts of Note code shows relationships between parts of Note code shows relationships between parts of model model model • Can change • Can change “ “look look” ” of parts easily without altering relationships of parts easily without altering relationships • Can change “look” of parts easily without altering relationships Simple example of tree model Simple example of tree model Simple example of tree model Want a general node structure Want a general node structure Want a general node structure for nodes for nodes for nodes

  18. Possible Node Structure Code for drawing part or pointer to drawing function linked list of pointers to children matrix relating node to parent

  19. Generalizations Need to deal with multiple children Need to deal with multiple children Need to deal with multiple children • How do we represent a more general tree? How do we represent a more general tree? • • How do we represent a more general tree? • How do we traverse such a data structure? How do we traverse such a data structure? • • How do we traverse such a data structure? Animation Animation Animation • How to use dynamically? How to use dynamically? • • How to use dynamically? • Can we create and delete nodes during execution? Can we create and delete nodes during execution? • • Can we create and delete nodes during execution?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend