SGI Techpubs Library

IRIX 6.5  »  Books  »  Developer  »  
OpenGL Optimizer Programmer's Guide: An Open API for Large-Model Visualization
(document number: 007-2852-002 / published: 1998-06-09)    table of contents  |  additional info  |  download
find in page

Chapter 6. Organizing the Scene Graph Spatially

To spatialize a scene graph means to structure the graph to reflect the spatial relationships of objects in the scene. Spatialization simplifies searching for a node with a particular location in space, and so increases the efficiency of view-frustum and occlusion culling, as well as highlighting and picking.

This chapter explores spatialization in the following sections:

Effect of Spatialization on Cull Traversals

As a view-frustum, cull, or highlighting traverser descends a spatialized graph, each parent node effectively contains a “sign post,” the union of the bounding boxes of its children, which directs the traverser towards a node of interest. More efficient traversal results because the traverser does not need to test every node in the scene to check whether a ray strikes an object; it can eliminate a subgraph with one node test. The maximum number of tests is the depth of the tree. You control the depth of the tree by how finely you subdivide the spatial volume, that is, by the granularity of the spatialization.

Granularity Trade-offs

Finer granularity for a scene graph reduces the load on the graphics hardware, but increases traversal time by increasing the number of nodes in the graph. A coarse level of granularity reduces traversal time, but slows the graphics pipeline because all the vertices in large csGeoSets must be processed even if only a small portion is actually visible. As discussed in the section “View-Frustum Culling”, an appropriate level of granularity balances the amount of time spent on cull tests with the time saved by eliminating unnecessary vertices from processing by the graphics hardware. In one example, it was found that spatializing and defining appropriate granularity reduced rendering time by a factor greater than ten.

When to Spatialize

Spatialization tools are useful when you have large objects in the viewing frustum, or when you intend to interactively manipulate selected objects.

Spatialization takes time; it serves no purpose if you spend more time spatializing than you would traversing and rendering without spatialization. Typically, spatialization during a flythrough application is not useful, and may disrupt interactions with the scene graph. Spatializing moving objects is also not typically useful.

Spatialization Algorithm

The spatialization method provided by OpenGL Optimizer is similar to the development of an octree, a graph in which children correspond to iterated subdivisions of a parent cube into eight equal cubes. For more information about octrees, see the book Computer Graphics: Principles and Practice listed in “Recommended Background Reading”.

Octree spatial division is simple and efficient. However, the OpenGL Optimizer spatializing tools subdivide space not by simply bisecting edges of a cube, as in an octree, but by selecting planes for subdivisions so that the rendering loads of the resulting volumes are similar. After each cut, the number of triangles is approximately the same on each side of the cutting plane.

Spatialization Control Parameters

The main parameters you can use to control spatialization are hints for the largest and smallest sets of triangles in each csGeoSet of the spatialized graph. The spatializing tools attempt to develop a scene graph with the number of triangles in each csGeoSet within the prescribed range.

Spatialization Classes

OpenGL Optimizer provides a high-level tool that allows you to re-structure a scene graph and its csGeoSets to get the desired number of triangles in each leaf node. You can specify the leaf nodes to be trifans or tristrips. More details are provided in the section “Spatialization Tool: opSpatialize”.

You can also use lower-level tools that perform the component procedures of this process, tools that spatialize a set of triangles, reorganize an existing set of nodes, and combine csGeoSets. Combining csGeoSets is useful if the nodes in a scene graph are not appropriate for spatial reorganization because, for example, they contain significantly different numbers of triangles, or the graph simply has too many small csGeoSets. The classes that provide these tools are discussed in the following sections:

Spatialization Tool: opSpatialize

The opSpatialize class may be the only spatialization tool you need. opSpatialize has one important method, convert(). You control combining and dividing of csGeoSets by specifying a range of values for the number of triangles in each leaf node.

convert() has the following behavior:

  • convert() combines or divides, as necessary, all the csGeoSets in or below the root node passed as an argument.

  • convert() organizes the nodes in the graph spatially such that the bounding box of each parent node is the union of the bounding boxes of its children.

  • convert() is overloaded. If the argument of convert() is a csGeoSet, only that csGeoSet() is affected. If the argument is the root node of a scene, the entire graph is processed.


Note: Do not spatialize a scene graph that has LOD nodes or transforms:


  • Spatializing csLOD siblings is a nonsensical operation.

  • The results of splitting a csGeoSet under a transform node do not necessarily stay under the transform node.

Class Declaration for opSpatialize

