Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Intersection Detection Action

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 for more information.

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

Intersections are detected between all the parts of the scene.<br/>SoIntersectionDetectionAction (scene 1)

After the legs of the jumping man are moved, there is no intersection between the legs and the left and right cylinders (feet).<br/>SoIntersectionDetectionAction (scene 2)

Example : How to use SoIntersectionDetectionAction This code can be used to analyze a scene graph to determine which pairs of objects within the scene intersect. See SoIntersectionDetectionAction (scene 1) and SoIntersectionDetectionAction (scene 2).

Source code from: $OIVHOME/src/Inventor/examples/Features/Collision/Intersections/Intersections.cxx

C++ :

//---------------------------------------------------------------------
// This callback is called when the action is started.
SoIntersectionDetectionAction::Resp
onIntersection( void* userData, const SoIntersectingPrimitive* primitive1, const SoIntersectingPrimitive* primitive2 )
{
// These two primitive have an intersection.
printf( "%d %s (%s) *** %s (%s)\n",
intersectionCount,
( char* )primitive1->path->getTail()->getName().getString(),
( char* )primitive1->path->getTail()->getTypeId().getName().getString(),
( char* )primitive2->path->getTail()->getName().getString(),
( char* )primitive2->path->getTail()->getTypeId().getName().getString() );
intersectionCount++;
// This callback will be called for the two next colliding shapes
return SoIntersectionDetectionAction::NEXT_SHAPE;
}
//---------------------------------------------------------------------
void
functionToActivateTheIntersectionCallback()
{
intersectionCount = 0;
SoIntersectionDetectionAction action;
action.addIntersectionCallback( onIntersection, NULL );
action.apply( root );
}

C# :

Java :