use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class AudioNode method updateGeometricState.
@Override
public void updateGeometricState() {
super.updateGeometricState();
if (channel < 0) {
return;
}
Vector3f currentWorldTranslation = worldTransform.getTranslation();
if (Float.isNaN(previousWorldTranslation.x) || !previousWorldTranslation.equals(currentWorldTranslation)) {
getRenderer().updateSourceParam(this, AudioParam.Position);
if (velocityFromTranslation) {
velocity.set(currentWorldTranslation).subtractLocal(previousWorldTranslation);
velocity.multLocal(1f / lastTpf);
getRenderer().updateSourceParam(this, AudioParam.Velocity);
}
previousWorldTranslation.set(currentWorldTranslation);
}
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class AnimationFactory method getTranslationForFrame.
/**
* returns the translation for a given frame index
* creates the translation if it doesn't exists
* @param keyFrameIndex index
* @return the translation
*/
private Vector3f getTranslationForFrame(int keyFrameIndex) {
if (keyFrameIndex < 0 || keyFrameIndex > totalFrames) {
throw new ArrayIndexOutOfBoundsException("keyFrameIndex must be between 0 and " + totalFrames + " (received " + keyFrameIndex + ")");
}
Vector3f v = keyFramesTranslation[keyFrameIndex];
if (v == null) {
v = new Vector3f();
keyFramesTranslation[keyFrameIndex] = v;
}
return v;
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class ALAudioRenderer method setListenerParams.
private void setListenerParams(Listener listener) {
Vector3f pos = listener.getLocation();
Vector3f vel = listener.getVelocity();
Vector3f dir = listener.getDirection();
Vector3f up = listener.getUp();
al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z);
al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z);
fb.rewind();
fb.put(dir.x).put(dir.y).put(dir.z);
fb.put(up.x).put(up.y).put(up.z);
fb.flip();
al.alListener(AL_ORIENTATION, fb);
al.alListenerf(AL_GAIN, listener.getVolume());
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class ALAudioRenderer method updateListenerParam.
public void updateListenerParam(Listener listener, ListenerParam param) {
checkDead();
synchronized (threadLock) {
if (audioDisabled) {
return;
}
switch(param) {
case Position:
Vector3f pos = listener.getLocation();
al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z);
break;
case Rotation:
Vector3f dir = listener.getDirection();
Vector3f up = listener.getUp();
fb.rewind();
fb.put(dir.x).put(dir.y).put(dir.z);
fb.put(up.x).put(up.y).put(up.z);
fb.flip();
al.alListener(AL_ORIENTATION, fb);
break;
case Velocity:
Vector3f vel = listener.getVelocity();
al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z);
break;
case Volume:
al.alListenerf(AL_GAIN, listener.getVolume());
break;
}
}
}
use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.
the class BoundingBox method distanceToEdge.
public float distanceToEdge(Vector3f point) {
// compute coordinates of point in box coordinate system
TempVars vars = TempVars.get();
Vector3f closest = vars.vect1;
point.subtract(center, closest);
// project test point onto box
float sqrDistance = 0.0f;
float delta;
if (closest.x < -xExtent) {
delta = closest.x + xExtent;
sqrDistance += delta * delta;
closest.x = -xExtent;
} else if (closest.x > xExtent) {
delta = closest.x - xExtent;
sqrDistance += delta * delta;
closest.x = xExtent;
}
if (closest.y < -yExtent) {
delta = closest.y + yExtent;
sqrDistance += delta * delta;
closest.y = -yExtent;
} else if (closest.y > yExtent) {
delta = closest.y - yExtent;
sqrDistance += delta * delta;
closest.y = yExtent;
}
if (closest.z < -zExtent) {
delta = closest.z + zExtent;
sqrDistance += delta * delta;
closest.z = -zExtent;
} else if (closest.z > zExtent) {
delta = closest.z - zExtent;
sqrDistance += delta * delta;
closest.z = zExtent;
}
vars.release();
return FastMath.sqrt(sqrDistance);
}
Aggregations