|
|
@ -78,6 +78,7 @@ public class AudioNode extends Node implements AudioSource { |
|
|
|
protected transient AudioData data = null; |
|
|
|
protected transient AudioData data = null; |
|
|
|
protected transient volatile AudioSource.Status status = AudioSource.Status.Stopped; |
|
|
|
protected transient volatile AudioSource.Status status = AudioSource.Status.Stopped; |
|
|
|
protected transient volatile int channel = -1; |
|
|
|
protected transient volatile int channel = -1; |
|
|
|
|
|
|
|
protected Vector3f previousWorldTranslation = Vector3f.NAN; |
|
|
|
protected Vector3f velocity = new Vector3f(); |
|
|
|
protected Vector3f velocity = new Vector3f(); |
|
|
|
protected boolean reverbEnabled = false; |
|
|
|
protected boolean reverbEnabled = false; |
|
|
|
protected float maxDistance = 200; // 200 meters
|
|
|
|
protected float maxDistance = 200; // 200 meters
|
|
|
@ -88,6 +89,8 @@ public class AudioNode extends Node implements AudioSource { |
|
|
|
protected float innerAngle = 360; |
|
|
|
protected float innerAngle = 360; |
|
|
|
protected float outerAngle = 360; |
|
|
|
protected float outerAngle = 360; |
|
|
|
protected boolean positional = true; |
|
|
|
protected boolean positional = true; |
|
|
|
|
|
|
|
protected boolean velocityFromTranslation = false; |
|
|
|
|
|
|
|
protected float lastTpf; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>Status</code> indicates the current status of the audio node. |
|
|
|
* <code>Status</code> indicates the current status of the audio node. |
|
|
@ -702,17 +705,44 @@ public class AudioNode extends Node implements AudioSource { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isVelocityFromTranslation() { |
|
|
|
|
|
|
|
return velocityFromTranslation; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setVelocityFromTranslation(boolean velocityFromTranslation) { |
|
|
|
|
|
|
|
this.velocityFromTranslation = velocityFromTranslation; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateGeometricState(){ |
|
|
|
public void updateLogicalState(float tpf) { |
|
|
|
boolean updatePos = false; |
|
|
|
super.updateLogicalState(tpf); |
|
|
|
if ((refreshFlags & RF_TRANSFORM) != 0){ |
|
|
|
lastTpf = tpf; |
|
|
|
updatePos = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void updateGeometricState() { |
|
|
|
super.updateGeometricState(); |
|
|
|
super.updateGeometricState(); |
|
|
|
|
|
|
|
|
|
|
|
if (updatePos && channel >= 0) |
|
|
|
if (channel < 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3f currentWorldTranslation = worldTransform.getTranslation(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Float.isNaN(previousWorldTranslation.x) |
|
|
|
|
|
|
|
|| !previousWorldTranslation.equals(currentWorldTranslation)) { |
|
|
|
|
|
|
|
|
|
|
|
getRenderer().updateSourceParam(this, AudioParam.Position); |
|
|
|
getRenderer().updateSourceParam(this, AudioParam.Position); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (velocityFromTranslation) { |
|
|
|
|
|
|
|
velocity.set(currentWorldTranslation).subtractLocal(previousWorldTranslation); |
|
|
|
|
|
|
|
velocity.multLocal(1f / lastTpf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getRenderer().updateSourceParam(this, AudioParam.Velocity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previousWorldTranslation.set(currentWorldTranslation); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -772,6 +802,7 @@ public class AudioNode extends Node implements AudioSource { |
|
|
|
oc.write(outerAngle, "outer_angle", 360); |
|
|
|
oc.write(outerAngle, "outer_angle", 360); |
|
|
|
|
|
|
|
|
|
|
|
oc.write(positional, "positional", false); |
|
|
|
oc.write(positional, "positional", false); |
|
|
|
|
|
|
|
oc.write(velocityFromTranslation, "velocity_from_translation", false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -806,6 +837,7 @@ public class AudioNode extends Node implements AudioSource { |
|
|
|
outerAngle = ic.readFloat("outer_angle", 360); |
|
|
|
outerAngle = ic.readFloat("outer_angle", 360); |
|
|
|
|
|
|
|
|
|
|
|
positional = ic.readBoolean("positional", false); |
|
|
|
positional = ic.readBoolean("positional", false); |
|
|
|
|
|
|
|
velocityFromTranslation = ic.readBoolean("velocity_from_translation", false); |
|
|
|
|
|
|
|
|
|
|
|
if (audioKey != null) { |
|
|
|
if (audioKey != null) { |
|
|
|
try { |
|
|
|
try { |
|
|
|