Aiming fixed crosshairs is one way to pick objects in the scene. Another option is to make the mouse pointer visible, and allow free clicks.
Make a copy of the previous exercise,
TargetPickCenter.java
. You can keep the code that handles the mouse click actions and the key press actions for inspiration.Rename the copy of the class to
TargetPickCursor.java
. Remember to also refactor the first line of themain()
method to the following:TargetPickCursor app = new TargetPickCursor();
Keep the
myBox()
method, the constants, theanalogListener
object, and the two cubes. Remove theattachCenterMark()
method, and theAnalogListener
object implementation.By default, the mouse pointer is hidden. To make it visible, add the following to the
simpleInitApp()
method:flyCam.setDragToRotate(true); inputManager.setCursorVisible(true);
Run TargetPickCursor
to see the intermediate result.