minecraft-source/src/com/mojang/blaze3d/audio/Listener.java

43 lines
1.1 KiB
Java
Raw Normal View History

2020-07-22 06:23:34 +01:00
package com.mojang.blaze3d.audio;
2020-07-22 06:25:47 +01:00
import com.mojang.math.Vector3f;
2020-07-22 06:23:34 +01:00
import org.lwjgl.openal.AL10;
import net.minecraft.world.phys.Vec3;
public class Listener {
private float gain;
2020-07-22 06:32:50 +01:00
private Vec3 position;
2020-07-22 06:23:34 +01:00
public Listener() {
this.gain = 1.0f;
2020-07-22 06:32:50 +01:00
this.position = Vec3.ZERO;
2020-07-22 06:23:34 +01:00
}
2020-07-22 06:32:50 +01:00
public void setListenerPosition(final Vec3 dem) {
this.position = dem;
AL10.alListener3f(4100, (float)dem.x, (float)dem.y, (float)dem.z);
2020-07-22 06:23:34 +01:00
}
2020-07-22 06:32:50 +01:00
public Vec3 getListenerPosition() {
return this.position;
}
public void setListenerOrientation(final Vector3f g1, final Vector3f g2) {
AL10.alListenerfv(4111, new float[] { g1.x(), g1.y(), g1.z(), g2.x(), g2.y(), g2.z() });
2020-07-22 06:23:34 +01:00
}
public void setGain(final float float1) {
AL10.alListenerf(4106, float1);
this.gain = float1;
}
public float getGain() {
return this.gain;
}
public void reset() {
this.setListenerPosition(Vec3.ZERO);
2020-07-22 06:25:47 +01:00
this.setListenerOrientation(Vector3f.ZN, Vector3f.YP);
2020-07-22 06:23:34 +01:00
}
}