Class SoCollisionManager
- java.lang.Object
 - 
- com.openinventor.inventor.Inventor
 - 
- com.openinventor.inventor.collision.SoCollisionManager
 
 
 
- 
public class SoCollisionManager extends Inventor
Class to manage collisions. TheSoCollisionManagerclass manages collisions, i.e., it controls the position of an object in a scene, preventing it from colliding with other objects in the scene.The collision manager references a scene, an object and a transformation. It can prevent collisions between the specified object and other objects within the scene.
It can use the actual primitives of the objects during the computation, or for faster performance, it may use their bounding boxes.
When the referenced transformation changes, the collision manager looks for a collision between the bounding box of the object and the bounding boxes of objects within the scene. If a collision between the bounding boxes is detected, the algorithm can (depending on what the programmer specifies) compute a more precise intersection using the actual primitives of the object and/or the objects of the scene.
The algorithm can call programmer-supplied callbacks when there is a collision between the bounding boxes, and when there is a collision between the primitives of the shapes.
When there is a collision, the collision manager can "glue" the object on the scene. This refers to placing the object at the position just before the first collision that would occur along the transformation path. For example, if an object would collide with (intersect) a wall, the object would be placed directly against the wall.
- See Also:
 SoIntersectionDetectionAction,SoWinCollisionViewer
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSoCollisionManager.AxisAxis.static interfaceSoCollisionManager.BBoxCollisionListenerBounding box collision callbacks are called after the bounding box collision detection and before real detection, allowing the programmer to change thestatic classSoCollisionManager.CollidingPrimitiveVertices array can contains 2 or 3 elements whether primitive is a segment or a triangle.static interfaceSoCollisionManager.CollisionListenerCollision callbacks are called when there is a collision.static interfaceSoCollisionManager.FilterFilter callback is called when an object shape collides with a scene shape.static classSoCollisionManager.PositionsPostion.static classSoCollisionManager.RespsTypes definitions.static classSoCollisionManager.TransformChangeTypesTransform change type.- 
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand 
 - 
 
- 
Field Summary
- 
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle 
 - 
 
- 
Constructor Summary
Constructors Constructor Description SoCollisionManager(SoPath object, SoGroup scene, SoTransform transform)Constructor. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Calls activate(true).voidactivate(boolean flag)Sets a flag to activate the collision manager, for instance, to tell it to watch the transformation and start collision detection computations when the transformation changes.voidaddBBoxCollisionListener(SoCollisionManager.BBoxCollisionListener listener)Adds bounding box collision callback.voidaddCollisionListener(SoCollisionManager.CollisionListener listener)Adds collision callback.intgetGluingLevel()Returns the gluing level.SoPathgetObject()Returns the object that will be transformed.SoGroupgetScene()Returns the scene the object is interacting with.SoTransformgetTransform()Returns the transformation that will be watched.booleanisActivated()Returns a flag indicating whether the collision manager is activated.booleanisGluing()Returns a flag indicating whether the collision manager should place the object at the position just before the first collision that would occur along the transformation path.booleanisObjectBBoxOnly()Returns a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.booleanisSceneBBoxOnly()Returns a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions.voidremoveBBoxCollisionListener(SoCollisionManager.BBoxCollisionListener listener)Removes bounding box collision callback.voidremoveCollisionListener(SoCollisionManager.CollisionListener listener)Removes collision callback.voidsetFilter(SoCollisionManager.Filter f)Sets the Filter callback function called when an object shape collides with a scene shape.voidsetGluing()Calls setGluing(true).voidsetGluing(boolean flag)Sets a flag indicating that the collision manager should place the object at the position just before the first collision that would occur along the transformation path.voidsetGluingLevel(int level)Sets the gluing level.voidsetObject(SoPath object)Sets the object that will be transformed.voidsetObjectBBoxOnly()Calls setObjectBBoxOnly(true).voidsetObjectBBoxOnly(boolean flag)Sets a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.voidsetScene(SoGroup scene)Sets the scene the object is interacting with.voidsetSceneBBoxOnly()Calls setSceneBBoxOnly(true).voidsetSceneBBoxOnly(boolean flag)Sets a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions.voidsetTransform(SoTransform transform)Sets the transformation that will be watched.- 
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
SoCollisionManager
public SoCollisionManager(SoPath object, SoGroup scene, SoTransform transform)
Constructor. The specified scene must be the head of the path to the specified object. 
 - 
 
