O'Reilly logo

jMonkeyEngine 3.0 Beginner's Guide by Ruth Kusterer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – pick a brick (crosshairs with ray casting)

You want the player to aim and click one of the cubes. You want to identify the selected cube, and make it rotate.

  1. Start by implementing the AnalogListener object on the Analog() method to test for our left-click action, MAPPING_ROTATE. Remember, we chose the AnalogListener object because rotation is a continuous motion.
    private AnalogListener analogListener = new AnalogListener() {
        public void onAnalog(String name, float intensity, float tpf) {
            if (name.equals(MAPPING_ROTATE)) {
                // implement action here
            }   
        }
    };
  2. To identify what was clicked, we use methods from the com.jme3.collision package. Replace the implement action here comment with the following code; first we create an empty results ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required