SoCollisionManager Class Reference
[Collision]

VSG extension Class to manage collisions. More...

#include <Inventor/collision/SoCollisionManager.h>

List of all members.

Public Types

enum  Resp {
  NEXT_PRIMITIVE,
  NEXT_SHAPE,
  ABORT
}
enum  TransformChangeType {
  NONE,
  TRANSLATION,
  SCALE,
  ROTATION,
  ORIENTATION,
  CENTER
}
enum  Axis {
  X_AXIS = 1,
  Y_AXIS = 2,
  Z_AXIS = 4
}
enum  Position {
  BEGIN,
  END
}
typedef Resp SoCollisionCB (void *userData, const SoCollidingPrimitive *object, const SoCollidingPrimitive *scene)

Public Member Functions

 SoCollisionManager (SoPath *object, SoGroup *scene, SoTransform *transform)
 ~SoCollisionManager ()
void setObject (SoPath *object)
SoPathgetObject () const
void setScene (SoGroup *scene)
SoGroupgetScene () const
void setTransform (SoTransform *transform)
SoTransformgetTransform () const
void setGluingLevel (unsigned int level)
unsigned int getGluingLevel () const
void setObjectBBoxOnly (SbBool flag=TRUE)
SbBool isObjectBBoxOnly () const
void setSceneBBoxOnly (SbBool flag=TRUE)
SbBool isSceneBBoxOnly () const
void setGluing (SbBool flag=TRUE)
SbBool isGluing () const
void activate (SbBool flag=TRUE)
SbBool isActivated () const
void setFilterCallback (SoFilterCollisionCB *f, void *userData=NULL)
void addBBoxCollisionCallback (SoBBoxCollisionCB *f, void *userData=NULL)
void removeBBoxCollisionCallback (SoBBoxCollisionCB *f, void *userData=NULL)
void addCollisionCallback (SoCollisionCB *f, void *userData=NULL)
void removeCollisionCallback (SoCollisionCB *f, void *userData=NULL)

Detailed Description

VSG extension Class to manage collisions.

The 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

SoIntersectionDetectionAction, SoWinCollisionViewer

See related examples:

CollisionViewer, Dart, ObjectMoving


Member Typedef Documentation

typedef Resp SoCollisionManager::SoCollisionCB(void *userData, const SoCollidingPrimitive *object, const SoCollidingPrimitive *scene)

Member Enumeration Documentation

Axis.

Enumerator:
X_AXIS 

X.

Y_AXIS 

Y.

Z_AXIS 

Z.

Postion.

Enumerator:
BEGIN 

Begin.

END 

End.

Types definitions.

Enumerator:
NEXT_PRIMITIVE 

Continue and call again for next colliding primitive.

NEXT_SHAPE 

Continue and call again for next colliding shape.

ABORT 

Do not continue.

Transform change type.

Enumerator:
NONE 

None.

TRANSLATION 

Translation.

SCALE 

Scale.

ROTATION 

Rotation.

ORIENTATION 

Orientation.

CENTER 

Center.


Constructor & Destructor Documentation

SoCollisionManager::SoCollisionManager ( SoPath object,
SoGroup scene,
SoTransform transform 
)

Constructor.

The specified scene must be the head of the path to the specified object.

SoCollisionManager::~SoCollisionManager (  ) 

Destructor.


Member Function Documentation

void SoCollisionManager::activate ( SbBool  flag = TRUE  ) 

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.

void SoCollisionManager::addBBoxCollisionCallback ( SoBBoxCollisionCB f,
void *  userData = NULL 
)

Adds bounding box collision callback.

Bounding box collision callbacks are called after the bounding box collision detection and before real detection, allowing the programmer to change the ObjectBBoxOnly and SceneBBoxOnly flags. The callback functions are passed the paths of the two nodes whose bounding boxes are colliding.

void SoCollisionManager::addCollisionCallback ( SoCollisionCB f,
void *  userData = NULL 
)

Adds collision callback.

Collision callbacks are called when there is a collision. The callback functions receive information about the primitives which collide. If the callback returns NEXT_PRIMITIVE, it will be called for the two next colliding triangles or segments; if it returns NEXT_SHAPE, it will be called for the two next colliding shapes; if it returns ABORT, it will be called only if another transformation generates a collision.

When the gluing flag is TRUE, the object and scene passed to the callback function are NULL because there is no collision.

unsigned int SoCollisionManager::getGluingLevel (  )  const

Returns the gluing level.

SoPath* SoCollisionManager::getObject (  )  const

Returns the object that will be transformed.

SoGroup* SoCollisionManager::getScene (  )  const

Returns the scene the object is interacting with.

SoTransform* SoCollisionManager::getTransform (  )  const

Returns the transformation that will be watched.

SbBool SoCollisionManager::isActivated (  )  const

Returns a flag indicating whether the collision manager is activated.

SbBool SoCollisionManager::isGluing (  )  const

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.

SbBool SoCollisionManager::isObjectBBoxOnly (  )  const

Returns a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.

SbBool SoCollisionManager::isSceneBBoxOnly (  )  const

Returns a flag indicating whether to use the bounding boxes of objects in the scene instead of the actual primitives when computing collisions.

void SoCollisionManager::removeBBoxCollisionCallback ( SoBBoxCollisionCB f,
void *  userData = NULL 
)

Removes bounding box collision callback.

void SoCollisionManager::removeCollisionCallback ( SoCollisionCB f,
void *  userData = NULL 
)

Removes collision callback.

void SoCollisionManager::setFilterCallback ( SoFilterCollisionCB f,
void *  userData = NULL 
)

Sets the 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.

void SoCollisionManager::setGluing ( SbBool  flag = TRUE  ) 

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.

void SoCollisionManager::setGluingLevel ( unsigned 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.

void SoCollisionManager::setObject ( SoPath object  ) 

Sets the object that will be transformed.

void SoCollisionManager::setObjectBBoxOnly ( SbBool  flag = TRUE  ) 

Sets a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.

Default value is FALSE.

void SoCollisionManager::setScene ( SoGroup scene  ) 

Sets the scene the object is interacting with.

void SoCollisionManager::setSceneBBoxOnly ( SbBool  flag = TRUE  ) 

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.

void SoCollisionManager::setTransform ( SoTransform transform  ) 

Sets the transformation that will be watched.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/