Time for action – pick a brick (using crosshairs)

To learn about picking a target in the scene, let's add a second cube to the scene. Again we want to click to rotate a cube, but this time, we want to pick the cube that will be the target of the action.

  1. Make a copy of the previous exercise, UserInput.java. Keep the mouse click and the key press actions for inspiration.
  2. Rename the copy of the class to TargetPickCenter.java. Remember to also refactor the first line of the main() method to the following:
    TargetPickCenter app = new TargetPickCenter();.
  3. Let's write a simple cube generator so that we can generate sample content more easily: move the code block that creates the blue cube from the simpleInitApp() method into a custom method called myCube() ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.