artisynth.core.mechmodels
Class CollisionManager

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.CompositeComponentBase
          extended by artisynth.core.modelbase.RenderableCompositeBase
              extended by artisynth.core.mechmodels.CollisionManager
All Implemented Interfaces:
ComponentChangeListener, CompositeComponent, IndexedComponentList, ModelComponent, RenderableComponent, ScalableUnits, java.lang.Cloneable, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Scannable

public class CollisionManager
extends RenderableCompositeBase
implements ScalableUnits

A special component the manages collisions between collidable bodies.


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.CompositeComponent
CompositeComponent.NavpanelDisplay
 
Field Summary
static boolean DEFAULT_USE_NEW_HANDLER
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
CollisionManager()
           
 
Method Summary
 void addAuxStateComponents(java.util.List<HasAuxState> comps)
           
 void addCollisionOverride(CollidablePair pair, CollisionBehavior behavior)
          Adds a CollisionComponent to override the primary collision behavior for a specific pair of components.
 void clear()
           
 void clearCachedData()
           
 void clearCollisionOverrides()
          Removes all collision overrides, so that the collision behavior between all components will revert back to their primary behavior.
 ComponentList<CollisionComponent> collisionComponents()
           
 CollisionHandlerList collisionHandlers()
          If necessary, rebuilds the collison pair list from the specified contact info.
 void componentChanged(ComponentChangeEvent e)
          Notifies this composite component that a change has occured within one or more of its descendants.
 RenderProps createRenderProps()
          Factory method to create render properties appropriate to this object.
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
 double getCollisionAccel()
           
 double getCollisionArenaRadius()
           
 CollisionBehavior getCollisionBehavior(Collidable a, Collidable b)
          Returns the collision behavior for a specified pair of collidables.
 double getCollisionCompliance()
           
 double getCollisionDamping()
           
 CollisionComponent getCollisionOverride(Collidable a, Collidable b)
          Returns the CollisionCompenent in this model associated with a particular collision override.
 CollisionComponent getCollisionOverride(CollidablePair pair)
          Returns the CollisionCompenent in this model associated with a particular collision override.
 double getCollisionPointTol()
           
 double getCollisionRegionTol()
           
 void getConstrainers(java.util.List<Constrainer> constrainers)
           
 double getContactNormalLen()
           
 CollisionBehavior getDefaultCollisionBehavior(Collidable typeA, Collidable typeB)
          Gets the default collision behavior, for a specified pair of generic collidable types.
static double getDefaultPenetrationTol(ModelComponent comp, double defaultTol)
           
 double getPenetrationTol()
           
 PropertyMode getPenetrationTolMode()
           
 CollisionBehavior getPrimaryCollisionBehavior(CollidablePair pair)
          Returns the primary collision behavior for a specified component pair as seen by this model.
 boolean getUseNewHandler()
           
 void initialize()
           
 boolean isDrawIntersectionContours()
           
 boolean isDrawIntersectionFaces()
           
 boolean isDrawIntersectionPoints()
           
 void prerender(RenderList list)
          Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.
 boolean removeCollisionOverride(CollisionComponent comp)
          Removes a CollisionComponent, removing the collision override for the associated pair of components.
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
 void scaleDistance(double s)
          Scales all distance coordinates.
 void scaleMass(double s)
          Scales all mass units.
 void setCollisionAccel(double acc)
           
 void setCollisionArenaRadius(double rad)
           
 void setCollisionBehavior(Collidable a, Collidable b, boolean enabled)
           
 void setCollisionBehavior(Collidable a, Collidable b, boolean enabled, double mu)
          Sets collision behavior for a specified pair of Collidables, overriding, if necessary, the primary behavior.
 void setCollisionBehavior(Collidable a, Collidable b, CollisionBehavior behavior)
          Sets collision behavior for a specified pair of Collidables, overriding, if necessary, the primary behavior.
 void setCollisionCompliance(double c)
           
 void setCollisionDamping(double d)
           
 void setCollisionPointTol(double tol)
           
 void setCollisionRegionTol(double tol)
           
 void setContactNormalLen(double len)
           
 void setDefaultCollisionBehavior(boolean enabled, double mu)
          Specifies the default collision behavior for all default pairs (RigidBody-RigidBody, RigidBody-Deformable, Deformable-Deformable, Deformable-Self).
 void setDefaultCollisionBehavior(Collidable typeA, Collidable typeB, boolean enabled, double mu)
          Sets the default collision behavior for a specified pair of generic collidable types.
 void setDefaultCollisionBehavior(Collidable typeA, Collidable typeB, CollisionBehavior behavior)
          Sets the default collision behavior for a specified pair of generic collidable types.
 void setDefaultCollisionBehavior(CollisionBehavior behavior)
          Specifies the default collision behavior for all default pairs (RigidBody-RigidBody, RigidBody-Deformable, Deformable-Deformable, Deformable-Self).
 void setDrawIntersectionContours(boolean set)
           
 void setDrawIntersectionFaces(boolean set)
           
 void setDrawIntersectionPoints(boolean set)
           
 void setFriction(double mu)
           
 void setPenetrationTol(double tol)
          Sets the penetration tolerance for this component.
 void setPenetrationTolMode(PropertyMode mode)
           
 void setUseNewHandler(boolean set)
           
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 
Methods inherited from class artisynth.core.modelbase.RenderableCompositeBase
copy, getRenderHints, getRenderProps, getSelection, isSelectable, numSelectionQueriesNeeded, setRenderProps
 
