All Topics  
Scene graph

 

   Email Print
   Bookmark   Link






 

Scene graph



 
 
A scene graph is a general data structure
Data structure

A data structure in computer science is a way of storing data in a computer so that it can be used efficiently. It is an organization of mathematical and logical concepts of data....
 commonly used by vector-based graphics editing
Vector graphics

Vector graphics is the use of geometrical Primitive s such as point s, line , curves, and shapes or polygon, which are all based upon mathematical equations, to represent s in computer graphics....
 applications and modern computer games. Examples of such programs include AutoCAD, Adobe Illustrator
Adobe Illustrator

Adobe Illustrator is a vector graphics editor developed and marketed by Adobe Systems.The latest version, Illustrator CS4, is the fourteenth generation in the product line....
, Acrobat 3D, OpenSceneGraph
OpenSceneGraph

OpenSceneGraph is an open source high performance 3D graphics toolkit, used by application developers in fields such as visual simulation, computer games, virtual reality, scientific visualization and computer model....
 and CorelDRAW
CorelDRAW

CorelDRAW is a vector graphics editor developed and marketed by Corel of Ottawa, Canada. It is also the name of Corel's Graphics Suite. Its latest version, named X4 , was released in January 2008....
.

The scene graph is a structure that arranges the logical and often (but not necessarily) spatial representation of a graphical scene. The definition of a scene graph is fuzzy because programmers who implement scene graphs in applications and in particular the games industry take the basic principles and adapt these to suit particular applications.






Discussion
Ask a question about 'Scene graph'
Start a new discussion about 'Scene graph'
Answer questions from other users
Full Discussion Forum



Encyclopedia


A scene graph is a general data structure
Data structure

A data structure in computer science is a way of storing data in a computer so that it can be used efficiently. It is an organization of mathematical and logical concepts of data....
 commonly used by vector-based graphics editing
Vector graphics

Vector graphics is the use of geometrical Primitive s such as point s, line , curves, and shapes or polygon, which are all based upon mathematical equations, to represent s in computer graphics....
 applications and modern computer games. Examples of such programs include AutoCAD, Adobe Illustrator
Adobe Illustrator

Adobe Illustrator is a vector graphics editor developed and marketed by Adobe Systems.The latest version, Illustrator CS4, is the fourteenth generation in the product line....
, Acrobat 3D, OpenSceneGraph
OpenSceneGraph

OpenSceneGraph is an open source high performance 3D graphics toolkit, used by application developers in fields such as visual simulation, computer games, virtual reality, scientific visualization and computer model....
 and CorelDRAW
CorelDRAW

CorelDRAW is a vector graphics editor developed and marketed by Corel of Ottawa, Canada. It is also the name of Corel's Graphics Suite. Its latest version, named X4 , was released in January 2008....
.

The scene graph is a structure that arranges the logical and often (but not necessarily) spatial representation of a graphical scene. The definition of a scene graph is fuzzy because programmers who implement scene graphs in applications and in particular the games industry take the basic principles and adapt these to suit particular applications. This means there is no hard-and-fast rule as to what a scene graph should be.

A scene graph is a collection of nodes in a graph
Graph (data structure)

In computer science, a graph is a kind of data structure, specifically an abstract data type , that consists of a Set of nodes and a set of edges that establish relationships between the nodes....
 or tree
Tree (data structure)

In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked Vertex_. It is an acyclic connected graph where each node has a set of zero or more children nodes, and at most one parent node....
 structure. A node may have many children but often only a single parent, with the effect of a parent apparent to all its child nodes; an operation applied to a group automatically propagates its effect to all of its members. In many programs, associating a geometrical transformation matrix
Transformation matrix

In linear algebra, linear transformations can be represented by matrix . If T is a linear transformation mapping Rn to Rm and x is a column vector with n entries, then...
 (see also transformation
Transformation (mathematics)

In mathematics, a transformation could be any function from a set X to itself. However, often the set X has some additional algebraic or geometric structure and the term "transformation" refers to a function from X to itself which preserves this structure....
  and matrix) at each group level and concatenating such matrices together is an efficient and natural way to process such operations. A common feature, for instance, is the ability to group related shapes/objects into a compound object which can then be moved, transformed, selected, etc. as easily as a single object.

