Search in sources :

Example 16 with Vector3f

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);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 17 with Vector3f

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;
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 18 with Vector3f

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());
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 19 with Vector3f

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;
        }
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 20 with Vector3f

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);
}
Also used : TempVars(com.jme3.util.TempVars)

Aggregations

Vector3f (com.jme3.math.Vector3f)536 Material (com.jme3.material.Material)126 Geometry (com.jme3.scene.Geometry)118 DirectionalLight (com.jme3.light.DirectionalLight)95 Quaternion (com.jme3.math.Quaternion)94 TempVars (com.jme3.util.TempVars)67 ColorRGBA (com.jme3.math.ColorRGBA)64 Node (com.jme3.scene.Node)63 Spatial (com.jme3.scene.Spatial)57 Box (com.jme3.scene.shape.Box)57 Sphere (com.jme3.scene.shape.Sphere)51 Texture (com.jme3.texture.Texture)41 KeyTrigger (com.jme3.input.controls.KeyTrigger)36 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)35 Vector2f (com.jme3.math.Vector2f)35 FilterPostProcessor (com.jme3.post.FilterPostProcessor)34 FloatBuffer (java.nio.FloatBuffer)34 InputCapsule (com.jme3.export.InputCapsule)33 BoundingBox (com.jme3.bounding.BoundingBox)30 AmbientLight (com.jme3.light.AmbientLight)30