Hierarchy, Modeling, and Scene Graphs Angel: Chapter 10 OpenGL Programming and Reference Guides, other sources. ppt from Angel, AW, etc. CSCI 6360/4360.

Slides:



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

Hierarchical Modeling I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Transformations Objectives Understand how transformations work in 2D and 3D Understand the concept of homogenous coordinate system Understand scene graphs.
Hierarchical Modeling II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Transformations III Week.
Graphical Objects and Scene Graphs CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
Hierarchical Transformations and Models CSE 3541 Matt Boggus.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
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
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.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Kinematic Linkages.
Chapter 10 Bresenham’s Algorithm Data Structures and Graphics or Working with Models.
Graphical Objects and Scene Graphs 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
Transforms Hierarchical Modeling Scene Graphs Using hierarchical modeling techniques in 3D software design Transforms Local basis Matrix math review Matrices.
Demetriou/Loizidou – ACSC330 – Chapter 9 Hierarchical and Object-Oriented Modeling Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
Multiway Trees. Trees with possibly more than two branches at each node are know as Multiway trees. 1. Orchards, Trees, and Binary Trees 2. Lexicographic.
Implementing Scene Graphs, CSG Trees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, January 26, 2004.
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.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 40 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 40 Computer Graphics Hierarchy I.
CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Kinematics Jehee Lee Seoul National University. Kinematics How to animate skeletons (articulated figures) Kinematics is the study of motion without regard.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
111/16/ :14 UML Instance Transformation x y z x y z x y z x y z SRT Model Coordinates.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Hierarchical and Object-Oriented Graphics Construct complex models from a set of simple geometric objects Extend the use of transformations to include.
Transformations Tutorial
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
Computer Graphics I, Fall 2008 Hierarchical Modeling II.
Scene Graph & Game Engines. 2 Limitations of Immediate Mode Graphics  When we define a geometric object in an application, upon execution of the code.
Models & Hierarchies CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 9.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
University of New Mexico
Attack of the Clones Image source:
Graphical Objects and Scene Graphs Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hierarchical Modeling. 2 Objectives Build a tree-structured model of a humanoid figure. Examine various traversal strategies. Build a generalized tree-model.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
Computer Graphics I, Fall 2008 Hierarchical Modeling I.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a.
Hierarchical Models Chapter 9.
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Graphical Objects and Scene Graphs
Graphical Objects and Scene Graphs
Using the basic-objects-IFS.js Utility
Modeling and Hierarchy
Hierarchical Modeling II
Hierarchical Transformations Hierarchical Models Scene Graphs
Computer Graphics - Hierarchical Models-
Modeling and Hierarchy
Hierarchical and Object-Oriented Graphics
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
CSCE 441: Computer Graphics: Hierarchical Models
Hierarchical and Object-Oriented Graphics
Hierarchical Modeling I
Hierarchical Modeling & Constructive Solid Geometry
Transformations III Week 3, Mon Jan 21
Dr. Chih-Kuo Yeh 葉智國 Computer Graphics Dr. Chih-Kuo Yeh 葉智國
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

Hierarchy, Modeling, and Scene Graphs Angel: Chapter 10 OpenGL Programming and Reference Guides, other sources. ppt from Angel, AW, etc. CSCI 6360/4360

Overview Angel chapter on hierarchy and modeling … Presents ideas essentially “intuitive” to those trained in use of object oriented paradigm Detailed explication of translation of procedural OpenGL ideas to hierarchical (object oriented) formulation … pretty straightforward Scene graphs - From c/c++ perspective of OpenGL - “bleeding edge” of software Lacks standards Open source formulation of OpenGL - … Vendors have their own “toolkits” – nVidia, … From truly object oriented perspective – “couldn’t be more natural” Only way to do it in Java – Java3d

Overview Examine the limitations of linear modeling Symbols and instances Introduce hierarchical models Articulated models Robots Introduce Tree and DAG models But, don’t worry it (almost) all goes away with the various scene graph implementations and tools

