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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations