Click or drag to resize
SoDualSceneCollider Class

Class to check for collisions between two scenes.

Inheritance Hierarchy
SystemObject
  OIV.InventorSoNetBase
    OIV.Inventor.CollisionSoDualSceneCollider

Namespace: OIV.Inventor.Collision
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.2.2.0 (10.16.2.0)
Syntax
public class SoDualSceneCollider : SoNetBase

The SoDualSceneCollider type exposes the following members.

Constructors
  NameDescription
Public methodSoDualSceneCollider

Default constructor.

Top
Methods
  NameDescription
Public methodActivate

Specifies the transformation that will be watched.

Public methodCheckCollision

Checks if the current moving scene collides with the static scene.

Public methodEnableMultiThread

Use multiple threads to compute intersections.

Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMinEdgeLength

Returns the minimum length of a triangle edge.

Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsMultiThreadEnabled

Returns true if multithreaded computation is enabled.

Public methodSearchNextIntersection

Method called by OIV.Inventor.Collision.SoDualSceneCollider.CheckCollision() for each pair of intersecting triangles found.

Public methodSetMinEdgeLength

Specifies the minimum length of a triangle edge.

Public methodSetMovingScene(SoPath)
Calls SetMovingScene(object, System.Int32(0)).
Public methodSetMovingScene(SoPath, Int32)

Specifies the scene that will be moved or transformed.

Public methodSetStaticScene(SoPath)
Calls SetStaticScene(scene, System.Int32(0)).
Public methodSetStaticScene(SoPath, Int32)

Specifies the scene the moving scene is interacting with.

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

The OIV.Inventor.Collision.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 OIV.Inventor.Actions.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 OIV.Inventor.Collision.SoDualSceneCollider references a static scene and a moving scene (with two SoPaths) and a transformation (with an OIV.Inventor.Nodes.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 OIV.Inventor.Collision.SoDualSceneCollider.SetStaticScene(OIV.Inventor.SoPath, System.Int32) and the moving scene by the method OIV.Inventor.Collision.SoDualSceneCollider.SetMovingScene(OIV.Inventor.SoPath, System.Int32).

The OIV.Inventor.Collision.SoDualSceneCollider references a scene by storing its triangle list (see OIV.Inventor.Actions.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 OIV.Inventor.Collision.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 OIV.Inventor.Collision.SoDualSceneCollider.SetMovingScene(OIV.Inventor.SoPath, System.Int32) or OIV.Inventor.Collision.SoDualSceneCollider.SetStaticScene(OIV.Inventor.SoPath, System.Int32) are called again by the application.

However OIV.Inventor.Collision.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 OIV.Inventor.Collision.SoDualSceneCollider.CheckCollision(). This method searches for pairs of intersecting triangles in an optimal way. For each pair of intersecting triangles found, the Boolean method OIV.Inventor.Collision.SoDualSceneCollider.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 OIV.Inventor.Collision.SoDualSceneCollider.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 OIV.Inventor.Collision.SoDualSceneCollider.CheckCollision() function becomes

  • the smaller max_triangles_per_leaf, the slower the OIV.Inventor.Collision.SoDualSceneCollider.SetMovingScene(OIV.Inventor.SoPath, System.Int32)/OIV.Inventor.Collision.SoDualSceneCollider.SetStaticScene(OIV.Inventor.SoPath, System.Int32) 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 OIV.Inventor.Collision.SoDualSceneCollider.EnableMultiThread(System.Boolean) method.

See Also