22.3.  Intersection Detection Action

Figure 22.2. Intersection detection action class


This class is an Open Inventor action. It allows programmers to analyze a complete scene graph to detect intersections between pairs of shapes. The action first detects intersections between bounding boxes. If an intersection exists between two shapes, the action calls a user filter function. This function can stop the detection process for these two shapes.

The second step of the intersection detection mechanism consists of comparing each triangle of both shapes. If a triangle collision is found, the action calls the user callbacks. Each callback is able to inform the action if it is interested in the next collision report. It can be informed of the intersection for the next graphics primitive or only for the next shape or it can just say that it is not interested in the next intersection. Intersections are detected even if objects are not visible or not pickable. See SoIntersectionDetectionAction( C++ | Java | .NET )for more information.

The code in the following example can be used to do this.

SoIntersectionDetectionAction (scene 1)
SoIntersectionDetectionAction (scene 1)

Intersections are detected between all the parts of the scene.

Figure 22.3. SoIntersectionDetectionAction (scene 1)


SoIntersectionDetectionAction (scene 2)
SoIntersectionDetectionAction (scene 2)

After the legs of the jumping man are moved, there is no intersection between the legs and the left and right cylinders (feet).

Figure 22.4. SoIntersectionDetectionAction (scene 2)


Example 22.2. How to use SoIntersectionDetectionAction