net.pacbell.jfai.toh.ui
Class MousePicker

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.Node
          extended by javax.media.j3d.Leaf
              extended by javax.media.j3d.Behavior
                  extended by com.sun.j3d.utils.picking.behaviors.PickMouseBehavior
                      extended by net.pacbell.jfai.toh.ui.MousePicker

public class MousePicker
extends PickMouseBehavior

A mouse behavior that allows user to select scene graph objects. Common usage:

1. Create your scene graph.

2. Create this behavior with root and canvas.

 MousePicker behavior = new MousePicker(canvas, root, bounds);
 root.addChild(behavior);
 

The above behavior will monitor for any picking events using the left mouse button in the scene graph (below root node). Note the root node can also be a sub-graph node of the scene graph (rather than the topmost). Derived from PickRotateBehavior .


Field Summary
 
Fields inherited from class com.sun.j3d.utils.picking.behaviors.PickMouseBehavior
buttonPress, conditions, currGrp, debug, mevent, pickCanvas, wakeupCondition
 
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
MousePicker(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode)
          Creates a pick behavior that waits for user mouse events for the scene graph using a specified pick mode.
 
Method Summary
 PickingCallback getCallback()
          Gets the callback.
 int getPickMode()
          Gets the pick mode.
 void setCallback(PickingCallback callback)
          Register the callback class.
 void setPickMode(int pickMode)
          Sets the pick mode.
 void updateScene(int xpos, int ypos)
          Handles mouse button events in the 3D scene.
 
Methods inherited from class com.sun.j3d.utils.picking.behaviors.PickMouseBehavior
getMode, getTolerance, initialize, processStimulus, setMode, setTolerance
 
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
 

Constructor Detail

MousePicker

public MousePicker(BranchGroup root,
                   Canvas3D canvas,
                   Bounds bounds,
                   int pickMode)
Creates a pick behavior that waits for user mouse events for the scene graph using a specified pick mode.

Parameters:
root - Root of your scene graph.
canvas - Java 3D drawing canvas.
bounds - Bounds of your scene.
pickMode - PickObject.USE_BOUNDS or PickObject.USE_GEOMETRY. Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry objects in the scene graph that are pickable must have the ALLOW_INTERSECT capability set.
Method Detail

getCallback

public PickingCallback getCallback()
Gets the callback.

Returns:
the PickingCallback

getPickMode

public int getPickMode()
Gets the pick mode.

Returns:
The pick mode.
See Also:
PickTool

setCallback

public void setCallback(PickingCallback callback)
Register the callback class.

Parameters:
callback - to be called each time a pick was attempted. The callback's type is set to PickingCallback.ROTATE for a successful pick, or PickingCallback.NO_PICK otherwise.

setPickMode

public void setPickMode(int pickMode)
Sets the pick mode.

Parameters:
pickMode - The pick mode.
See Also:
PickTool

updateScene

public void updateScene(int xpos,
                        int ypos)
Handles mouse button events in the 3D scene.

Specified by:
updateScene in class PickMouseBehavior
Parameters:
xpos - Current mouse X position
ypos - Current mouse Y position
See Also:
PickRotateBehavior