Methods inherited from class artisynth.core.modelbase.CompositeComponentBase
findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, hasChildren, hasState, hierarchyContainsReferences, indexOf, iterator, numComponents, postscan, scan, setDisplayMode, updateNameMap
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from interface maspack.properties.HasProperties
getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Field Detail

DEFAULT_USE_NEW_HANDLER

public static boolean DEFAULT_USE_NEW_HANDLER

myProps

public static PropertyList myProps
Constructor Detail

CollisionManager

public CollisionManager()
Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class ModelComponentBase
Returns:
static information for all exported properties

setPenetrationTol

public void setPenetrationTol(double tol)
Sets the penetration tolerance for this component. Setting a value of -1 will cause a default value to be computed based on the radius of the topmost MechModel.

Parameters:
tol - new penetration tolerance

getPenetrationTol

public double getPenetrationTol()

getPenetrationTolMode

public PropertyMode getPenetrationTolMode()

setPenetrationTolMode

public void setPenetrationTolMode(PropertyMode mode)

getDefaultPenetrationTol

public static double getDefaultPenetrationTol(ModelComponent comp,
                                              double defaultTol)

getCollisionArenaRadius

public double getCollisionArenaRadius()

setCollisionArenaRadius

public void setCollisionArenaRadius(double rad)

setCollisionPointTol

public void setCollisionPointTol(double tol)

getCollisionPointTol

public double getCollisionPointTol()

setCollisionRegionTol

public void setCollisionRegionTol(double tol)

getCollisionRegionTol

public double getCollisionRegionTol()

setContactNormalLen

public void setContactNormalLen(double len)

getContactNormalLen

public double getContactNormalLen()

setCollisionCompliance

public void setCollisionCompliance(double c)

getCollisionCompliance

public double getCollisionCompliance()

setCollisionDamping

public void setCollisionDamping(double d)

getCollisionDamping

public double getCollisionDamping()

getCollisionAccel

public double getCollisionAccel()

setCollisionAccel

public void setCollisionAccel(double acc)

clear

public void clear()

setFriction

public void setFriction(double mu)

setDefaultCollisionBehavior

public void setDefaultCollisionBehavior(boolean enabled,
                                        double mu)
Specifies the default collision behavior for all default pairs (RigidBody-RigidBody, RigidBody-Deformable, Deformable-Deformable, Deformable-Self). This is a convenience wrapper for setDefaultCollisionBehavior(behavior).

Parameters:
enabled - if true, enables collisions
mu - friction coefficient (ignored if enabled is false)

setDefaultCollisionBehavior

public void setDefaultCollisionBehavior(CollisionBehavior behavior)
Specifies the default collision behavior for all default pairs (RigidBody-RigidBody, RigidBody-Deformable, Deformable-Deformable, Deformable-Self).

Parameters:
behavior - desired collision behavior

getDefaultCollisionBehavior

public CollisionBehavior getDefaultCollisionBehavior(Collidable typeA,
                                                     Collidable typeB)
Gets the default collision behavior, for a specified pair of generic collidable types. Allowed collidable types are Collidable.RigidBody and Collidable.Deformable. In addition, the type Collidable.Self can be paired with Collidable.Deformable to obtain the default behavior for deformable self collisions; Collidable.Self cannot be paired with other types.

Parameters:
typeA - first generic collidable type
typeB - second generic collidable type
Returns:
default collision behavior for the indicted collidable types.