The class has the following methods:

class opSpatialize
{
public:
static csNode *convert( 
                   csNode *node,  
                   int goalMin,int goalMax,
                   const csBoxBound& bbox,
                   csType *outType = csTriFanSet::getClassType(),
                   opColorGenerator *c = opColorGenerator::noColors());
};

Arguments to opSpatialize::convert()

convert() has the following arguments:

node 

Root node of the graph you want to spatialize.

bbox 

Volume to be subdivided.

goalMax 

Target maximum number of triangles in any leaf node in the final scene graph.

goalMin 

Minimum number of triangles in any leaf node in the final scene graph.

outType 

Type of all csGeoSets in the new, spatialized graph: csTriStrip or csTriFan.

convert() also allows you to provide contrasting colors for the csTriStrips or csTriFans in the new graph by using opColorGenerator in exactly the same way as opTriFanner and opTriStripper. See the section “Specifying Coloring of New csGeoSets: opColorGenerator” in Chapter 13 for more details.

Classes for Component Procedures of Spatialization

The method opSpatialize::convert() uses three component operations that are implemented individually in three OpenGL Optimizer classes:

  1. It uses the class opGeoSpatialize to organize the existing nodes in the scene graph.

  2. It uses opCombineGeoSets to combine triangles from small leaf nodes, where “small” means too few triangles.

  3. It uses opTriSpatialize to subdivide large leaf nodes.

These classes are discussed in the following sections:

Spatializing a Scene Graph: opGeoSpatialize

The class opGeoSpatialize reorganizes existing nodes in a scene graph. Given a bounding box and a scene-graph root node, convert()

  • subdivides the box and re-arranges the node hierarchy until there are approximately a specified number of triangles in each of the resulting volumes.

  • combines csGeoSets with too few triangles into larger csGeoSets by using the class opCombineGeoSets (see“Merging csGeoSets in a Scene Graph: opCombineGeoSets”).

Figure 6-1 illustrates the effects of opGeoSpatialize on a scene graph of car parts. The csGeoSets for three of the tire-and-rim combinations (necessarily contained in csShape nodes) are placed appropriately with respect to front or rear, and left or right. The csGeoSets for the fourth tire and rim are combined in one csGeoSet, and placed appropriately in the graph. The csGeoSet for the seat is placed in a portion of the graph for triangles in the center.

Figure 6-1. Organizing and Combining csGeoSets With opGeoSpatialize

Figure 6-1 Organizing and Combining csGeoSets With opGeoSpatialize

Class Declaration for opGeoSpatialize

The class has the following methods:

class opGeoSpatialize : public opDFTravAction
{
public:
opGeoSpatialize(int goalMin,int goalMax, const csBoxBound& bbox);
~opGeoSpatialize();

opTravDisp preNode(csNode *&, const opActionInfo&);
opActionDisp   end(csNode *&, const opActionInfo&);

void addShape(csShape *s);

csNode *done(csType *outType = csTriFanSet::getClassType(),
             opColorGenerator *c = opColorGenerator::noColors());

static csNode *convert( 
                   csNode *node,
                   int goalMin,int goalMax,
                   const csBoxBound& bbox,
                   csType *outType = csTriFanSet::getClassType(),
                   opColorGenerator *c = opColorGenerator::noColors());
};

Methods in opGeoSpatialize

The opGeoSpatialize class has several member functions needed for a scene-graph traversal (see Chapter 12, “Traversing a Large Scene Graph”). To spatialize a scene graph, however, call convert().

convert() 

Reorganizes the scene graph. Takes the same set of arguments as opSpatialize::convert(). A call to convert() returns a root csNode for the new graph. However, if the csNode argument is not the root of a (sub)graph, convert() does nothing.

opGeoSpatialize uses an opGeoConverter to organize the triangles in the csNodes. See “Decomposing csGeoSets Into Constituent Triangles: opGeoConverter”.

Merging csGeoSets in a Scene Graph: opCombineGeoSets

When you have a scene (sub)graph with too many small csGeosets, you can combine them and develop a graph consisting of a root node with children. Each child contains all the triangles of the original graph that have the same appearance. You can specify whether the output csGeoSets are csTriStripSets or csTriFanSets. You can subsequently use opTriSpatialize on the combined triangles to further develop a scene graph structure and adjust granularity; this is the approach taken by opSpatialize.

The result of combining csGeoSets is faster rendering, because of reduced traversal time and the possibility of larger trifans or tristrips. In one model with too many small csGeoSets, simply combining csGeoSets reduced rendering time by over two thirds.

