SoDualSceneCollider Class 
Class to check for collisions between two scenes.
Namespace: OIV.Inventor.Collision
The SoDualSceneCollider type exposes the following members.
Name  Description  

SoDualSceneCollider 
Constructor

Name  Description  

Activate  Specifies the transformation that will be watched.  
CheckCollision 
Checks if the current moving scene collides with the static scene.
This method is automatically called when the transform node
given to Activate() is updated (or touched).
Returns true if the two scenes collide, false otherwise.
 
EnableMultiThread  Use multiple threads to compute intersections.  
Equals  (Inherited from Object.)  
GetHashCode 
Overrides GetHashCode().
(Inherited from SoNetBase.)  
GetMinEdgeLength  Returns the minimum length of a triangle edge.  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
IsMultiThreadEnabled  Returns true if multithreaded computation is enabled.  
SearchNextIntersection 
Method called by CheckCollision() for each pair of intersecting
triangles found. The method returns false by default
and may be overridden.
 
SetMinEdgeLength  Specifies the minimum length of a triangle edge.  
SetMovingScene(SoPath)  Calls SetMovingScene(object, System.Int32(0)).  
SetMovingScene(SoPath, Int32)  Specifies the scene that will be moved or transformed.  
SetStaticScene(SoPath)  Calls SetStaticScene(scene, System.Int32(0)).  
SetStaticScene(SoPath, Int32)  Specifies the scene the moving scene is interacting with.  
ToString  Returns a string that represents the current object. (Inherited from Object.) 
The SoDualSceneCollider class manages collisions, i.e., it checks the intersection of one scene with a second scene. Both scenes are tessellated into a list of triangles by using an SoCallbackAction and its addTriangleCallback method. An intersection occurs when a triangle of the first scene intersects a triangle of the second scene. For each pair of intersecting triangles some response methods are called. These response methods can be overridden, for instance,
to highlight the intersecting shape
to highlight the intersecting pair of triangles
to compute points common to the two scenes
to count the number of intersecting pairs of triangles
etc.
The SoDualSceneCollider references a static scene and a moving scene (with two SoPaths) and a transformation (with an SoTransform). The user scene graph must be organized such that the transformation will affect the moving scene during traversal. The static scene is specified by the method setStaticScene and the moving scene by the method setMovingScene.
The SoDualSceneCollider references a scene by storing its triangle list (see SoCallbackAction) and by building a database as a tree. This database spatially organizes the list of triangles in order to optimize the number of triangle intersection tests. Note that the SoDualSceneCollider does not monitor the scene graph. Any modifications to the Open Inventor nodes in the static scene or the moving scene are not reflected in the internal tree database unless setMovingScene or setStaticScene are called again by the application.
However SoDualSceneCollider watches for any modification to the given transformation. Each time the transformation changes, an intersection test is done between the two scenes by automatically calling checkCollision(). This method searches for pairs of intersecting triangles in an optimal way. For each pair of intersecting triangles found, the Boolean method searchNextIntersection() is called. By default this method returns false, but in most cases, it will be overridden. If it returns false, the process of searching intersecting triangles is stopped and checkCollision() returns true. If searchNextIntersection returns true, the process continues to search other pairs of intersecting triangles. If searchNextIntersection always returns true, all pairs of intersecting triangles will be found. If the two scenes do not collide, searchNextIntersection is never called and checkCollision returns false. When searchNextIntersection is overridden, some methods can be called to get information about the current pair of intersecting triangles: getCollidingStaticPath(), getCollidingStaticTriangle(), getCollidingMovingPath(), getCollidingMovingTriangle(), and getCommonPoints().
In the static or moving scene, each internal node of the tree contains a bounding box while the leaf nodes contain triangles of the tessellation. The maximum number of triangles per leaf (max_triangles_per_leaf) is given as the second argument of the method setMovingScene and setStaticScene. Note how max_triangles_per_leaf affects the computation:
the smaller max_triangles_per_leaf, the deeper the tree.
the smaller max_triangles_per_leaf, the more memory the tree needs
the smaller max_triangles_per_leaf, the quicker the checkCollision() function becomes
the smaller max_triangles_per_leaf, the slower the setMovingScene/setStaticScene() functions become
A compromise must be chosen between the initial time to build the tree (setMovingScene/setStaticScene) and the time to check the collisions.
Depending on the total number of triangles and the value of max_triangles_per_leaf, the execution of setMovingScene/setStaticScene can take several seconds. The methods staticTriangleListBuilt/movingTriangleListBuilt and staticLeafBuilt/movingLeafBuilt have been defined and can be overridden to implement, for instance, a progress bar. However, note that the methods staticLeafBuilt/movingLeafBuilt are not called in linear time.
Collision checking will be faster using multiple threads. See the enableMultiThread() method.