setDefaultCollisionBehavior

public void setDefaultCollisionBehavior(Collidable typeA,
                                        Collidable typeB,
                                        boolean enabled,
                                        double mu)
Sets the default collision behavior for a specified pair of generic collidable types. This is a convenience wrapper for setDefaultCollisionBehavior(typeA,typeB,behavior).

Parameters:
typeA - first generic collidable type
typeB - second generic collidable type
enabled - if true, enables collisions
mu - friction coefficient (ignored if enabled is false)

setDefaultCollisionBehavior

public void setDefaultCollisionBehavior(Collidable typeA,
                                        Collidable typeB,
                                        CollisionBehavior behavior)
Sets the default collision behavior for a specified pair of generic collidable types. Allowed collidable types are Collidable.RigidBody and Collidable.Deformable. In addition, the type Collidable.Self can be paired with Collidable.Deformable to set the default behavior for deformable self collisions; Collidable.Self cannot be paired with other types.

Parameters:
typeA - first generic collidable type
typeB - second generic collidable type
behavior - specified collision behavior

setCollisionBehavior

public void setCollisionBehavior(Collidable a,
                                 Collidable b,
                                 boolean enabled)

setCollisionBehavior

public void setCollisionBehavior(Collidable a,
                                 Collidable b,
                                 boolean enabled,
                                 double mu)
Sets collision behavior for a specified pair of Collidables, overriding, if necessary, the primary behavior. Each collidable must be a particular component instance. This is a convenience wrapper for setCollisionBehavior(a,b,behavior).

Parameters:
a - first Collidable
b - second Collidable
enabled - if true, enables collisions
mu - friction coefficient (ignored if enabled is false)

setCollisionBehavior

public void setCollisionBehavior(Collidable a,
                                 Collidable b,
                                 CollisionBehavior behavior)
Sets collision behavior for a specified pair of Collidables, overriding, if necessary, the primary behavior. Each collidable must be a particular component instance. A deformable body may be paired with Collidable.Self to indicate self-intersection; otherwise, generic designations (such as Collidable.RigidBody) are not allowed.

If the specified collision behavior equals the existing collision behavior (as returned by getCollisionBehavior(artisynth.core.mechmodels.Collidable, artisynth.core.mechmodels.Collidable)), then this method does nothing. Otherwise, if the collision behavior can be obtained by removing an existing collision override for the pair, the override is removed. Otherwise, a collision override is created for the desired behavior, replacing any existing override.

Parameters:
a - first Collidable
b - second Collidable
behavior - specified collision behavior

getCollisionOverride

public CollisionComponent getCollisionOverride(CollidablePair pair)
Returns the CollisionCompenent in this model associated with a particular collision override. If no such component exists, null is returned. This method is provided mostly for internal ArtiSynth use.

Parameters:
pair - collidable pair
Returns:
CollisionComponent in this model overriding collision behavior for the specified pair, if any

getCollisionOverride

public CollisionComponent getCollisionOverride(Collidable a,
                                               Collidable b)
Returns the CollisionCompenent in this model associated with a particular collision override. If no such component exists, null is returned. This method is provided mostly for internal ArtiSynth use.

Parameters:
a - first collidable
b - second collidable
Returns:
CollisionComponent in this model overriding collision behavior for (a, b), if any

addCollisionOverride

public void addCollisionOverride(CollidablePair pair,
                                 CollisionBehavior behavior)
Adds a CollisionComponent to override the primary collision behavior for a specific pair of components. Each collidable must be a particular component instance. A deformable body may be paired with Collidable.Self to indicate self-intersection; otherwise, generic designations (such as Collidable.RigidBody) are not allowed. This method is mainly intended for ArtiSynth internal use.

Parameters:
pair - specified pair of collidables
behavior - desired override collision behavior

removeCollisionOverride

public boolean removeCollisionOverride(CollisionComponent comp)
Removes a CollisionComponent, removing the collision override for the associated pair of components. This method is mainly intended for ArtiSynth internal use.

Parameters:
comp - CollisionComponent overriding primary collision behavior for a specific pair of components
Returns:
true if the specified collision component was present

clearCollisionOverrides

public void clearCollisionOverrides()
Removes all collision overrides, so that the collision behavior between all components will revert back to their primary behavior.


getPrimaryCollisionBehavior

