Class SoCollisionManager
SoCollisionManager class 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAxis.static interfaceBounding box collision callbacks are called after the bounding box collision detection and before real detection, allowing the programmer to change thestatic classVertices array can contains 2 or 3 elements whether primitive is a segment or a triangle.static interfaceCollision callbacks are called when there is a collision.static interfaceFilter callback is called when an object shape collides with a scene shape.static enumPostion.static enumTypes definitions.static enumTransform 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
ConstructorsConstructorDescriptionSoCollisionManager(SoPath object, SoGroup scene, SoTransform transform) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()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.voidAdds bounding box collision callback.voidAdds collision callback.intReturns the gluing level.Returns the object that will be transformed.getScene()Returns the scene the object is interacting with.Returns the transformation that will be watched.booleanReturns 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.booleanReturns a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.booleanReturns a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions.voidRemoves bounding box collision callback.voidRemoves collision callback.voidSets the Filter callback function called when an object shape collides with a scene shape.voidCalls 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.voidSets the object that will be transformed.voidCalls 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.voidSets the scene the object is interacting with.voidCalls 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 Details
-
SoCollisionManager
Constructor. The specified scene must be the head of the path to the specified object.
-
-
Method Details
-
setFilter
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
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
Removes bounding box collision callback. -
addCollisionListener
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
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
Sets the scene the object is interacting with. -
getScene
Returns the scene the object is interacting with. -
setTransform
Sets the transformation that will be watched. -
setObject
Sets the object that will be transformed. -
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
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.
-