164
Chapter 14: Optimizing Rendering
Indexing csGeoSet Attributes
You can specify the appearance of all the csGeoSet elements making up a geometry
either individually or collectively. You have the option of specifying the attribute values
sequentially, so that the first element is described by the first csAttribute values or you
can use an index system.
Choosing to index the attribute values (or not) can dramatically affect application
performance. The general rule to remember when indexing or not is to determine
whether many elements share the same vertices, or not. If many elements share the same
vertex, index the attribute values; if a vertex is not shared by many elements, specify the
attribute values of the elements sequentially.
For more information about indexing, see “Indexing Attributes” on page 23.
Setting the Transformation Matrix Directly
Whether you set the transformation matrix explicitly or you use the csContext methods
that set the transformation matrix for you, rendering performance is optimized for the
following reason: a shape can be translated, scaled, and rotated. Rather than computing
these methods every time a shape is drawn, the transformation matrix represents the
product of all three methods. Likewise, when a transformation matrix node is the parent
of many shape nodes, the transformation for all of the children shape nodes is captured
in a single transformation matrix.
Compiling Part of a Scene Graph
Although there are no restrictions on the way in which you create a scene graph, it is
customary to find that pieces deep in a scene graph branch add to pieces above them,
which add to pieces above them until an entire object is described. For example, the
lowest node in a branch might be a toe, the node above it might be the foot, the node
above that the leg, the node above that the body; taken together, the nodes describe one
side of the lower half of a body, as shown in Figure 14-6.