Search in sources :

Example 51 with Matrix4f

use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformVerts.

private static void doTransformVerts(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f pos = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        pos.x = inBuf.get(i * 3 + 0);
        pos.y = inBuf.get(i * 3 + 1);
        pos.z = inBuf.get(i * 3 + 2);
        transform.mult(pos, pos);
        outBuf.put(offset + i * 3 + 0, pos.x);
        outBuf.put(offset + i * 3 + 1, pos.y);
        outBuf.put(offset + i * 3 + 2, pos.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 52 with Matrix4f

use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformTangents.

private static void doTransformTangents(FloatBuffer inBuf, int offset, int components, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f tan = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= components;
    for (int i = 0; i < inBuf.limit() / components; i++) {
        tan.x = inBuf.get(i * components + 0);
        tan.y = inBuf.get(i * components + 1);
        tan.z = inBuf.get(i * components + 2);
        transform.multNormal(tan, tan);
        outBuf.put(offset + i * components + 0, tan.x);
        outBuf.put(offset + i * components + 1, tan.y);
        outBuf.put(offset + i * components + 2, tan.z);
        if (components == 4) {
            outBuf.put(offset + i * components + 3, inBuf.get(i * components + 3));
        }
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 53 with Matrix4f

use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformNorms.

private static void doTransformNorms(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f norm = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        norm.x = inBuf.get(i * 3 + 0);
        norm.y = inBuf.get(i * 3 + 1);
        norm.z = inBuf.get(i * 3 + 2);
        transform.multNormal(norm, norm);
        outBuf.put(offset + i * 3 + 0, norm.x);
        outBuf.put(offset + i * 3 + 1, norm.y);
        outBuf.put(offset + i * 3 + 2, norm.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 54 with Matrix4f

use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowFilterVR method preFrame.

@Override
protected void preFrame(float tpf) {
    shadowRenderer.preFrame(tpf);
    material.setMatrix4("ViewProjectionMatrixInverse", viewPort.getCamera().getViewProjectionMatrix().invert());
    Matrix4f m = viewPort.getCamera().getViewProjectionMatrix();
    material.setVector4("ViewProjectionMatrixRow2", tmpv.set(m.m20, m.m21, m.m22, m.m23));
}
Also used : Matrix4f(com.jme3.math.Matrix4f)

Example 55 with Matrix4f

use of com.jme3.math.Matrix4f in project jmonkeyengine by jMonkeyEngine.

the class OSVR method getHMDMatrixProjectionRightEye.

@Override
public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) {
    if (eyeRightInfo == null)
        return cam.getProjectionMatrix();
    if (eyeMatrix[EYE_RIGHT] == null) {
        FloatBuffer tfb = FloatBuffer.allocate(16);
        com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte) EYE_RIGHT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short) 0, tfb);
        eyeMatrix[EYE_RIGHT] = new Matrix4f();
        eyeMatrix[EYE_RIGHT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15));
    }
    return eyeMatrix[EYE_RIGHT];
}
Also used : Matrix4f(com.jme3.math.Matrix4f) FloatBuffer(java.nio.FloatBuffer)

Aggregations

Matrix4f (com.jme3.math.Matrix4f)36 TempVars (com.jme3.util.TempVars)24 Vector3f (com.jme3.math.Vector3f)15 FloatBuffer (java.nio.FloatBuffer)7 BoundingBox (com.jme3.bounding.BoundingBox)6 Transform (com.jme3.math.Transform)6 Bone (com.jme3.animation.Bone)4 CollisionResult (com.jme3.collision.CollisionResult)3 Spatial (com.jme3.scene.Spatial)3 BoundingVolume (com.jme3.bounding.BoundingVolume)2 Material (com.jme3.material.Material)2 Quaternion (com.jme3.math.Quaternion)2 Geometry (com.jme3.scene.Geometry)2 BoneContext (com.jme3.scene.plugins.blender.animations.BoneContext)2 Structure (com.jme3.scene.plugins.blender.file.Structure)2 FbxId (com.jme3.scene.plugins.fbx.file.FbxId)2 FrameBuffer (com.jme3.texture.FrameBuffer)2 Texture2D (com.jme3.texture.Texture2D)2 Picture (com.jme3.ui.Picture)2 ByteBuffer (java.nio.ByteBuffer)2