public class SoDualSceneCollider extends Inventor
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,
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:
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.
Inventor.ConstructorCommand
VERBOSE_LEVEL, ZeroHandle
Modifier and Type | Method and Description |
---|---|
void |
activate(SoTransform transform)
Specifies the transformation that will be watched.
|
void |
enableMultiThread(boolean enable)
Use multiple threads to compute intersections.
|
double |
getMinEdgeLength()
Returns the minimum length of a triangle edge.
|
boolean |
isMultiThreadEnabled()
Returns true if multithreaded computation is enabled.
|
void |
setMinEdgeLength(double minEdgeLength)
Specifies the minimum length of a triangle edge.
|
void |
setMovingScene(SoPath object)
Calls setMovingScene(object, (int)0).
|
void |
setMovingScene(SoPath object,
int max_triangles_per_leaf)
Specifies the scene that will be moved or transformed.
|
void |
setStaticScene(SoPath scene)
Calls setStaticScene(scene, (int)0).
|
void |
setStaticScene(SoPath scene,
int max_triangles_per_leaf)
Specifies the scene the moving scene is interacting with.
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public void setStaticScene(SoPath scene)
public void setMovingScene(SoPath object)
public double getMinEdgeLength()
setMinEdgeLength()
public void enableMultiThread(boolean enable)
IMPORTANT: When multithreaded computation is enabled, the searchNextIntersection(), is not necessarily called from the main thread. Therefore the code in searchNextIntersection() (and any methods called from it) must be thread-safe. As an example, GUI update calls outside the main thread are often not allowed.
Default is false.
public boolean isMultiThreadEnabled()
public void setMinEdgeLength(double minEdgeLength)
minEdgeLength
- if < 0, no edges are checked and all triangles of the scene are registered. Default value is 1E-8.public void activate(SoTransform transform)
public void setMovingScene(SoPath object, int max_triangles_per_leaf)
public void setStaticScene(SoPath scene, int max_triangles_per_leaf)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com