Instances Start with a prototype object (a symbol) Each appearance of the object in the model is an instance Must scale, orient, position Defines instance transformation Can store a model by assigning a number to each symbol and storing the parameters for the instance transformation Symbol-instance table

Structure Through Function Calls Symbol-instance table does not show relationships between parts of model Consider model of car Chassis + 4 identical wheels Two symbols Rate of forward motion determined by rotational speed of wheels Structure Through Function Calls car(speed) { chassis() wheel(right_front); wheel(left_front); wheel(right_rear); wheel(left_rear); } Fails to show relationships well Look at problem using a graph

Graphs, Trees, Models Graph Tree Tree Model of Car DAG Model Set of nodes and edges (links) Edge connects a pair of nodes Directed or undirected Cycle: directed path that is a loop Tree Graph in which each node (except the root) has exactly one parent node May have multiple children Leaf or terminal node: no children Tree Model of Car DAG Model If we use the fact that all the wheels are identical, we get a directed acyclic graph Not much different than dealing with tree loop root node leaf node

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

Angel Example: Robot Arm parts in their own coodinate systems Robot arm is an example of an articulated mode Parts connected at joints Can specify state of model by giving all joint angles

Relationships in Robot Arm Base rotates independently Single angle determines position Lower arm attached to base Its position depends on rotation of base Must also translate relative to base and rotate about connecting joint Upper arm attached to lower arm Its position depends on both base and lower arm Must translate relative to lower arm and rotate about joint connecting to lower arm Rotation of base: Rb Apply M = Rb to base Translate lower arm relative to base: Tlu Rotate lower arm around joint: Rlu Apply M = Rb Tlu Rlu to lower arm Translate upper arm relative to upper arm: Tuu Rotate upper arm around joint: Ruu Apply M = Rb Tlu Rlu Tuu Ruu to upper arm

