Example usage for com.badlogic.gdx.math Matrix4 M31

List of usage examples for com.badlogic.gdx.math Matrix4 M31

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Matrix4 M31.

Prototype

int M31

To view the source code for com.badlogic.gdx.math Matrix4 M31.

Click Source Link

Document

WY: Typically the value zero.

Usage

From source file:MeshBoneUtil.dualQuat.java

License:Open Source License

public void convertToMat(Matrix4 m) {
    float cur_length = (float) real.dot(real);
    float w = (float) real.w, x = (float) real.x, y = (float) real.y, z = (float) real.z;
    float t0 = (float) imaginary.w, t1 = (float) imaginary.x, t2 = (float) imaginary.y,
            t3 = (float) imaginary.z;

    m.val[Matrix4.M01] = w * w + x * x - y * y - z * z;
    m.val[Matrix4.M02] = 2 * x * y - 2 * w * z;
    m.val[Matrix4.M03] = 2 * x * z + 2 * w * y;

    m.val[Matrix4.M11] = 2 * x * y + 2 * w * z;
    m.val[Matrix4.M12] = w * w + y * y - x * x - z * z;
    m.val[Matrix4.M13] = 2 * y * z - 2 * w * x;

    m.val[Matrix4.M21] = 2 * x * z - 2 * w * y;
    m.val[Matrix4.M22] = 2 * y * z + 2 * w * x;
    m.val[Matrix4.M23] = w * w + z * z - x * x - y * y;

    m.val[Matrix4.M31] = -2 * t0 * x + 2 * w * t1 - 2 * t2 * z + 2 * y * t3;
    m.val[Matrix4.M32] = -2 * t0 * y + 2 * t1 * z - 2 * x * t3 + 2 * w * t2;
    m.val[Matrix4.M33] = -2 * t0 * z + 2 * x * t2 + 2 * w * t3 - 2 * t1 * y;

    // ??//from   w  ww  .  j a  v a2s  .c  o m
    m.val[Matrix4.M03] = 0;
    m.val[Matrix4.M13] = 0;
    m.val[Matrix4.M23] = 0;
    m.val[Matrix4.M33] = cur_length;

    for (int i = 0; i < 16; i++) {
        m.val[i] /= cur_length;
    }
    //m /= cur_length;
}

From source file:ve.ucv.ciens.ccg.nxtar.graphics.CustomPerspectiveCamera.java

License:Apache License

public void setCustomARProjectionMatrix(final float focalPointX, final float focalPointY,
        final float cameraCenterX, final float cameraCenterY, final float near, final float far, final float w,
        final float h) {
    final float FAR_PLUS_NEAR = far + near;
    final float FAR_LESS_NEAR = far - near;

    projection.val[Matrix4.M00] = -2.0f * focalPointX / w;
    projection.val[Matrix4.M10] = 0.0f;
    projection.val[Matrix4.M20] = 0.0f;
    projection.val[Matrix4.M30] = 0.0f;

    projection.val[Matrix4.M01] = 0.0f;
    projection.val[Matrix4.M11] = 2.0f * focalPointY / h;
    projection.val[Matrix4.M21] = 0.0f;
    projection.val[Matrix4.M31] = 0.0f;

    projection.val[Matrix4.M02] = 2.0f * cameraCenterX / w - 1.0f;
    projection.val[Matrix4.M12] = 2.0f * cameraCenterY / h - 1.0f;
    projection.val[Matrix4.M22] = -FAR_PLUS_NEAR / FAR_LESS_NEAR;
    projection.val[Matrix4.M32] = -1.0f;

    projection.val[Matrix4.M03] = 0.0f;
    projection.val[Matrix4.M13] = 0.0f;
    projection.val[Matrix4.M23] = -2.0f * far * near / FAR_LESS_NEAR;
    projection.val[Matrix4.M33] = 0.0f;
}

From source file:ve.ucv.ciens.ccg.nxtar.systems.GeometrySystem.java

License:Apache License

private void applyWorldTransform(ModelInstance model, GeometryComponent geometry) {
    translationMatrix.setToTranslation(geometry.position);

    rotationMatrix.val[Matrix4.M00] = geometry.rotation.val[0];
    rotationMatrix.val[Matrix4.M10] = geometry.rotation.val[1];
    rotationMatrix.val[Matrix4.M20] = geometry.rotation.val[2];
    rotationMatrix.val[Matrix4.M30] = 0;

    rotationMatrix.val[Matrix4.M01] = geometry.rotation.val[3];
    rotationMatrix.val[Matrix4.M11] = geometry.rotation.val[4];
    rotationMatrix.val[Matrix4.M21] = geometry.rotation.val[5];
    rotationMatrix.val[Matrix4.M31] = 0;

    rotationMatrix.val[Matrix4.M02] = geometry.rotation.val[6];
    rotationMatrix.val[Matrix4.M12] = geometry.rotation.val[7];
    rotationMatrix.val[Matrix4.M22] = geometry.rotation.val[8];
    rotationMatrix.val[Matrix4.M32] = 0;

    rotationMatrix.val[Matrix4.M03] = 0;
    rotationMatrix.val[Matrix4.M13] = 0;
    rotationMatrix.val[Matrix4.M23] = 0;
    rotationMatrix.val[Matrix4.M33] = 1;

    scalingMatrix.setToScaling(geometry.scaling);

    model.transform.idt().mul(translationMatrix).mul(rotationMatrix).mul(scalingMatrix);
    model.calculateTransforms();/*from w w  w  . j a v a  2 s  . co  m*/
}