public CollisionBehavior getPrimaryCollisionBehavior(CollidablePair pair)
Returns the primary collision behavior for a specified component pair as seen by this model. A primary collision behavior is the collision behavior that will occur in the absence of any override behaviors in this model. Typically, this will be the default behavior, unless both components in the pair belong to a sub-MechModel, in which case the CollisionManager in the sub-MechModel determines the behavior.

Each collidable must be a particular component instance. A deformable body may be paired with Collidable.Self to indicate self-intersection; otherwise, generic designations (such as Collidable.RigidBody) are not allowed.

Parameters:
pair - specified pair of collidables
Returns:
primary collision behavior for the specified component pair

getCollisionBehavior

public CollisionBehavior getCollisionBehavior(Collidable a,
                                              Collidable b)
Returns the collision behavior for a specified pair of collidables. Each collidable must be a particular component instance. A deformable body may be paired with Collidable.Self to indicate self-intersection; otherwise, generic designations (such as Collidable.RigidBody) are not allowed.

If this CollisionManager contains a collision override for the specified pair, then the behavior will be determined by that override. Otherwise, the behavior will equal that returned by getPrimaryCollisionBehavior(artisynth.core.mechmodels.CollidablePair).

Parameters:
a - first Collidable
b - second Collidable
Returns:
behavior for this pair of Collidables.

collisionHandlers

public CollisionHandlerList collisionHandlers()
If necessary, rebuilds the collison pair list from the specified contact info.


collisionComponents

public ComponentList<CollisionComponent> collisionComponents()

initialize

public void initialize()

createRenderProps

public RenderProps createRenderProps()
Description copied from interface: HasRenderProps
Factory method to create render properties appropriate to this object.

Specified by:
createRenderProps in interface HasRenderProps
Overrides:
createRenderProps in class RenderableCompositeBase
Returns:
new render properties for this object

updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Overrides:
updateBounds in class RenderableCompositeBase
Parameters:
pmin - minimum point
pmax - maximum point

prerender

public void prerender(RenderList list)
Description copied from interface: GLRenderable
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.

Specified by:
prerender in interface GLRenderable
Overrides:
prerender in class RenderableCompositeBase

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Specified by:
render in class RenderableCompositeBase
Parameters:
renderer - renderer object which is used to perform the rendering. Provides pointers to GL and GLU, along with helper functions.
flags - supplies flags that may be used to control different aspects of the rendering. Flags are defined in GLRenderer and currently include GLRenderer.SELECTED, GLRenderer.VERTEX_COLORING, GLRenderer.HSV_COLOR_INTERPOLATION, GLRenderer.SORT_FACES, and GLRenderer.CLEAR_MESH_DISPLAY_LISTS.

scaleDistance

public void scaleDistance(double s)
Description copied from interface: ScalableUnits
Scales all distance coordinates.

Specified by:
scaleDistance in interface ScalableUnits
Parameters:
s - scaling factor

scaleMass

public void scaleMass(double s)
Description copied from interface: ScalableUnits
Scales all mass units.

Specified by:
scaleMass in interface ScalableUnits
Parameters:
s - scaling factor

clearCachedData

public void clearCachedData()

addAuxStateComponents

public void addAuxStateComponents(java.util.List<HasAuxState> comps)

componentChanged

public void componentChanged(ComponentChangeEvent e)
Description copied from class: CompositeComponentBase
Notifies this composite component that a change has occured within one or more of its descendants. When this occurs, the composite may need to invalidate cached information that depends on the descendants.

This method should propagate the notification up the component hierarchy by calling notifyParentOfChange.

Specified by:
componentChanged in interface ComponentChangeListener
Specified by:
componentChanged in interface CompositeComponent
Overrides:
componentChanged in class CompositeComponentBase
Parameters:
e - optional argument giving specific information about the change

getConstrainers

public void getConstrainers(java.util.List<Constrainer> constrainers)

setUseNewHandler

public void setUseNewHandler(boolean set)

getUseNewHandler

public boolean getUseNewHandler()

setDrawIntersectionContours

public void setDrawIntersectionContours(boolean set)

isDrawIntersectionContours

public boolean isDrawIntersectionContours()

setDrawIntersectionFaces

public void setDrawIntersectionFaces(boolean set)

isDrawIntersectionFaces

public boolean isDrawIntersectionFaces()

setDrawIntersectionPoints

public void setDrawIntersectionPoints(boolean set)

isDrawIntersectionPoints

public boolean isDrawIntersectionPoints()