IntroductionComputer Graphics CS 470
Popular in Course
Popular in ComputerScienence
This 18 page Class Notes was uploaded by Abe Jones on Saturday September 12, 2015. The Class Notes belongs to CS 470 at West Virginia University taught by Staff in Fall. Since its upload, it has received 5 views. For similar materials see /class/202775/cs-470-west-virginia-university in ComputerScienence at West Virginia University.
Reviews for IntroductionComputer Graphics
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 09/12/15
Computer Graphics CS 470 Computer Science and Electrical Engineering Dept West Virginia University November 7 2008 l 0 Scene Graph 39 Outline 0 Scene Graph 0 Introduction 0 Node structure Scene graph A way to represent states and objects in a scene 0 Hierarchical relationships between objects gt Not usually spatial relationships 0 Shared properties and attributes o The de nition is vague gt No single implementation gt Usually application speci c Chassis Righ t Front LeftFront Righ t reor Le Ft reor Wheel wheel wheel Wheel CS 470 West Virginia University Computer Graphics November 739 2008 4 3918quot39 S cene graph The scene graph is a container which holds scene objects The data structure may be a tree or a directed acyclic graph DAG Chasm Chassis Left front Left rear Righ tfront Leftfront Righ treor Le ftreor Wheel wheel wheel wheel nghl39 front Right rear i Wheel I o Directed edges represent parent child relationship 0 The root node has no parent 0 Each node in a tree has 1 parent except root node 0 Each node in a DAG has at least 1 parent except root node gt Multiple instances of the same object can be represented this way CS 470 West Virginia University V November 2008 5 18 Scene graph The object oriented approach nodes and sometimes edges are objects 0 Scene objects inherit from node or edge base class 0 Overloaded member functions 0 Some member functions recursively traverse tree in some order usually depth rst l arm arm leg leg M Mr Leftlower Rig ht Iower Leftlower Righ t Iower leg leg Head I Leftupper I RightUpperl Leftupper I Rightupperl M M a rig CS 470 West Virginia University 1 quot V 397 November 7 2008 6 18 Scene Graph Node structure Graph Nodes Procedural Approach Children CS 470 West Virginia University a Coputer Graphics struct treenode GLfloat m16 void f struct treenode sibling struct treenode Child o m16 transforation matrix 0 f pointer to render function 0 sibling child pointers which maintain the structure NeVember 1792008 7 1839 Node structure Graph Nodes Objectoriented Approach A more general framework for encapsulating data and methods which manipulate and display the data Good candidates for objects in the scene graph 0 Materials 0 Lights 0 High level geometrical objects Good candidates for methods 0 Render 0 Animate o Respond to input N ve39r nber 2008 8 ME Scene Graph Node structure Graph Nodes Objectoriented Approach Scene I Separator Separator Color I Translate I Obiectl I Translate I Obiect3 I Rotate I Translate I Rotate I Obiect 2 I Node can encapsulate 0 Material properties 0 Transformations o Objects 0 Lights 0 Render states CS 470 West Virginia University Computer Graphics N0 tuber 7 91 l Node structure Program organization At initialization o Read scene le 0 Construct objects 0 Build scene graph At runtime a display callback traverse the tree and render nodes 0 idle callback traverse tree and animate nodes 0 user input callback message passing or tree traversal I 1 1018 I Noaig signature Existing scenegraph APIs 0 Open Inventor o OSG Open Scene Graph 0 NVSG NVidia Scene Graph 0 OGRE Objectoriented graphics rendering engine I 31118 o gg gonna Node class from Angel book class Node public Node virtual NNode virtual void Render void AddChildNode k private void Traverse Node LeftChild Node Rightsibling friend class GLViewer I e rsmmsture Scene graph building void NodezzAddChildNode node ifLeftChildNULL LeftChildnode else nodeigtRightSiblingLeftChild LeftChildnode I o grsgguctm Scene graph traversal void NodeTraverse ifKeepMatriX glPushMatriX Render ifLeftChildNULL LeftChildigtTraverse ifKeepMatriX glPopMatriX ifRightSiblinglNULL RightsiblingigtTraverse Example node types class Color public Node private bool Changed float Color3f3 void ColorRender ifChanged glColorvaColor3f I o e s game Example node types class Materlal publlc Node prlva te bool changed5 void Materlal Render 1fChanged0 glMaterlalfvGLiFRONTiANDiBACK GLiAMBIENT Ambientm 1fChangedl glMate alfvGL7FRONT7ANDiBACK GLiDIFFUSE lefuse 1fChanged2 glMaterlalfvGLiFRONTiANDiBACK GLisPECULAR Specular 1fChanged3 glMaterlalfvGLiFRONTiANDiBACK GLiEMISSION Emlsslon 1fChanged 4 g1MatenalfGLJRowLANDJACK GLisHININESSV Shlnlness I may anytime class Geometry publlc Node protected Color esolorwode Drawstyle sstylewode class Sphere publlc Geometry prlvate float Radlus H vold Sphere Rendero glPushAttrlb GLiALLiATTRIBiBITS 1f ColorNode Colorwodeemender 0 1f MatNo 6 Math dergtRender 0 1f Trans ode Trsnswodeegtkender 0 1f styleNode stylewodeegtkender 0 glutSolldSphere derus 40 40 glPopAttrlb 0