SoCollisionShape Class Reference
[libipsa classesCollisionShape classes]

Defines the base class for Inventor CollisionShape objects. More...

#include <SoCollisionShape.h>

Inheritance diagram for SoCollisionShape:

Inheritance graph
[legend]

List of all members.

Public Types


Public Member Functions

virtual SoBaseKit * copy (SbBool copyConnections) const
dGeomID createGeom (const SbMatrix &mm)
void getCOG (SbVec3f &cog)
dGeomID getGeom ()
dSpaceID getSpace ()
SbBool getVisualisationStatus ()
void setSpace (dSpaceID spaceID)
SbBool setUpConnections (SbBool onOff, SbBool doItAlways=FALSE)
void setVisualisationStatus (SbBool onOff)
 SoCollisionShape (const SbString &nodeName="")
virtual void updateGeomPosition (const SbMatrix &mm)
void updateOIPosition ()
virtual ~SoCollisionShape ()

Static Public Member Functions

static void initClass ()
static SoCallbackAction::Response InitCollisionShapesCB (void *userdata, SoCallbackAction *action, const SoNode *node)

Public Attributes

SoSFEnum alignment
SoSFBool autoinitialise
SoSFUInt32 category
SoSFUInt32 collisionmask
SoSFEnum surfaceMaterial

Protected Member Functions

virtual dGeomID cGeom (const SbMatrix &mm)
virtual void updateVisualisationAndOdeProperties ()

Protected Attributes

SbVec3f COG
SbMatrix CoinRefTransform
dGeomID geometry
dSpaceID space
SoMatrixTransform * transform
SoFieldSensor updateOdePropertiesSensor
SoSFTrigger updateOdePropertiesTrigger

Private Member Functions

 SO_KIT_CATALOG_ENTRY_HEADER (visualisation)
 SO_KIT_CATALOG_ENTRY_HEADER (ODETransform)
 SO_KIT_CATALOG_ENTRY_HEADER (visDrawStyle)
 SO_KIT_CATALOG_ENTRY_HEADER (separator)
 SO_KIT_HEADER (SoCollisionShape)

Static Private Member Functions

static void UpdateVisualisationAndOdePropertiesCB (void *data, SoSensor *sensor)


Detailed Description

Defines the base class for Inventor CollisionShape objects.

Geometry objects (or ''geoms'' for short) are the fundamental objects in ODEs collision system and can represent a single rigid shape (such as a sphere or box).
Any geom can collide with any other geom which then yields zero or more contact points.
Normally the collision shape is invisible which can be changed by setting the SoCollisionShape::visDrawStyle member to FILLED in the Inventor file of by calling SoCollisionShape::setVisualisationStatus() with TRUE as parameter. This is usefull if a collision object is necessary which does not have to have any physical properties (like a ground plane for example).

See How to create a new IPSA collision shape for detailed instructions on how to create new IPSA collision shapes.

Definition at line 44 of file SoCollisionShape.h.


Member Enumeration Documentation

The different ways the collisionshape can be aligned with the corresponding body.

Enumerator:
STANDARD  Keep the collision shape in the same place as it is.
CENTERED  Align the collision shape with the center of gravity.

Definition at line 77 of file SoCollisionShape.h.

Enumeration for the different types of surface materials which are used to determine the friction between bodies.

Enumerator:
CLEAN 
GREASY 
WOOD 
GLASS 
STEEL 
RUBBER 
NO_OF_SURFACEMATERIALS 

Definition at line 85 of file SoCollisionShape.h.


Constructor & Destructor Documentation

SoCollisionShape::SoCollisionShape ( const SbString &  nodeName = ""  ) 

The constructor of SoCollisionShape.

Parameters:
nodeName name of the node in the Inventor scenegraph

Definition at line 330 of file SoCollisionShape.cpp.

References alignment, autoinitialise, category, CENTERED, CLEAN, collisionmask, GLASS, GREASY, RUBBER, STANDARD, STEEL, surfaceMaterial, transform, updateOdePropertiesSensor, UpdateVisualisationAndOdePropertiesCB(), and WOOD.

SoCollisionShape::~SoCollisionShape (  )  [virtual]

The virtual standard destructor of SoCollisionShape.

Definition at line 437 of file SoCollisionShape.cpp.

References geometry.


Member Function Documentation

dGeomID SoCollisionShape::cGeom ( const SbMatrix &  mm  )  [protected, virtual]

This method creates a box geom of the given 1/1/1 side lengths, and returns its ID. The point of reference for a box is its center.

Parameters:
mm the model matrix of the current node
Returns:
dGeomID: The dGeomID of the box geom.

Reimplemented in SoCollisionShapeBox, SoCollisionShapeCylinder, SoCollisionShapePlane, SoCollisionShapeSphere, and SoCollisionShapeTriMesh.

Definition at line 532 of file SoCollisionShape.cpp.

References space.

Referenced by createGeom().

SoBaseKit * SoCollisionShape::copy ( SbBool  copyConnections  )  const [virtual]

The overwritten copy() method

