3.6. Paths

Paths are used to isolate particular objects in the scene graph. Suppose you want to refer to the left foot of the robot. Which node in Figure 3.10, “ Scene Graph Showing Shared Instancing of the Leg Group represents the left foot? You can't refer simply to the foot node, since that node is used for both the left and right feet. The answer is that the left foot is represented by the path, or chain, starting at the robot node (the root), and leading all the way down the graph to the foot node. Figure 3.12, “ Path Representing the Left Foot ” indicates the path for the left foot node.

A path contains references to a chain of nodes, each of which is a child of the previous node. A path represents a scene graph or subgraph (part of a scene graph). In scene graph diagrams in this book, a path is represented by a heavy line that connects the chain of nodes.

Path Representing the Left Foot

Figure 3.12.  Path Representing the Left Foot


Paths are returned by a picking or search action, and you can construct your own path. (See Chapter 8, Applying Actions for a detailed description of interactive picking.) The user of an interactive application might click the mouse over an object on the screen, causing the object to be picked, and then perform an operation on that object—for example, moving it, changing its color, or deleting it. The selection node manages a list of paths as the currently selected objects.

All actions that can be performed on a node can also be performed on a path. These actions include calculating a bounding box and origin for the path, accumulating a transformation matrix for it, and writing the path to a file.

How you use the information included in a path depends on your application. You may use the whole path, or only part of the path. If your user clicks the mouse on the robot's left foot, is the user selecting the whole robot, the left leg, or just the left foot? (Perhaps one click selects the whole robot, and subsequent clicks select parts of the robot that are lower in the graph, such as the left leg and foot.)