It also happens that in some scene graphs, a node can have a relation to any node including itself, or at least an extension that refers to another node (for instance Pixar
Pixar

Pixar Animation Studios is a CGI animation production company based in Emeryville, California, United States. To date, the studio has earned twenty-two Academy Awards, four Golden Globes, and three Grammy, among many other awards, acknowledgments and achievements....
's PhotoRealistic RenderMan
PhotoRealistic RenderMan

PhotoRealistic RenderMan, or PRMan for short, is a proprietary photorealistic RenderMan-compliant renderer.It primarily uses the Reyes rendering algorithm but is also fully capable of doing ray tracing and global illumination....
 because of its usage of Reyes rendering
Reyes rendering

Reyes rendering is a computer software architecture used in 3D computer graphics to rendering photo-realistic images. It was developed in the mid-1980s by Loren Carpenter and Robert L....
 algorithm, or Adobe Systems
Adobe Systems

Adobe Systems Incorporated is an United States computer Computer software company headquartered in San Jose, California, USA. The company has historically focused upon the creation of multimedia and creativity software products, with a more-recent foray into rich Internet application software development....
's Acrobat 3D for advanced interactive manipulation).

Scene graphs in graphics editing tools

In vector-based graphics editing, each node in a scene graph represents some atomic unit of the document, usually a shape such as an ellipse
Ellipse

In mathematics, an ellipse is the apparent shape of a circle viewed obliquely from outside it, as distinct from a hyperbola which is the shape seen from inside....
 or Bezier path
Bézier curve

In the mathematics field of numerical analysis, a B?zier curve is a parametric curve important in computer graphics and related fields.Generalizations of B?zier curves to higher dimensions are called B?zier surfaces, of which the B?zier triangle is a special case....
. Although shapes themselves (particularly paths) can be decomposed further into nodes such as spline nodes
Spline (mathematics)

In mathematics, a spline is a special Function defined piecewise by polynomials.In interpolation problems, spline interpolation is often preferred to polynomial interpolation because it yields similar results, even when using low degree polynomials, while avoiding Runge's phenomenon for higher degrees....
, it is practical to think of the scene graph as composed of shapes rather than going to a lower level of representation.

Another useful and user-driven node concept is the layer. A layer acts like a transparent sheet upon which any number of shapes and shape groups can be placed. The document then becomes a set of layers, any of which can be conveniently made invisible, dimmed, and/or locked (made read-only). Some applications place all layers in a linear list while others support sublayers (i.e., layers within layers, to any desired depth).

Internally, there may be no real structural difference between layers and groups at all, since they are both just nested scene graphs. If differences are needed, a common type declaration in C++
C++

C++ is a general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level programming language and low-level programming language language features....
 would be to make a generic scene graph class, and then derive layers and groups as subclasses. A visibility member, for example, would be a feature of a layer but not necessarily of a group.

Scene graphs in games and 3D applications

Scene graphs are useful for modern games using 3D graphics and increasingly large worlds or levels. In such applications, nodes in a scene graph (generally) represent entities or objects in the scene.

For instance, a game might define a logical relationship between a knight and a horse so that the knight is considered an extension to the horse. The scene graph would have a 'horse' node with a 'knight' node attached to it.

As well as describing the logical relationship, the scene graph may also describe the spatial relationship of the various entities: the knight moves through 3D space as the horse moves.

In these large applications, memory requirements are major considerations when designing a scene graph. For this reason many large scene graph systems use instancing to reduce memory costs and increase speed. In our example above, each knight is a separate scene node, but the graphical representation of the knight (made up of a 3D mesh, textures, materials and shaders) is instanced. This means that only a single copy of the data is kept, which is then referenced by any 'knight' nodes in the scene graph. This allows a reduced memory budget and increased speed, since when a new knight node is created, the appearance data does not need to be duplicated.

Scene graph implementation

The simplest form of scene graph uses an array
Array

In computer science, an array is a data structure consisting of a group of element s that are accessed by index . In most programming languages each element has the same data type and the array occupies a contiguous area of computer memory....
 or linked list
Linked list

In computer science, a linked list is one of the fundamental data structures, and can be used to implement other data structures. It consists of a sequence of node s, each containing arbitrary data Field s and one or two reference s pointing to the next and/or previous nodes....
 data structure
Data structure

A data structure in computer science is a way of storing data in a computer so that it can be used efficiently. It is an organization of mathematical and logical concepts of data....
, and displaying its shapes is simply a matter of linearly iterating the nodes one by one. Other common operations, such as checking to see which shape intersects the mouse pointer
Point location

The point location problem is a fundamental topic of computational geometry. It finds applications in areas that deal with processing geometrical data: computer graphics, geographic information systems , motion planning, and computer aided design ....
 (e.g., in a GUI
Gui

Gui or guee is a generic term to refer to grillinged dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients....
-based applications
Application software

Application software is any tool that functions and is operated by means of a computer, with the purpose of supporting or improving the software user 's work....
) are also done via linear searches. For small scene graphs, this tends to suffice.

Larger scene graphs cause linear operations to become noticeably slow and thus more complex underlying data structures are used, the most popular being a tree. This is the most common form of scene graph. In these scene graphs the composite design pattern
Composite pattern

In computer science, the composite pattern is a partitioning design pattern . Composite allows a group of objects to be treated in the same way as a single instance of an object....
 is often employed to create the hierarchical representation of group-nodes and leaf-nodes.

Group Nodes - Can have any number of child nodes attached to it. Group nodes include transformations and switch nodes.

Leaf Nodes - Are nodes that are actually rendered or see the effect of an operation. These include objects, sprites, sounds, lights and anything that could be considered 'rendered' in some abstract sense.

Scene graph operations and dispatch

In order to apply an operation on a scene graph, some way of dispatching an operation is needed based upon what node is currently being considered. For example in a render operation a transformation group-node would do nothing more than accumulate its transformation (generally this is matrix multiplication but could involve operations with vector displacement and quaternions or Euler angles
Euler angles

The Euler angles were developed by Leonhard Euler to describe the orientation of a rigid body in dimension Euclidean space. To give an object a specific orientation it may be subjected to a sequence of three rotations described by the Euler angles....
 instead). Whereas an object leaf-node would send the object off for rendering to the renderer (some implementations might render the object directly but this can integrate the underlying rendering API - e.g. OpenGL
OpenGL

OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
 or DirectX
DirectX

Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms....
 too tightly and rigidly - it is better to separate the scene graph and renderer systems as this promotes portability.)

In order to dispatch differently for different node types several different approaches can be taken, each have pros and cons and are widely disputed among programmers arguing which is best.

In Object-Oriented languages such as C++
C++

C++ is a general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level programming language and low-level programming language language features....
 this can easily be achieved by virtual functions, the node base class has virtual functions for every operation that can be performed on the nodes. This is simple to do but prevents the addition of new operations by other programmers that don't have access to the source. Alternatively the visitor pattern
Visitor pattern

In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure upon which it operates....
 can be used. This has a similar disadvantage in that it is similarly difficult to add new node types.

Other techniques involve the use of RTTI (Run-Time Type Information
Run-time type information

In programming, RTTI refers to a C++ system that keeps information about an object's data type in memory at runtime. Run-time type information can apply to simple data types, such as integers and characters, or to generic objects....
). The operation can be realised as a class which is passed the current node, it then queries the nodes type (RTTI) and looks up the correct operation in an array of callbacks or functors. This requires that at initialisation the user/system registers functors/callbacks with the different operations so they can be looked up in the array. This system offers massive flexibility, speed and extensibility of new nodes and operations.

Variations on these techniques exist and new methods can offer added benefits - one alternative is scene graph rebuilding where the scene graph is rebuilt for each of the operations performed, this however can be very slow but produces a highly optimised scene graph. This demonstrates that a good scene graph implementation depends heavily on the application in which it is used.

Traversals
Traversals are the key to the power of applying operations to scene graphs. A traversal generally consists of starting at some arbitrary node (often the root of the scene graph), applying the operation(s) (often the updating and rendering operations are applied one after the other), and recursively moving down the scene graph(tree) to the child nodes, until a leaf node is reached. At this point many scene graphs then traverse back up the tree, possibly applying a similar operation. Rendering is an example: While recursively traversing down the scene graph hierarchy the operation(s) applies a PreRender operation. Once reaching a leaf node, it begins traversing back up the tree, applying a PostRender operation. This nicely allows certain nodes to push a state for child nodes, and to pop the state afterwards.

Some scene graph operations are actually more efficient when nodes are traversed in a different order - this is where some systems implement scene graph rebuilding to reorder the scene graph into an easier to parse format or tree.

For example:

In 2D cases, scene graphs typically render themselves by starting at the tree's root node and then recursively drawing the child nodes. The tree's leaves represent the most foreground objects. Since drawing proceeds from back to front with closer objects simply overwriting farther ones, the process is known as employing the Painter's algorithm
Painter's algorithm

The painter's algorithm, also known as a priority fill, is one of the simplest solutions to the visibility problem in 3D computer graphics....
. In 3D systems, which often employ depth buffers, it is more efficient to draw the closest objects first, since farther objects often need only be depth-tested instead of actually rendered, because they are occluded by nearer objects.

Scene graph and bounding volume hierarchies (BVHs)

Bounding Volume Hierarchies (BVHs) are useful for numerous tasks - including efficient culling and speeding up collision detection between objects. A BVH is a spatial structure but doesn't have to partition the geometry (see spatial partitioning, below).

A BVH is a tree of bounding volume
Bounding volume

In computer graphics and computational geometry, a bounding volume for a set of objects is a closed volume that completely contains the union of the objects in the set....
s (often spheres, axis-aligned bounding boxes or/and oriented bounding boxes). At the bottom of the hierarchy the size of the volume is just large enough to encompass a single object tightly (or possibly even some smaller fraction of an object in high resolution BVHs). As one ascends the hierarchy each node has its own volume which tightly encompasses all the volumes beneath it. At the root of the tree is a volume that encompasses all the volumes in the tree (the whole scene).

BVHs are useful for speeding up collision detection between objects. If an object's bounding volume does not intersect a volume higher in the tree then it cannot intersect any object below that node (so they are all rejected very quickly).

Obviously there are some similarities between BVHs and scene graphs. A scene graph can easily be adapted to include/become a BVH - if each node has a volume associated or there is a purpose built 'bound node' added in at convenient location in the hierarchy. This may not be the typical view of scene graph but there are benefits to including a BVH in a scene graph.

Scene graphs and spatial partitioning

An effective way of combining spatial partitioning
Space partitioning

In mathematics, space partitioning is the process of dividing a space into two or more disjoint subsets . In other words, space partitioning divides a space into non-overlapping regions....
 and scene graphs is by creating a scene leaf node that contains the spatial partitioning data. This data is usually static and generally contains non-moving level data in some partitioned form. Some systems may have the systems separate and render them separately, this is fine and there are no real advantages to either method. In particular it is bad to have the scene graph contained within the spatial partitioning system, this is because the scene graph is better thought of as the grander system to the spatial partitioning.

When it is useful to combine them

In short: Spatial partitioning will/should considerably speed up the processing and rendering time of the scene graph.

Very large drawings, or scene graphs that are generated solely at runtime
Runtime

In computer science, runtime or run time describes the operation of a computer program, the duration of its execution, from beginning to termination ....
 (as happens in ray tracing
Ray tracing

In computer graphics, ray tracing is a technique for generating an digital image by tracing the path of light through pixel in an . The technique is capable of producing a very high degree of photorealism; usually higher than that of typical scanline rendering methods, but at a greater computation time....
 rendering programs), require defining of group nodes in a more automated fashion. A raytracer, for example, will take a scene description of a 3D
Dimension

In mathematics, the dimension of a space is roughly defined as the minimum number of coordinates needed to specify every point within it. For example: a point on the unit circle in the plane can be specified by two Cartesian coordinates but one can make do with a single coordinate , so the circle is 1-dimensional even though it exists in...
 model and build an internal representation that breaks up its individual parts into bounding boxes (also called bounding slabs). These boxes are grouped hierarchically so that ray intersection tests (as part of visibility determination) can be efficiently computed. A group box that does not intersect an eye ray, for example, can entirely skip having to test any of its members.

A similar efficiency holds in 2D applications as well. If the user has magnified a document so that only part of it is visible on his computer screen, and then scrolls said document, it is useful to use a bounding box (or in this case, a bounding rectangle scheme) to quickly determine which scene graph elements are visible and thus actually need to be drawn.

Depending on the particulars of the application's drawing performance, a large part of the scene graph's design can be impacted by rendering efficiency considerations. In 3D video games such as Quake, for example, binary space partitioning
Binary space partitioning

Binary space partitioning is a method for recursively subdividing a Euclidean space into convex sets by hyperplanes. This subdivision gives rise to a representation of the scene by means of a Tree known as a BSP tree....
 (BSP) trees are heavily favored to minimize visibility tests. BSP trees, however, take a very long time to compute from design scene graphs, and must be recomputed if the design scene graph changes so the levels tend to remain static and dynamic characters aren't generally considered in the spatial partitioning scheme.

Scene graphs for dense regular objects such as heightfields and polygon meshes tend to employ quadtree
Quadtree

A quadtree is a tree data structure in which each internal node has up to four children. Quadtrees are most often used to partition a two dimensional space by recursively subdividing it into four quadrants or regions....
s and octree
Octree

An octree is a tree data structure in which each internal node has up to eight children. Octrees are most often used to partition a three dimensional space by recursively subdividing it into eight octants....
s, which are specialized variants of a 3D bounding box hierarchy. Since a heightfield occupies a box volume itself, recursively subdividing this box into eight subboxes (hence the 'oct' in octree) until individual heightfield elements are reached is efficient and natural. A quadtree is simply a 2D octree.

PHIGS

PHIGS
PHIGS

PHIGS is an application programming interface standard for rendering 3D computer graphics, at one time considered to be the 3D graphics standard for the 1990s....
 was the first commercial scene graph specification, and became an ANSI standard in 1988. Disparate implementations were provided by Unix hardware vendors. The appears to have been the first commercial scene graph library provided by a single software vendor. It was designed to run on disparate lower-level 2D and 3D interfaces, with the first major production version (v3.0) completed in 1991. Shortly thereafter, Silicon Graphics released IRIS Inventor 1.0 (1992), which was a scene graph built on top of the IRIS GL 3D API. It was followed up with Open Inventor
Open Inventor

Open Inventor, originally IRIS Inventor, is a C++ object oriented retained mode 3D graphics API designed by Silicon Graphics to provide a higher layer of programming for OpenGL....
 in 1994, a portable scene graph built on top of OpenGL. More 3D scene graph libraries can be found in :Category:3D Scenegraph APIs.

See also

  • Graph theory
    Graph theory

    In mathematics and computer science, graph theory is the study of graph : mathematical structures used to model pairwise relations between objects from a certain collection....
  • Graph (data structure)
    Graph (data structure)

    In computer science, a graph is a kind of data structure, specifically an abstract data type , that consists of a Set of nodes and a set of edges that establish relationships between the nodes....
  • Tree (data structure)
    Tree (data structure)

    In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked Vertex_. It is an acyclic connected graph where each node has a set of zero or more children nodes, and at most one parent node....
  • Space partitioning
    Space partitioning

    In mathematics, space partitioning is the process of dividing a space into two or more disjoint subsets . In other words, space partitioning divides a space into non-overlapping regions....


Books

  • Leler, Wm and Merry, Jim (1996) 3D with HOOPS, Addison-Wesley
  • Wernecke, Josie (1994) The Inventor Mentor: Programming Object-Oriented 3D Graphics with Open Inventor, Addison-Wesley, ISBN 0-201-62495-8 (Release 2)


Web sites and articles

  • Strauss, Paul (1993).
  • Helman, Jim; Rohlf, John (1994).
  • Carey, Rikk and Bell, Gavin (1997).
  • PEXTimes
  • Bar-Zeev, Avi.
  • [https://java3d.dev.java.net Java3D]: , [https://lg3d.dev.java.net LG3D] ...