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 – positional audio

We create a looping positional audio node, and attach it to a parent node that is positioned at the origin.

The following sample code introduces you to a simple case of positional audio.

  1. Make a copy of Main.java and name the class PositionalSound.java. Remember to also refactor the first line of the main() method to PositionalSoundapp = new PositionalSound();.
  2. Copy the provided file Sounds/Environment/River.ogg into your project's Sounds/Environment/ directory.
  3. In the simpleInitApp() method, attach some filler content (a node and a cube geometry) to the scene graph so you have a point of reference:
    public void simpleInitApp() { // Create a node for the object the sound belongs to Node riverbedNode = new Node("Riverbed"); ...

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