Package com.simsilica.lemur.event
Class PickEventSession
java.lang.Object
com.simsilica.lemur.event.PickEventSession
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollisionRoot
(ViewPort viewPort) void
addCollisionRoot
(ViewPort viewPort, String layer) void
addCollisionRoot
(Spatial root, ViewPort viewPort) void
addCollisionRoot
(Spatial root, ViewPort viewPort, String layer) boolean
buttonEvent
(int buttonIndex, int x, int y, boolean pressed) void
Clears the current hit target that is used for entered/exited processing.clone()
Creates a new PickEventSession with the same roots that his pick event session has at the time of cloning.void
close()
Clears the hit target and clears all internal data including collision roots.boolean
cursorMoved
(int x, int y) Called when the cursor has moved.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.protected Spatial
findHitTarget
(Spatial hit) Finds a spatial in the specified spatial's hierarchy that is capable of recieving mouse events.protected PickEventSession.RootEntry
String[]
protected Ray
getPickRay
(PickEventSession.RootEntry rootEntry, Vector2f cursor) protected SafeArrayList
<PickEventSession.RootEntry> protected float[]
Returns the min and max world z values for the specified spatial.boolean
Returns true if extra debug logging has been turned on.protected boolean
void
removeCollisionRoot
(ViewPort viewPort) void
removeCollisionRoot
(Spatial root) protected void
setCurrentHitTarget
(ViewPort viewport, Spatial s, Vector2f cursor, CollisionResult cr) void
setDebugOn
(boolean f) Turns on extra debug logging.void
setPickLayerOrder
(String... layers) protected void
protected boolean
viewContains
(Camera cam, Vector2f cursor)
-
Constructor Details
-
PickEventSession
public PickEventSession() -
PickEventSession
-
-
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
-
clone
Creates a new PickEventSession with the same roots that his pick event session has at the time of cloning. -
findViewPort
-
findRootEntry
-
addCollisionRoot
-
addCollisionRoot
-
addCollisionRoot
-
addCollisionRoot
-
removeCollisionRoot
-
removeCollisionRoot
-
setPickLayerOrder
-
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
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
-
viewContains
-
getZBounds
Returns the min and max world z values for the specified spatial. -
getPickRay
-
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)
-