Required Matrices and Code Rotation of base: Rb Apply M = Rb to base Translate lower arm relative to base: Tlu Rotate lower arm around joint: Rlu Apply M = Rb Tlu Rlu to lower arm Translate upper arm relative to upper arm: Tuu Rotate upper arm around joint: Ruu Apply M = Rb Tlu Rlu Tuu Ruu to upper arm robot_arm() { glRotate(theta, 0.0, 1.0, 0.0); base(); // draw glTranslate(0.0, h1, 0.0); glRotate(phi, 0.0, 1.0, 0.0); lower_arm(); // draw glTranslate(0.0, h2, 0.0); glRotate(psi, 0.0, 1.0, 0.0); upper_arm(); // draw }

Tree Model of Robot Code shows relationships between parts of model robot_arm() { glRotate(theta, 0.0, 1.0, 0.0); base(); // draw glTranslate(0.0, h1, 0.0); glRotate(phi, 0.0, 1.0, 0.0); lower_arm(); // draw glTranslate(0.0, h2, 0.0); glRotate(psi, 0.0, 1.0, 0.0); upper_arm(); // draw } Code shows relationships between parts of model Can change “look” of parts easily without altering relationships Simple example of tree model Want a general node structure for nodes

Possible Node Structure robot_arm() { glRotate(theta, 0.0, 1.0, 0.0); base(); // draw glTranslate(0.0, h1, 0.0); glRotate(phi, 0.0, 1.0, 0.0); lower_arm(); // draw glTranslate(0.0, h2, 0.0); glRotate(psi, 0.0, 1.0, 0.0); upper_arm(); // draw } Code for drawing part or pointer to drawing function linked list of pointers to children matrix relating node to parent

Generalizations Need to deal with multiple children Animation How to represent a more general tree How to traverse such a data structure Animation How to use dynamically How to create and delete nodes during execution Will consider building a model – of a humanoid figure

Building the Model Simple implementation using quadrics: ellipsoids and cylinders Access parts through functions torso(), left_upper_arm() Matrices describe position of node with respect to its parent Mlla positions left lower leg with respect to left upper arm

Building the Model Simple implementation using quadrics: ellipsoids and cylinders Access parts through functions torso(), left_upper_arm() Matrices describe position of node with respect to its parent Mlla positions left lower leg with respect to left upper arm

Display and Traversal The position of the figure is determined by 11 joint angles (two for the head and one for each other part) Display of the tree requires a graph traversal Visit each node once Display function at each node that describes the part associated with the node, applying the correct transformation matrix for position and orientation

Transformation Matrices Detail There are 10 relevant matrices: M positions and orients entire figure through the torso which is the root node Mh positions head with respect to torso Mlua, Mrua, Mlul, Mrul position arms and legs with respect to torso Mlla, Mrla, Mlll, Mrll position lower parts of limbs with respect to corresponding upper limbs

Stack-based Traversal Detail Set model-view matrix to M and draw torso Set model-view matrix to MMh and draw head For left-upper arm need MMlua and so on Rather than recomputing MMlua from scratch or using an inverse matrix, we can use the matrix stack to store M and other matrices as we traverse the tree

Traversal Code Detail figure() { glPushMatrix() // save present model-view matrix torso(); glRotate3f(…); // update model-view matrix for head head(); glPopMatrix(); // recover original model-view matrix glPushMatrix(); // save it again glTranslate3f(…); // update model-view matrix for left upper arm glRotate3f(…); left_upper_arm(); glPopMatrix(); // recover and save original model-view matrix gain glPushMatrix(); :

Preorder Traversal Detail void traverse(treenode *root) { if(root == NULL) return; glPushMatrix(); glMultMatrix(root->m); root->f(); if(root->child != NULL) traverse(root->child); glPopMatrix(); if(root->sibling != NULL) traverse(root->sibling); }

Notes Details figure() { glPushMatrix() torso(); glRotate3f(…); head(); glPopMatrix(); glPushMatrix(); glTranslate3f(…); left_upper_arm(); : Must save model-view matrix before multiplying it by node matrix Updated matrix applies to children of node but not to siblings which contain their own matrices Traversal program applies to any left-child right-sibling tree The particular tree is encoded in the definition of individual nodes Order of traversal matters because of possible state changes in the functions

OpenGL and Objects OpenGL lacks an object orientation Consider, for example, a green sphere We can model the sphere with polygons or use OpenGL quadrics Its color is determined by the OpenGL state and is not a property of the object Defies our notion of a physical object We can try to build better objects in code using object-oriented languages/techniques

Imperative vs. Object-Oriented Programming Models Imperative programming model Example: rotate a cube The rotation function must know how the cube is represented Vertex list Edge list In object-oriented model, the representation is stored with the object The application sends a message to the object The object contains functions (methods) which allow it to “transform itself” Application glRotate cube data results Application glRotate cube data results

Angel - C/C++ Can try to use C structs to build objects C++ provides better support Use class construct Can hide implementation using public, private, and protected members in a class Can also use friend designation to allow classes to access each other Chapter has long example of creating graphics objects In fact would use a tool

Scene Graphs Recall figure model … Could describe model either by tree or by equivalent code Could write a generic traversal to display Can represent all elements of a scene (cameras, lights, materials, geometry) as C++ objects and should be able to show them in a tree Render scene by traversing this tree Scene graph

Scene Graph API Open Scene Graph (OSG), Cross-platform, supports culling, sorting, level of detail Inventor, Java3D, Nvidia scene graph (NVSG), VRML Scene graphs can also be described by a file (text or binary) Implementation independent way of transporting scenes Supported by scene graph APIs However, primitives supported should match capabilities of graphics systems Hence most scene graph APIs are built on top of OpenGL or DirectX (for PCs)

OSG and Viewer

OSG

End .