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.
Make a copy of
Main.java
and name the classPositionalSound.java
. Remember to also refactor the first line of themain()
method toPositionalSoundapp = new PositionalSound();
.Copy the provided file
Sounds/Environment/River.ogg
into your project'sSounds/Environment/
directory.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"); riverbedNode.setLocalTranslation(Vector3f.ZERO); rootNode.attachChild(riverbedNode); // Attach a geometry to the scene node (just a blue cube) Box riverbedMesh = new Box(Vector3f.ZERO, 1, 1, 1); Geometry riverbedGeo = new Geometry...