Graphical Objects and Scene Graphs

Slides:



Advertisements
Similar presentations
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Advertisements

Graphical Objects and Scene Graphs CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Hierarchy, Modeling, and Scene Graphs Angel: Chapter 10 OpenGL Programming and Reference Guides, other sources. ppt from Angel, AW, etc. CSCI 6360/4360.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
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.
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.
Demetriou/Loizidou – ACSC330 – Chapter 9 Hierarchical and Object-Oriented Modeling Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Building Models Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley.
Scene Graph & Game Engines. 2 Limitations of Immediate Mode Graphics  When we define a geometric object in an application, upon execution of the code.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Hierarchical Models Chapter 9.
Introduction to Computer Graphics with WebGL
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Introduction to Computer Graphics with WebGL
Ray Tracing Ed Angel Professor Emeritus of Computer Science
Graphical Objects and Scene Graphs
Using the basic-objects-IFS.js Utility
Modeling and Hierarchy
Hierarchical Modeling II
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Image Formation Ed Angel Professor Emeritus of Computer Science,
Models and Architectures
Introduction to Computer Graphics with WebGL
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Modeling and Hierarchy
Hierarchical and Object-Oriented Graphics
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Building Models Ed Angel
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Building Models Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics
Introduction to Computer Graphics
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Models and Architectures
Hierarchical Modeling I
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 3: Shaders
Programming with OpenGL Part 4: Color and Attributes
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Dr. Chih-Kuo Yeh 葉智國 Computer Graphics Dr. Chih-Kuo Yeh 葉智國
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Graphical Objects and Scene Graphs Ed Angel Professor Emeritus of Computer Science University of New Mexico E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Objectives Introduce graphical objects Generalize the notion of objects to include lights, cameras, attributes Introduce scene graphs E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Limitations of Immediate Mode Graphics When we define a geometric object in an application, upon execution of the code the object is passed through the pipeline It then disappears from the graphical system To redraw the object, either changed or the same, we must reexecute the code Display lists provide only a partial solution to this problem E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

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 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Imperative Programming Model Example: rotate a cube The rotation function must know how the cube is represented Vertex list Edge list cube data Application Rotate results E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Object-Oriented Programming Model In this 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 Cube Object message E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

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 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Cube Object Suppose that we want to create a simple cube object that we can scale, orient, position and set its color directly through code such as cube mycube; mycube.color[0]=1.0; mycube.color[1]= mycube.color[2]=0.0; mycube.matrix[0][0]=……… E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Cube Object Functions We would also like to have functions that act on the cube such as mycube.translate(1.0, 0.0,0.0); mycube.rotate(theta, 1.0, 0.0, 0.0); setcolor(mycube, 1.0, 0.0, 0.0); We also need a way of displaying the cube mycube.render(); E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Building the Cube Object class cube { public: float color[3]; float matrix[4][4]; // public methods private: // implementation } E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

The Implementation Can use any implementation in the private part such as a vertex list The private part has access to public members and the implementation of class methods can use any implementation without making it visible Render method is tricky but it will invoke the standard OpenGL drawing functions E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Other Objects Other objects have geometric aspects Cameras Light sources But we should be able to have nongeometric objects too Materials Colors Transformations (matrices) E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Application Code cube mycube; material plastic; mycube.setMaterial(plastic); camera frontView; frontView.position(x ,y, z); E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Light Object class light { // match Phong model public: boolean type; //ortho or perspective boolean near; float position[3]; float orientation[3]; float specular[3]; float diffuse[3]; float ambient[3]; } E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Scene Descriptions If we recall figure model, we saw that We could describe model either by tree or by equivalent code We could write a generic traversal to display If we can represent all the elements of a scene (cameras, lights,materials, geometry) as C++ objects, we should be able to show them in a tree Render scene by traversing this tree E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Scene Graph E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Preorder Traversal PushAttrib PushMatrix Color Translate Rotate Object1 Object2 PopMatrix PopAttrib … E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Group Nodes Necessary to isolate state chages Equivalent to Push/Pop Note that as with the figure model We can write a universal traversal algorithm The order of traversal can matter If we do not use the group node, state changes can persist E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Inventor and Java3D Inventor and Java3D provide a scene graph API 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) E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

VRML Want to have a scene graph that can be used over the World Wide Web Need links to other sites to support distributed data bases Virtual Reality Markup Language Based on Inventor data base Implemented with OpenGL E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Open Scene Graph Supports very complex geometries by adding occulusion culling in first path Supports translucently through a second pass that sorts the geometry First two passes yield a geometry list that is rendered by the pipeline in a third pass E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012