edu.mines.jtk.sgl
Class PickContext

java.lang.Object
  extended by edu.mines.jtk.sgl.TraversalContext
      extended by edu.mines.jtk.sgl.TransformContext
          extended by edu.mines.jtk.sgl.PickContext

public class PickContext
extends TransformContext

A transform context for picking.

A pick context has a pick segment, which is a line segment in a local coordinate system. During a pick traversal of the scene graph, nodes compute points of intersection, if any, between their geometry and the pick segment. For efficiency, only nodes with bounding spheres that intersect the pick segment will perform intersection computations.

The pick segment in a pick context has two endpoints. One endpoint lies on the near clipping plane, with specified pixel (x,y) coordinates and pixel z coordinate 0.0. This endpoint is called the near endpoint of the pick segment. The far endpoint lies on the far clipping plane. It has the same specified pixel (x,y) coordinates as the near endpoint, but has pixel z coordinate 1.0. With these pick segment endpoints, only geometry between the near and far clipping planes can be picked.

Version:
2005.06.21
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
PickContext(java.awt.event.MouseEvent event)
          Constructs a pick context for the specified mouse event.
 
Method Summary
 void addResult(Point3 point)
          Adds a pick result with specified pick point to this context.
 PickResult getClosest()
          Gets the pick result closest to the origin of the pick segment.
 java.awt.event.MouseEvent getMouseEvent()
          Gets the mouse event for which this context was constructed.
 Segment getPickSegment()
          Gets the pick segment for this context.
 void popLocalToWorld()
          Restores the most recently saved (pushed) local-to-world transform.
 void pushLocalToWorld(Matrix44 transform)
          Saves the local-to-world transform before appending a transform.
 boolean segmentIntersectsSphereOf(Node node)
          Determines whether the pick segment intersects the bounding sphere of the specified node.
 
Methods inherited from class edu.mines.jtk.sgl.TransformContext
getCubeToLocal, getCubeToPixel, getCubeToView, getCubeToWorld, getLocalToCube, getLocalToPixel, getLocalToView, getLocalToWorld, getPixelToCube, getPixelToLocal, getPixelToView, getPixelToWorld, getView, getViewCanvas, getViewToCube, getViewToLocal, getViewToPixel, getViewToWorld, getWorld, getWorldToCube, getWorldToLocal, getWorldToPixel, getWorldToView
 
Methods inherited from class edu.mines.jtk.sgl.TraversalContext
countNodes, getNode, getNode, getNodes, popNode, pushNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PickContext

public PickContext(java.awt.event.MouseEvent event)
Constructs a pick context for the specified mouse event.

Parameters:
event - the mouse event.
Method Detail

getMouseEvent

public java.awt.event.MouseEvent getMouseEvent()
Gets the mouse event for which this context was constructed.

Returns:
the mouse event.

getPickSegment

public Segment getPickSegment()
Gets the pick segment for this context. Endpoint A of the segment lies on the near clipping plane; endpoint B lies on the far clipping plane.

Returns:
the pick segment.

segmentIntersectsSphereOf

public boolean segmentIntersectsSphereOf(Node node)
Determines whether the pick segment intersects the bounding sphere of the specified node.

Parameters:
node - the node with a bounding sphere.
Returns:
true, if the pick segment intersects the bounding sphere; false, otherwise.

addResult

public void addResult(Point3 point)
Adds a pick result with specified pick point to this context.

Parameters:
point - the pick point, in local coordinates.

getClosest

public PickResult getClosest()
Gets the pick result closest to the origin of the pick segment.

Returns:
the pick result; null, if none.

pushLocalToWorld

public void pushLocalToWorld(Matrix44 transform)
Saves the local-to-world transform before appending a transform. The specified transform matrix is post-multiplied with the current local-to-world transform, such that the specified transform is applied first when transforming local coordinates to world coordinates.

Overrides:
pushLocalToWorld in class TransformContext
Parameters:
transform - the transform to append.

popLocalToWorld

public void popLocalToWorld()
Restores the most recently saved (pushed) local-to-world transform. Discards the current local-to-world transform.

Overrides:
popLocalToWorld in class TransformContext