Scene Graph: Object-Oriented Scenes

A scene graph is a directed acyclic graph (DAG) that contains all of the data needed to render a 3D scene. Scene graphs are typically n-ary tree data structures, in which any node can contain any number of children. Scene graphs are also an object-oriented way to handle objects for a practical and organized 3D engine. These objects can be graphical objects, such as shapes and meshes, or nongraphical entities, such as lights, cameras, and sound objects, all organized in a scene hierarchy. Another thing that is special about scene graphs is that any particular node will inherit and concatenate the transformations and render states of its parents, just as our previous geometry hierarchy did.

Java is one of the easiest languages in which to write scene graphs because it is object oriented, and scene graphs are inherently object oriented, including the use of base classes, garbage collection, runtime type identification, and multithreading. Much of the design and implementation effort for C/C++ scene graphs is spent dealing with these issues that are already part of the Java platform.

Why Use a Scene Graph?

A well-implemented scene graph will take advantage of various techniques to achieve better performance with the graphics hardware without forcing the developer to be familiar with the complex algorithms it employs to achieve this. In addition, scene graphs abstract the rendering operations from a process-oriented problem to a data-oriented problem. This is the crux of what is considered retained-mode graphics, but scene graphs take this idea even further by adding additional scene-based behavior support, such as switching geometry, LOD geometry, and even updating the use of scene-based behaviors.

These techniques are generally designed to minimize the number of operations done on the host CPU and graphics commands sent to the graphics hardware API. In Java, this design has additional performance benefits because this means there should be fewer overall JNI calls and their associated overhead, as well.

Some of the techniques are hardware specific, such as OpenGL display lists, vertex arrays, and vertex buffer objects, just like our RenderShape used. Other techniques include many different types of view culling and render state sorting. View culling is used to determine which geometry lies either partially or wholly within the camera view. By eliminating the geometry that lies wholly outside the viewport, the number of geometry commands that are sent down the graphics pipeline is reduced. State sorting is also important because, if done properly, it can minimize costly render-state changes by optimally ordering the commands that it sends to the graphics hardware.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net