shout3d.core
Interface Picker


public abstract interface Picker

An interface which represents a Picker and provides required methods.


Field Summary
static int MATRIX
           
static int NORMAL
           
static int POINT
           
 
Method Summary
 float[] getPickInfo(int which)
          Gets any info that was requested (prior to performing the pick) by setting flags in setPickInfo.
 boolean pickAny(int x, int y)
          Given a pixel coordinate assumed to be in the viewer's window, returns a boolean stating whether any geometry in the scene was intersected by the ray from the eyepoint through the pixel.
 boolean pickAnyFromTo(float[] from, float[] to)
          Given a ray described as going from the 'from' point and towards the 'to' point, returns a boolean stating whether any geometry in the scene was intersected by the ray.
 Node[] pickClosest(int x, int y)
          Given a pixel coordinate assumed to be in the viewer's window, constructs a ray from the location of the viewer's currently bound Viewpoint, then intersects.
 Node[] pickClosestFromTo(float[] from, float[] to)
          Given a ray described as going from the 'from' point and towards the 'to' point, intersects that ray.
 void setPath(Node[] path)
          Establishes a new path for the picker to usre for ray intersection.
 void setPickInfo(int which, boolean doCalculation)
          Tells the Picker which information it needs to collect as it traverses the scene graph in order to Pick.
 void setScene(Node root)
          Establishes a new scene graph for the picker to use for ray intersection.
 boolean wasPicked(Node node)
          After performing a pick, this returns true if the given node was on the path to the pick.
 

Field Detail

POINT

public static final int POINT

NORMAL

public static final int NORMAL

MATRIX

public static final int MATRIX
Method Detail

setPickInfo

public void setPickInfo(int which,
                        boolean doCalculation)
Tells the Picker which information it needs to collect as it traverses the scene graph in order to Pick.
Parameters:
which - the flag indicating which info the user is specifying (POINT, NORMAL, or MATRIX)
doCalculation - whether this Picker should collect which's info

setScene

public void setScene(Node root)
Establishes a new scene graph for the picker to use for ray intersection. By default, intersects with the associated viewer's scene. This method overrides that default Note: setting this does NOT look for the given root below the viewers scene and attempt to pick that sub-scene. For that behavior, construct a path from the viewer's scene root down to the desired node sub-scene-root and pass that path to this interface's setPath() method.
Parameters:
root - the root of the scene to pick

setPath

public void setPath(Node[] path)
Establishes a new path for the picker to usre for ray intersection. Attempts1 only to intersect the ray with nodes at or below the leaf (final) node of the path. Other nodes in the path are used only to collect tranfsormation information, by calling getMatrix on Group nodes along the path. By default, the picker intersects with the associated viewer's scene. This method overrides that default.
Parameters:
path - the path to the subgraph to pick

pickAny

public boolean pickAny(int x,
                       int y)
Given a pixel coordinate assumed to be in the viewer's window, returns a boolean stating whether any geometry in the scene was intersected by the ray from the eyepoint through the pixel. When this method is used, no pickInfo (POINT, NORMAL, or MATRIX) may be retrieved afterward.
Parameters:
x - the pixel's x coordinate
y - the pixel's y coordinate
Returns:
whether the ray hits anything

pickAnyFromTo

public boolean pickAnyFromTo(float[] from,
                             float[] to)
Given a ray described as going from the 'from' point and towards the 'to' point, returns a boolean stating whether any geometry in the scene was intersected by the ray. When this method is used, no pickInfo (POINT, NORMAL, or MATRIX) may be retrieved afterward.
Parameters:
from - the from point of the given ray
to - the to point of the given ray
Returns:
whether the ray hits anything

pickClosest

public Node[] pickClosest(int x,
                          int y)
Given a pixel coordinate assumed to be in the viewer's window, constructs a ray from the location of the viewer's currently bound Viewpoint, then intersects. Returns a path to the geometry node below the scene root that is intersected by the ray at a point closer to the current Viewpoint's position than any other geometry below the scene root. If no geometry below the scene root is intersected by the ray, returns null.
Parameters:
x - the pixel's x coordinate
y - the pixel's y coordinate
Returns:
the path to the picked node or null if nothing is picked.

pickClosestFromTo

public Node[] pickClosestFromTo(float[] from,
                                float[] to)
Given a ray described as going from the 'from' point and towards the 'to' point, intersects that ray. Returns a path to the geometry node below the scene root that is intersected by the ray at a point closer to the 'from' point than any other geometry below the scene root. If no geometry below the scene root is intersected by the ray, returns null.
Parameters:
from - the from point of the given ray
to - the to point of the given ray
Returns:
the path to the picked node or null if nothing is picked.

wasPicked

public boolean wasPicked(Node node)
After performing a pick, this returns true if the given node was on the path to the pick.
Parameters:
node - the node to look for on the pick path
Returns:
true if the node is on the path, false otherwise

getPickInfo

public float[] getPickInfo(int which)
                    throws Shout3DException
Gets any info that was requested (prior to performing the pick) by setting flags in setPickInfo. Must be called after the pick has been performed. Note: Normal is undefined for lines and points.
Parameters:
which - the info to receive