Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Searching on Multi-Dimensional Data
Introduction to Trees. Tree example Consider this program structure diagram as itself a data structure. main readinprintprocess sortlookup.
Quadtrees Raster and vector.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Data Structures Data Structures Topic #8. Today’s Agenda Continue Discussing Table Abstractions But, this time, let’s talk about them in terms of new.
Hierarchical Modeling II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
CS 450: Computer Graphics 2D TRANSFORMATIONS
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
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
BSP Trees, Quadtrees & Octrees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January 28, 2004.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
COMP 175: Computer Graphics March 10, 2015
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Polygon Lists & 3-D File Formats Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 18, 2002.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
Linear Interpolation, Brief Introduction to OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September.
CS 481 Preview, Some Lighting Details Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 19, 2003.
Transforms Hierarchical Modeling Scene Graphs Using hierarchical modeling techniques in 3D software design Transforms Local basis Matrix math review Matrices.
Implementing Scene Graphs, CSG Trees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, January 26, 2004.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
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.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
More on Advanced Interfaces, Image Basics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, November 21, 2003.
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
Advanced HSR Methods Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
File Organization and Processing Week Tree Tree.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Advanced Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 31, 2003.
Transformations Tutorial
Computer Graphics I, Fall 2008 Hierarchical Modeling II.
Computer Graphics Matrix Hierarchies / Animation
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
More Object Representations
Reading data into sorted list Want to suck text file in and produce sorted list of the contents: Option 1 : read directly into array based list, sort afterwards.
Data Structure and Algorithms
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
Selection Mode, Introduction to Widgets Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 6, 2003.
Computer Graphics I, Fall 2008 Hierarchical Modeling I.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
COMP261 Lecture 23 B Trees.
Stenciling Effects Glenn G. Chappell
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Computer Graphics - Hierarchical Models-
Hierarchical and Object-Oriented Graphics
CSCE 441: Computer Graphics: Hierarchical Models
Projection in 3-D Glenn G. Chappell
More on Widgets, Misc. Topics
Hierarchical and Object-Oriented Graphics
Hierarchical Modeling & Constructive Solid Geometry
CS679 - Fall Copyright Univ. of Wisconsin
Dr. Chih-Kuo Yeh 葉智國 Computer Graphics Dr. Chih-Kuo Yeh 葉智國
Preview of 3-D Graphics Glenn G. Chappell
Computer Graphics Matrix Hierarchies / Animation
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 23, 2004

23 Jan 2004CS 481/6812 Review: More on Drawable Objects We have discussed deriving various classes of drawable objects from a base class Drawable. This makes it convenient to deal with drawable objects without knowing much about them. Thus new kinds of objects can be added to a program without altering existing drawing code. And all objects can be stored together in one big container. But watch out for that last one. These are no good: Drawable scenearray[MAX_DRAWABLES]; std::vector scenevec; But this is fine: std::vector scenevec; If you do this, make sure you handle allocation & deallocation properly!

23 Jan 2004CS 481/6813 Review: Hierarchical Objects [1/3] By a hierarchical object we mean a (moving) object with moving parts (that have moving subparts that have moving subsubparts …). We can implement hierarchical objects conveniently using the OpenGL matrix stacks, as long as we follow a few rules. Draw all objects in “standard position”. Handle model/view properly. Details on the next slide …

23 Jan 2004CS 481/6814 Review: Hierarchical Objects [2/3] A function that draws an object should draw it with a “standard” position and orientation. For example, in face.cpp, all object-drawing functions draw the object upright, centered at the origin, and fitting (roughly) within the square in which x & y lie between –1 and 1. A function that draws an object should use the current model/view transformation. Thus, the actual position, orientation, and size of the object drawn by a function are determined by the function’s caller. When model/view is modified, always do a push before the modification and a pop after you are done using the modified transformation: Do glPushMatrix. Modify model/view ( glTranslate *, etc.). Use model/view (draw something). Do glPopMatrix.

23 Jan 2004CS 481/6815 Review: Hierarchical Objects [3/3] EXAMPLE TIME A program to draw a movable “robot arm” was created in class.

