Class PickEventSession

java.lang.Object
com.simsilica.lemur.event.PickEventSession

public class PickEventSession extends Object
Encapsulates the state necessary to deliver events to targets, track capture, track enter/exit, etc. devoid of specific mouse events. This allows it to be used for arbitrary picking as would be needed by joysticks or when clicking on off-screen rendered views of different scenes.

Collision roots may either be perspective or orthogonal and the appropriate type of collision is done. The ViewPort's camera is used to detect the difference.

Events are delivered in near to far order to any 'target' that the cursor ray collides with until the event is consumed. Enter and exit events are delivered as targets are acquired or lost.

If a button down event happens over a target then it is considered 'captured'. This spatial will be provided to subsequent events in addition to the normal target. Furthermore, any new motion events are always delivered to the captured spatial first.

  • Constructor Details

  • Method Details

    • setDebugOn

      public void setDebugOn(boolean f)
      Turns on extra debug logging. This will cause all of the logging that would normally be at trace level for any instance to be at debug level just for _this_ instance.
    • isDebugOn

      public boolean isDebugOn()
      Returns true if extra debug logging has been turned on.
    • isTraceEnabled

      protected boolean isTraceEnabled()
    • trace

      protected void trace(String msg)
    • clone

      public PickEventSession clone()
      Creates a new PickEventSession with the same roots that his pick event session has at the time of cloning.
      Overrides:
      clone in class Object
    • findViewPort

      public ViewPort findViewPort(Spatial s)
    • findRootEntry

      protected PickEventSession.RootEntry findRootEntry(Spatial s)
    • addCollisionRoot

      public void addCollisionRoot(ViewPort viewPort)
    • addCollisionRoot

      public void addCollisionRoot(ViewPort viewPort, String layer)
    • addCollisionRoot

      public void addCollisionRoot(Spatial root, ViewPort viewPort)
    • addCollisionRoot

      public void addCollisionRoot(Spatial root, ViewPort viewPort, String layer)
    • removeCollisionRoot

      public void removeCollisionRoot(ViewPort viewPort)
    • removeCollisionRoot

      public void removeCollisionRoot(Spatial root)
    • setPickLayerOrder

      public void setPickLayerOrder(String... layers)
    • getPickLayerOrder

      public String[] getPickLayerOrder()
    • clearHitTarget

      public void clearHitTarget()
      Clears the current hit target that is used for entered/exited processing. This will cause any currently 'entered' spatial to receive an 'exited' event. This is useful for when the thing that initiated this session is done (temporarily or otherwise) sending events to this session.
    • close

      public void close()
      Clears the hit target and clears all internal data including collision roots.
    • findHitTarget

      protected Spatial findHitTarget(Spatial hit)
      Finds a spatial in the specified spatial's hierarchy that is capable of recieving mouse events.
    • setCurrentHitTarget

      protected void setCurrentHitTarget(ViewPort viewport, Spatial s, Vector2f cursor, CollisionResult cr)
    • getRootList

      protected SafeArrayList<PickEventSession.RootEntry> getRootList()
    • viewContains

      protected boolean viewContains(Camera cam, Vector2f cursor)
    • getZBounds

      protected float[] getZBounds(Spatial s)
      Returns the min and max world z values for the specified spatial.
    • getPickRay

      protected Ray getPickRay(PickEventSession.RootEntry rootEntry, Vector2f cursor)
    • cursorMoved

      public boolean cursorMoved(int x, int y)
      Called when the cursor has moved.
    • cursorMoved

      public boolean cursorMoved(int x, int y, int scroll)
      Called when the cursor has moved in an environment where there is also a separate scroll wheel or other scroll control.
    • buttonEvent

      public boolean buttonEvent(int buttonIndex, int x, int y, boolean pressed)