I’m having a problem with the Hello Audio and getting the 3D sound aspect of it to work. Perhaps I have just misunderstood the tutorial but here is what I am trying to do: I’d like to “shoot” a point onto a structure, find the collision point, and place a 3D sound node at that point that gets louder the closer the camera gets to it and softer the farther the camera gets from it. I attached the code of what I have so far and basically it is cut-and-paste from the two tutorials but for some reason the sound does not wane/grow louder the way I want it to. Not sure if I’m missing something or what but I’d truly appreciate any help on this matter. Wasn’t sure if it might require some special hardware / sound card to get the audio to do this. Thanks for any help people can provide on this! Even code snippets to try out would be a great plus! Thanks!
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
wall_structure.collideWith(ray, results);
for (int i = 0; i < results.size(); i++) {
// For each hit, we know distance, impact point, name of geometry.
float dist = results.getCollision(i).getDistance();
Vector3f pt = results.getCollision(i).getContactPoint();
}
if (results.size() > 0){
// The closest collision point is what was truly hit:
CollisionResult closest = results.getClosestCollision();
mark.setLocalTranslation(closest.getContactPoint());
audio_mark = new AudioNode(assetManager, "Sounds/hello.ogg",true);
audio_mark.setPositional(true);
audio_mark.setMaxDistance(4);
audio_mark.setLocalTranslation(closest.getContactPoint());
audio_mark.setVolume(2);
placed_audio = true;
audioRenderer.playSource(audio_mark);
.......
@Override
public void simpleUpdate(float tpf) {
listener.setLocation(cam.getLocation());
listener.setRotation(cam.getRotation());
if(placed_audio){
float d0 = (audio_nature.getLocalTranslation().subtract(cam.getLocation())).length();
System.out.println(d0);
}
}