Parameters:
copyConnections copy connections if true

Reimplemented in SoCollisionShapeBox, SoCollisionShapeCylinder, SoCollisionShapePlane, SoCollisionShapeSphere, and SoCollisionShapeTriMesh.

Definition at line 386 of file SoCollisionShape.cpp.

References COG, CoinRefTransform, geometry, setUpConnections(), space, and transform.

dGeomID SoCollisionShape::createGeom ( const SbMatrix &  mm  ) 

On first time invoke: uses the method SoCollisionShape::cGeom() to initialise SoCollisionShape::geometry via ODE if it is NULL. The dGeomID is used to set the body and data on it, Category and Collisionmask are set. Upon all subsequent calls the ODE-geom is NOT reinitialized. Only SoCollisionShape::category and SoCollisionShape::collisionmask are set on SoCollisionShape::geometry. SoCollisionShape::updateVisualisationAndOdeProperties is called if SoCollisionShape::autoinitialise is set to TRUE.

Parameters:
mm the model matrix of the current node
Returns:
dGeomID: the ODE internal ID of the collision shape

Definition at line 485 of file SoCollisionShape.cpp.

References category, cGeom(), collisionmask, geometry, and updateVisualisationAndOdeProperties().

Referenced by InitCollisionShapesCB().

void SoCollisionShape::getCOG ( SbVec3f &  COM  ) 

Parameters:
COM the center of gravity vector is stored in this parameter.

Definition at line 570 of file SoCollisionShape.cpp.

References COG.

Referenced by SoPhysics::createOdeBody(), and SoPhysics::updateOdeBodyParameters().

dGeomID SoCollisionShape::getGeom (  ) 

Returns the dGeomID of the object.

Returns:
dGeomID: The dGeomID of the object.

Definition at line 465 of file SoCollisionShape.cpp.

References geometry.

Referenced by SoPhysics::createOdeBody().

SoCollisionShape::getSpace (  )  [inline]

Returns:
the dSpaceID the collision shape was created in.

Definition at line 68 of file SoCollisionShape.h.

SbBool SoCollisionShape::getVisualisationStatus (  ) 

Reads the visualisation status and returns it.

Returns:
true if visualisation is visible, false otherwise.

Definition at line 544 of file SoCollisionShape.cpp.

void SoCollisionShape::initClass (  )  [static]

Initialises the class and it's type id variables.

Reimplemented in SoCollisionShapeBox, SoCollisionShapeCylinder, SoCollisionShapePlane, SoCollisionShapeSphere, and SoCollisionShapeTriMesh.

Definition at line 291 of file SoCollisionShape.cpp.

SoCallbackAction::Response SoCollisionShape::InitCollisionShapesCB ( void *  userdata,
SoCallbackAction *  action,
const SoNode *  node 
) [static]

This method traverses the Inventor tree and creates the respective ODE-Geom for each SoCollisionShapes-Node. Additionally it calls SoCollisionShape::setUpConnections() on the instance which can not be done in the constructor since the method SoCollisionShape::setUpConnections() is virtual and can not be called safely inside the constructor.

Parameters:
userdata pointer to an SoWorldPhysics object
action used to get the model matrix of the current node
node node with supertype SoCollisionshape

Definition at line 308 of file SoCollisionShape.cpp.

References autoinitialise, createGeom(), SoWorldPhysics::ownspace, setSpace(), setUpConnections(), updateGeomPosition(), and updateVisualisationAndOdeProperties().

Referenced by SoWorldPhysics::initialiseWorld().

void SoCollisionShape::setSpace ( dSpaceID  spaceID  ) 

SoCollisionShape::setSpace(dSpaceID spaceID) Sets the dSpaceID the collision shape should be created in.

Todo:
Allow the collision shape to be moved between spaces???
Parameters:
spaceID the dSpaceID to set

Definition at line 509 of file SoCollisionShape.cpp.

References space.

Referenced by InitCollisionShapesCB().

SbBool SoCollisionShape::setUpConnections ( SbBool  onOff,
SbBool  doItAlways = FALSE 
)

Connects the updateOdePropertiesSensor with the updateOdePropertiesTrigger field depending on the parameter onOff.

Parameters:
onOff attach sensors if TRUE, detach sensors if FALSE
doItAlways always perform attach/detach of sensors if this parameter is TRUE
Returns:
SbBool

Definition at line 410 of file SoCollisionShape.cpp.

References updateOdePropertiesSensor, updateOdePropertiesTrigger, and UpdateVisualisationAndOdePropertiesCB().

Referenced by SoCollisionShapeTriMesh::copy(), SoCollisionShapeSphere::copy(), SoCollisionShapePlane::copy(), SoCollisionShapeCylinder::copy(), SoCollisionShapeBox::copy(), copy(), and InitCollisionShapesCB().

void SoCollisionShape::setVisualisationStatus ( SbBool  onOff  ) 

Sets the visibility of the visualisation.

Parameters:
onOff enables the visualisation if true, disables it otherwise.

Definition at line 558 of file SoCollisionShape.cpp.

