org.selman.java3d.book.pickcollisiontest
Class CollisionBehavior
java.lang.Object
|
+--javax.media.j3d.SceneGraphObject
|
+--javax.media.j3d.Node
|
+--javax.media.j3d.Leaf
|
+--javax.media.j3d.Behavior
|
+--org.selman.java3d.book.pickcollisiontest.CollisionBehavior
- public class CollisionBehavior
- extends javax.media.j3d.Behavior
This behavior detects collisions between the branch of a scene, and
a collision object. The Java 3D 1.2 picking utilities are used to
implement collision detection. The objects in the scene that are
collidable should have their user data set. The collision object's
user data is used to ignore collisions between the object and itself.
When a collision is detected the trajectory of the collision object
is reversed (plus a small random factor) and an Appearance object
is modified.
When a collision is not detected the collision object is moved
along its current trajectory and the Appearance color is reset.
Colision checking is run after every frame.
Fields inherited from class javax.media.j3d.Node |
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING |
Constructor Summary |
CollisionBehavior(javax.media.j3d.BranchGroup pickRoot,
javax.media.j3d.TransformGroup collisionObject,
javax.media.j3d.Appearance app,
javax.vecmath.Vector3d posVector,
javax.vecmath.Vector3d incVector)
|
Methods inherited from class javax.media.j3d.Behavior |
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn |
Methods inherited from class javax.media.j3d.Node |
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable |
Methods inherited from class javax.media.j3d.SceneGraphObject |
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setUserData |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_WakeupCondition
protected javax.media.j3d.WakeupCondition m_WakeupCondition
CollisionBehavior
public CollisionBehavior(javax.media.j3d.BranchGroup pickRoot,
javax.media.j3d.TransformGroup collisionObject,
javax.media.j3d.Appearance app,
javax.vecmath.Vector3d posVector,
javax.vecmath.Vector3d incVector)
initialize
public void initialize()
- Specified by:
initialize
in class javax.media.j3d.Behavior
onCollide
protected void onCollide()
onMiss
protected void onMiss()
moveCollisionObject
protected void moveCollisionObject()
isCollision
public boolean isCollision(com.sun.j3d.utils.picking.PickResult[] resultArray)
processStimulus
public void processStimulus(java.util.Enumeration criteria)
- Specified by:
processStimulus
in class javax.media.j3d.Behavior