- 
Method Detail
- 
setFilter
public void setFilter(SoCollisionManager.Filter f)
Sets the Filter callback function called when an object shape collides with a scene shape. If the callback function returns TRUE, the Collision Manager looks forward for collisions; else, it aborts searching. If it is NULL, no filter is applied.Warning: This callback is not fully compliant with OSGi applications. It may crash in an OSGi environment, in that case we suggest to use
SoDualSceneColliderinstead. 
- 
addBBoxCollisionListener
public void addBBoxCollisionListener(SoCollisionManager.BBoxCollisionListener listener)
Adds bounding box collision callback.Warning: This callback is not fully compliant with OSGi applications. It may crash in an OSGi environment, in that case we suggest to use
SoDualSceneColliderinstead. 
- 
removeBBoxCollisionListener
public void removeBBoxCollisionListener(SoCollisionManager.BBoxCollisionListener listener)
Removes bounding box collision callback. 
- 
addCollisionListener
public void addCollisionListener(SoCollisionManager.CollisionListener listener)
Adds collision callback.Warning: This callback is not fully compliant with OSGi applications. It may crash in an OSGi environment, in that case we suggest to use
SoDualSceneColliderinstead. 
- 
removeCollisionListener
public void removeCollisionListener(SoCollisionManager.CollisionListener listener)
Removes collision callback. 
- 
setSceneBBoxOnly
public void setSceneBBoxOnly()
Calls setSceneBBoxOnly(true). 
- 
setObjectBBoxOnly
public void setObjectBBoxOnly()
Calls setObjectBBoxOnly(true). 
- 
activate
public void activate()
Calls activate(true). 
- 
setGluing
public void setGluing()
Calls setGluing(true). 
- 
setScene
public void setScene(SoGroup scene)
Sets the scene the object is interacting with. 
- 
getScene
public SoGroup getScene()
Returns the scene the object is interacting with. 
- 
setTransform
public void setTransform(SoTransform transform)
Sets the transformation that will be watched. 
- 
setObject
public void setObject(SoPath object)
Sets the object that will be transformed. 
- 
getObject
public SoPath getObject()
Returns the object that will be transformed. 
- 
setGluing
public void setGluing(boolean flag)
Sets a flag indicating that the collision manager should place the object at the position just before the first collision that would occur along the transformation path. For example, if an object would collide with (intersect) a wall, the object would be placed directly against the wall. Default value is false. 
- 
isSceneBBoxOnly
public boolean isSceneBBoxOnly()
Returns a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions. 
- 
isGluing
public boolean isGluing()
Returns a flag indicating whether the collision manager should place the object at the position just before the first collision that would occur along the transformation path. 
- 
isActivated
public boolean isActivated()
Returns a flag indicating whether the collision manager is activated. 
- 
activate
public void activate(boolean flag)
Sets a flag to activate the collision manager, for instance, to tell it to watch the transformation and start collision detection computations when the transformation changes. Default value is true. 
- 
setSceneBBoxOnly
public void setSceneBBoxOnly(boolean flag)
Sets a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions. Default value is false. 
- 
setGluingLevel
public void setGluingLevel(int level)
Sets the gluing level. The larger the number, the more precise the check for intermediate collisions, and the longer the computation will take. If this level is set to 0, the collision manager will act as if the gluing flag was set to false, except the collision callbacks are called with a gluing flag of true. Default value is 1. 
- 
getTransform
public SoTransform getTransform()
Returns the transformation that will be watched. 
- 
getGluingLevel
public int getGluingLevel()
Returns the gluing level. 
- 
isObjectBBoxOnly
public boolean isObjectBBoxOnly()
Returns a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions. 
- 
setObjectBBoxOnly
public void setObjectBBoxOnly(boolean flag)
Sets a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions. Default value is false. 
 - 
 
 -