Figure 6-2 illustrates the effects of combining csGeoSets. Notice that interior nodes of the scene graph are lost: combine nodes before you create LODs or insert transform nodes. Figure 6-2, which represents scene graph changes, shows the csShape nodes that contain the csGeoSets.

Figure 6-2. Combining csGeoSets with opCombineGeoSets

Figure 6-2 Combining csGeoSets with opCombineGeoSets

Class Declaration for opCombineGeoSets

The class has the following methods:

class opCombineGeoSets : public opDFTravAction
{
public:
opCombineGeoSets();
~opCombineGeoSets();
opTravDisp preNode(csNode *&, const opActionInfo&);
opActionDisp end(csNode *&, const opActionInfo&);

void addGeoSet(csGeoSet *gs,csAppearance *app);
csNode *buildGraph(csType *outType=csTriFanSet::getClassType(),
                   opColorGenerator *c = opColorGenerator::noColors());

static csNode *convert(
                csNode *root, float norm_tol,
                csType *outType=csTriFanSet::getClassType(),
                opColorGenerator *c = opColorGenerator::noColors()
                );
};

Methods in opCombineGeoSets

The opCombineGeoSets class has several methods needed for a scene-graph traversal (see Chapter 12, “Traversing a Large Scene Graph”). However, to combine csGeoSets, call convert(), which handles the traversal details for that case.

convert() 

Produces a new scene graph with csGeoSets combined wherever possible. You can use an opColorGenerator to control coloring of the new graph as you do with opSpatialize::convert().

Note that if the csMaterials associated with two csGeoSets do not match, then they will not be combined.

Spatializing a Single csShape: opTriSpatialize

The most elementary spatialization task successively subdivides a bounding box containing a set of triangles until there are approximately a specified number of triangles in each of the resulting volumes. Thus the loads on the graphics hardware are approximately the same for all of the leaf nodes.

The main method of the class opTriSpatialize is the overloaded convert() function, which redistributes triangles into csGeoSets containing similar numbers of triangles. Except for the arguments that specify the set of triangles on which convert() acts, its arguments are the same as for opSpatialize::convert() and have the same effects. You specify the set of triangles to be manipulated by convert() with a csBoxBound and csShape. Alternatively, you can use a csGeoSet and a csAppearance.

opTriSpatialize uses an opGeoConverter to manage the set of triangles and preserve results for other operations. See “Decomposing csGeoSets Into Constituent Triangles: opGeoConverter”.

Figure 6-3 illustrates the effects of spatializing the set of triangles in one csGeoSet that describes all four wheels of a car. A csGeoSet is created for each wheel and placed in a csShape node corresponding to the spatial position of the wheels.

Figure 6-3. Creating a Spatialized Graph From the csGeoSet in One csShape

Figure 6-3 Creating a Spatialized Graph From the csGeoSet in One csShape

Class Declaration for opTriSpatialize

The class has the following methods:

class opTriSpatialize
{
public:
opTriSpatialize(int goalMin,int goalMax,
                 const csBoxBound& bbox,
                 opGeoConverter *gc,
                 csAppearance *app);
~opTriSpatialize();

void addTriangle(const opTriangle *t);
csNode *done(csType *outType=csTriFanSet::getClassType(),
             opColorGenerator *c = opColorGenerator::noColors());

static csNode *convert(             
           csGeoSet *gs, csAppearance *app,
           int goalMin,int goalMax,
           const csBoxBound& bbox,
           csType *outType=csTriFanSet::getClassType(),
           opColorGenerator *colors = opColorGenerator::noColors());

static csNode *convert(
           csShape *shape,
           int goalMin,int goalMax,
           const csBoxBound& bbox,
           csType *outType=csTriFanSet::getClassType(),
           opColorGenerator *colors = opColorGenerator::noColors());
};

OpenGL Optimizer Programmer's Guide: An Open API for Large-Model Visualization
(document number: 007-2852-002 / published: 1998-06-09)    table of contents  |  additional info  |  download

    Front Matter
    About This Guide
    Part I. Getting Started
    Part II. High-Level Strategic Tools for Fast Rendering
    Part III. Specific Tools for Fast Rendering
    Part IV. Managing and Rendering Higher-Order Geometric Primitives
    Part V. Traversers, Low-Level Geometry Processing, and Multiprocessing
    Part VI. Utilities and Troubleshooting
    Part VII. Appendices
    Glossary
    Index


home/search | what's new | help