Search in sources :

Example 6 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method compose.

public TRSRTransformation compose(TRSRTransformation b) {
    Matrix4f m = getMatrix();
    m.mul(b.getMatrix());
    return new TRSRTransformation(m);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 7 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method mul.

public static Matrix4f mul(@Nullable Vector3f translation, @Nullable Quat4f leftRot, @Nullable Vector3f scale, @Nullable Quat4f rightRot) {
    Matrix4f res = new Matrix4f(), t = new Matrix4f();
    res.setIdentity();
    if (leftRot != null) {
        t.set(leftRot);
        res.mul(t);
    }
    if (scale != null) {
        t.setIdentity();
        t.m00 = scale.x;
        t.m11 = scale.y;
        t.m22 = scale.z;
        res.mul(t);
    }
    if (rightRot != null) {
        t.set(rightRot);
        res.mul(t);
    }
    if (translation != null)
        res.setTranslation(translation);
    return res;
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 8 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method isInteger.

public static boolean isInteger(Matrix4f matrix) {
    Matrix4f m = new Matrix4f();
    m.setIdentity();
    m.m30 = m.m31 = m.m32 = 1;
    m.m33 = 0;
    m.mul(matrix, m);
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            float v = m.getElement(i, j) / m.getElement(3, j);
            if (Math.abs(v - Math.round(v)) > 1e-5)
                return false;
        }
    }
    return true;
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 9 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method blockCenterToCorner.

/**
     * convert transformation from assuming center-block system to corner-block system
     */
public static TRSRTransformation blockCenterToCorner(TRSRTransformation transform) {
    Matrix4f ret = new Matrix4f(transform.getMatrix()), tmp = new Matrix4f();
    tmp.setIdentity();
    tmp.m03 = tmp.m13 = tmp.m23 = .5f;
    ret.mul(tmp, ret);
    tmp.m03 = tmp.m13 = tmp.m23 = -.5f;
    ret.mul(tmp);
    return new TRSRTransformation(ret);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 10 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method inverse.

public TRSRTransformation inverse() {
    if (this == identity)
        return this;
    Matrix4f m = getMatrix();
    m.invert();
    return new TRSRTransformation(m);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Aggregations

Matrix4f (javax.vecmath.Matrix4f)27 Vector3f (javax.vecmath.Vector3f)9 Matrix3f (javax.vecmath.Matrix3f)3 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)3 Matrix4 (com.badlogic.gdx.math.Matrix4)2 Vector3 (com.badlogic.gdx.math.Vector3)2 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)2 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 Transform (com.bulletphysics.linearmath.Transform)2 Mesh (com.nilunder.bdx.gl.Mesh)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)1 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 Model (com.badlogic.gdx.graphics.g3d.Model)1 MeshPart (com.badlogic.gdx.graphics.g3d.model.MeshPart)1 Node (com.badlogic.gdx.graphics.g3d.model.Node)1 NodePart (com.badlogic.gdx.graphics.g3d.model.NodePart)1 MeshPartBuilder (com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)1 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)1