Referenced by SoPhysics::createOdeBody(), and SoPhysics::FieldChangedCB().

SoCollisionShape::SO_KIT_CATALOG_ENTRY_HEADER ( visualisation   )  [private]

SoCollisionShape::SO_KIT_CATALOG_ENTRY_HEADER ( ODETransform   )  [private]

SoCollisionShape::SO_KIT_CATALOG_ENTRY_HEADER ( visDrawStyle   )  [private]

SoCollisionShape::SO_KIT_CATALOG_ENTRY_HEADER ( separator   )  [private]

SoCollisionShape::SO_KIT_HEADER ( SoCollisionShape   )  [private]

void SoCollisionShape::updateGeomPosition ( const SbMatrix &  mm  )  [virtual]

This function sets the ODE transformation from the open inventor transformation and aligns the Inventor visualisation with ODE. It is used for static collisionshapes (geoms without bodies) only.

Parameters:
mm The open inventor transformation matrix.

Reimplemented in SoCollisionShapePlane.

Definition at line 598 of file SoCollisionShape.cpp.

References alignment, CENTERED, COG, CoinRefTransform, geometry, and STANDARD.

Referenced by InitCollisionShapesCB().

void SoCollisionShape::updateOIPosition (  ) 

This function sets the open inventor position. It may be overridden for derived classed.

Definition at line 636 of file SoCollisionShape.cpp.

References CoinRefTransform, geometry, and transform.

void SoCollisionShape::updateVisualisationAndOdeProperties (  )  [protected, virtual]

Updates the default visualisation shape of the collsionshape and creates it if it isn't present. There are no properties which need to be updated

Reimplemented in SoCollisionShapeBox, SoCollisionShapeCylinder, SoCollisionShapePlane, SoCollisionShapeSphere, and SoCollisionShapeTriMesh.

Definition at line 450 of file SoCollisionShape.cpp.

Referenced by createGeom(), InitCollisionShapesCB(), and UpdateVisualisationAndOdePropertiesCB().

void SoCollisionShape::UpdateVisualisationAndOdePropertiesCB ( void *  data,
SoSensor *  sensor 
) [static, private]

This method is called whenever a size property of the collisionshape changes. It sets the new values on the dependent visualisation shape by calling updateVisualisationAndOdeProperties() on the passed in data object.

Parameters:
data void pointer to an SoPhysics object on which updateDependentObjects is called
sensor currently unused

Definition at line 582 of file SoCollisionShape.cpp.

References updateVisualisationAndOdeProperties().

Referenced by setUpConnections(), and SoCollisionShape().


Member Data Documentation

Alignment of current SoCollisionShape (default = SoCollisionShape::STANDARD).

Definition at line 83 of file SoCollisionShape.h.

Referenced by SoCollisionShape(), updateGeomPosition(), and SoPhysics::updateOdeBodyParameters().

Current collision category. This is used in ODE to distinguish different object categories for collision.

Definition at line 98 of file SoCollisionShape.h.

Referenced by createGeom(), and SoCollisionShape().

SoCollisionShape::COG [protected]

The center of gravity (cog) of the collision shape (default = { 0.0f, 0.0f, 0.0f}).

Definition at line 112 of file SoCollisionShape.h.

Referenced by SoCollisionShapeTriMesh::cGeom(), copy(), getCOG(), and updateGeomPosition().

Definition at line 109 of file SoCollisionShape.h.

Referenced by copy(), updateGeomPosition(), and updateOIPosition().

Collisionmask used by the ODE engine.

Definition at line 99 of file SoCollisionShape.h.

Referenced by createGeom(), and SoCollisionShape().

dGeomID SoCollisionShape::geometry [protected]

Current surface material for the SoCollisionShape (default = SoCollisionShape::GREASY).

Definition at line 96 of file SoCollisionShape.h.

Referenced by SoWorldPhysics::NearCallback(), and SoCollisionShape().

This sensor is attached to SoCollisionShape::updateOdePropertiesTrigger and calls SoCollsisionShape::UpdateVisualisationAndOdePropertiesCB() when the field changes.

Definition at line 107 of file SoCollisionShape.h.

Referenced by setUpConnections(), and SoCollisionShape().

The SoCollisionShape::updateOdePropertiesSensor is attached to this field to automatically update the ODE propertries and the visualisation shape if any object property changes. To make a property field property1 trigger an update of the visualisation shape use the following code in the constructor:

 updateOdePropertiesTrigger.appendConnection(&property1); 

Definition at line 106 of file SoCollisionShape.h.

Referenced by setUpConnections(), SoCollisionShapeBox::SoCollisionShapeBox(), SoCollisionShapeCylinder::SoCollisionShapeCylinder(), SoCollisionShapePlane::SoCollisionShapePlane(), SoCollisionShapeSphere::SoCollisionShapeSphere(), and SoCollisionShapeTriMesh::SoCollisionShapeTriMesh().


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

Get IPSA - Inventor Physics Simulation API at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated on Sat Mar 10 20:00:20 2012 for IPSA by  doxygen 1.5.8