I'm currently implementing picking in my project and am interested to know if there is a better way of achieving what I am trying to do.
I have extended InputAdapterRenderLoop and am using the method below to call a listener to process picking
public void onMouseButtonReleased(MouseDevice mouse, int button, int x, int y){
PickingLibrary.pickNearest(mainGroup, canvas, button, x, y, worldPickListener);
}
Where worldPickListener is a custom class that implements NearestPickListener.
Now as I am making an RTS I was planning to process the picking in the following manner
1) User selects a single or group of units
2) The listener stores this list of units and waits for the actual command
3) The user makes a choice of action (lets say move) which means they click somewhere else on the map
4) A new action is created to perform the action (in this case it is to move the unit from its current position to the new coordinates)
My problem currently lies in step 3. When the user clicks on a blank space to move a unit from their current position to the new picked coordinate the listener is called but on the 'onPickingMissed' method (makes sense as nothing is there to pick) but this does not contain the translated coordinates the user clicked on. This presents a problem when trying to move a unit to a coordinate. Now I'm wondering if I missed a simpler way of doing this or maybe am I using a method in the wrong way? But basically I need the coordinates on a picking miss, should I be using a different type of listener?
Any advice or guidance?