23 Jan 2004CS 481/6816 Data Structures for Scenes: Introduction So far, we have generally represented an object in a program by writing a function to draw it. In serious CG applications, this is almost never done. Instead, we separate data and code. We write code to draw objects of various types. This code is applied to various data structures, which might be initialized from external files. Thus, we make it easier to modify a scene. But harder to write the initial code, of course. Using some of the OO-design ideas discussed last week, we can also allow introduction of new types of data with only minimal modification of the code. If a program is to draw an arbitrary scene, then we should store the scene objects in some kind of container. Now we look at how this might be done.

23 Jan 2004CS 481/6817 Data Structures for Scenes: Talking About Trees But first, some tree terminology: Trees are made of nodes. One node is the root. The nodes (if any) attached immediately below a given node are its children. Nodes with no children are leaves. Each node (except the root) is a child of its parent. Root A A’s children A’s parent Leaves are shown in green.

23 Jan 2004CS 481/6818 Data Structures for Scenes: Scene Containers [1/2] A scene could be stored as a linear sequence (array, vector, list) of objects. However, most often we store scenes in some kind of tree-like structure. Why? Scenes often have a natural hierarchical structure, and trees are good for representing hierarchies. Partial traversal of a tree can sometimes give us a good “approximation” of a scene. For example, have general shapes high in the tree and details lower in the tree. Then we can draw at a coarse level of detail by ignoring all nodes below a certain level. Some tree structures allow fast queries of various sorts. For example, “Am I inside an object?”. More on this later. Finding a node in a tree is fast (if the tree is reasonably balanced and has a structure that facilitates searching). Tree traversal is just about as fast as list traversal, so there is little performance penalty.

23 Jan 2004CS 481/6819 Data Structures for Scenes: Scene Containers [2/2] There are many types of tree-like structures for holding scenes. Some of the ways they vary: Trees can be organized by how the scene is constructed (scene graphs, CSG trees) or by spatial relationships of the parts (BPS trees, quadtrees & octrees). The former helps deal with transformations & such conveniently. The latter gets us quick answers to questions like “Am I inside an object?” “What is the nearest object?” or helps do certain operations like HSR efficiently. The order in which children are listed can have various meanings (BSP trees, quadtrees & octrees) or no meaning (scene graphs). Numbers of children can vary. E.g., in an octree, each node can have up to 8 children. Are objects stored in all nodes or just in leaves? What objects does the tree hold? Polygons? General drawable objects?

23 Jan 2004CS 481/68110 Data Structures for Scenes: Four Data Structures We will discuss four types of trees for holding scenes: Scene Graphs Organized by how the scene is constructed. Nodes hold objects. CSG Trees Organized by how the scene is constructed. Leaves hold 3-D primitives. Internal nodes hold set operations. BSP Trees Organized by spatial relationships in the scene. Nodes hold facets (in 3-D, polygons). Quadtrees & Octrees Organized spatially. Nodes represent regions in space. Leaves hold objects.

23 Jan 2004CS 481/68111 The Basics of Scene Graphs: Introduction We have already discussed (informally) a tree structure for holding a hierarchical object. The organization is based on the composition of the object. It helps us deal with transformations (and moving parts with moving subparts …) conveniently. This structure is a simple example of what is called a scene graph.

23 Jan 2004CS 481/68112 The Basics of Scene Graphs: Structure Structure of a (simple) scene graph: Each node corresponds to a drawable object. The children of a given node correspond to “parts” of the object; these may be movable. Thus, each node has a transformation. It, and all of its descendants, are drawn with this transformation. The descendants have, in addition, their own transformations. Data needed in each node: Drawable object (pointer to this?). Transformation (a matrix? a pointer to a matrix? a pointer to a function that returns a matrix?). Pointers to child nodes.

23 Jan 2004CS 481/68113 The Basics of Scene Graphs: Notes In face.cpp, if we stored the face in a scene graph, it might look like this: We can add functionality to scene graphs by putting other things in them. In particular: Light sources. Other things like light sources (e.g., environment maps). Head EyeEar NoseMouth Iris Pupil Eye Iris Pupil L.R. Hair