Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoCollisionManager Class Reference

VSG extension Class to manage collisions. More...

#include <Inventor/collision/SoCollisionManager.h>

Public Types

enum  Resp {
  NEXT_PRIMITIVE ,
  NEXT_SHAPE ,
  ABORT
}
 Types definitions. More...
 
enum  TransformChangeType {
  NONE ,
  TRANSLATION ,
  SCALE ,
  ROTATION ,
  ORIENTATION ,
  CENTER
}
 Transform change type. More...
 
enum  Axis {
  X_AXIS = 1 ,
  Y_AXIS = 2 ,
  Z_AXIS = 4
}
 Axis. More...
 
enum  Position {
  BEGIN ,
  END
}
 Postion. More...
 
typedef SbBool SoFilterCollisionCB(void *userData, const SoPath *p1, const SoPath *p2)
 
typedef void SoBBoxCollisionCB(void *userData, const SoPath *p1, const SoPath *p2)
 
typedef Resp SoCollisionCB(void *userData, const SoCollidingPrimitive *object, const SoCollidingPrimitive *scene)
 

Public Member Functions

 SoCollisionManager (SoPath *object, SoGroup *scene, SoTransform *transform)
 Constructor.
 
 ~SoCollisionManager ()
 Destructor.
 
void setObject (SoPath *object)
 Sets the object that will be transformed.
 
SoPathgetObject () const
 Returns the object that will be transformed.
 
void setScene (SoGroup *scene)
 Sets the scene the object is interacting with.
 
SoGroupgetScene () const
 Returns the scene the object is interacting with.
 
void setTransform (SoTransform *transform)
 Sets the transformation that will be watched.
 
SoTransformgetTransform () const
 Returns the transformation that will be watched.
 
void setGluingLevel (unsigned int level)
 Sets the gluing level.
 
unsigned int getGluingLevel () const
 Returns the gluing level.
 
void setObjectBBoxOnly (SbBool flag=TRUE)
 Sets a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.
 
SbBool isObjectBBoxOnly () const
 Returns a flag indicating whether to use the object's bounding box instead of the actual primitives when computing collisions.
 
void 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.
 
SbBool 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 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.
 
SbBool 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.
 
void 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.
 
SbBool isActivated () const
 Returns a flag indicating whether the collision manager is activated.
 
void setFilterCallback (SoFilterCollisionCB *f, void *userData=NULL)
 Sets the callback function called when an object shape collides with a scene shape.
 
void addBBoxCollisionCallback (SoBBoxCollisionCB *f, void *userData=NULL)
 Adds bounding box collision callback.
 
void removeBBoxCollisionCallback (SoBBoxCollisionCB *f, void *userData=NULL)
 Removes bounding box collision callback.
 
void addCollisionCallback (SoCollisionCB *f, void *userData=NULL)
 Adds collision callback.
 
void removeCollisionCallback (SoCollisionCB *f, void *userData=NULL)
 Removes collision callback.
 

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

Definition at line 137 of file SoCollisionManager.h.

Member Typedef Documentation

◆ SoBBoxCollisionCB

typedef void SoBBoxCollisionCB(void *userData, const SoPath *p1, const SoPath *p2)

Definition at line 64 of file SoCollisionManager.h.

◆ SoCollisionCB

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

Definition at line 157 of file SoCollisionManager.h.

◆ SoFilterCollisionCB

typedef SbBool SoFilterCollisionCB(void *userData, const SoPath *p1, const SoPath *p2)

Definition at line 56 of file SoCollisionManager.h.

Member Enumeration Documentation

◆ Axis

Axis.

Enumerator
X_AXIS 

X.

Y_AXIS 

Y.

Z_AXIS 

Z.

Definition at line 334 of file SoCollisionManager.h.

◆ Position

Postion.

Enumerator
BEGIN 

Begin.

END 

End.

Definition at line 344 of file SoCollisionManager.h.

◆ Resp

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.

Definition at line 144 of file SoCollisionManager.h.

◆ TransformChangeType

Transform change type.

Enumerator
NONE 

None.

TRANSLATION 

Translation.

SCALE 

Scale.

ROTATION 

Rotation.

ORIENTATION 

Orientation.

CENTER 

Center.

Definition at line 318 of file SoCollisionManager.h.

Constructor & Destructor Documentation

◆ SoCollisionManager()

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::~SoCollisionManager ( )

Destructor.

Member Function Documentation

◆ activate()

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.

◆ addBBoxCollisionCallback()

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.

◆ addCollisionCallback()

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.

◆ getGluingLevel()

unsigned int SoCollisionManager::getGluingLevel ( ) const

Returns the gluing level.

◆ getObject()

SoPath * SoCollisionManager::getObject ( ) const

Returns the object that will be transformed.

◆ getScene()

SoGroup * SoCollisionManager::getScene ( ) const

Returns the scene the object is interacting with.

◆ getTransform()

SoTransform * SoCollisionManager::getTransform ( ) const

Returns the transformation that will be watched.

◆ isActivated()

SbBool SoCollisionManager::isActivated ( ) const

Returns a flag indicating whether the collision manager is activated.

◆ isGluing()

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.

◆ isObjectBBoxOnly()

SbBool SoCollisionManager::isObjectBBoxOnly ( ) const

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

◆ isSceneBBoxOnly()

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.

◆ removeBBoxCollisionCallback()

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

Removes bounding box collision callback.

◆ removeCollisionCallback()

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

Removes collision callback.

◆ setFilterCallback()

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.

◆ setGluing()

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.

◆ setGluingLevel()

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.

◆ setObject()

void SoCollisionManager::setObject ( SoPath object)

Sets the object that will be transformed.

◆ setObjectBBoxOnly()

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.

◆ setScene()

void SoCollisionManager::setScene ( SoGroup scene)

Sets the scene the object is interacting with.

◆ setSceneBBoxOnly()

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.

◆ setTransform()

void SoCollisionManager::setTransform ( SoTransform transform)

Sets the transformation that will be watched.


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