static void setSteamVRMatrix3ToMatrix4f(HmdMatrix34_t hmdMatrix, Matrix4f matrixToSet) { matrixToSet.set( hmdMatrix.m[0], hmdMatrix.m[4], hmdMatrix.m[8], 0, hmdMatrix.m[1], hmdMatrix.m[5], hmdMatrix.m[9], 0, hmdMatrix.m[2], hmdMatrix.m[6], hmdMatrix.m[10], 0, hmdMatrix.m[3], hmdMatrix.m[7], hmdMatrix.m[11], 1f ); }
/** * Get the projection matrix for an eye. * @param eyeIndex - An integer specifying the eye: 0 for the left eye, 1 for the right eye. * @return the projection matrix, as a Matrix4f. */ public Matrix4f getEyeProjectionMatrix(int eyeIndex) { return new Matrix4f(projectionMatrices[eyeIndex]); }
/** * Get the pose of an eye. * @param eyeIndex - An integer specifying the eye: 0 for the left eye, 1 for the right eye. * @return the pose, as a Matrix4f */ public Matrix4f getEyePose(int eyeIndex) { Matrix4f matrixReturn = new Matrix4f(headPose); matrixReturn.mul(eyePoses[eyeIndex]); return matrixReturn; }
private void jomlMatrix4f(org.joml.Matrix4f matrixInput, org.terasology.math.geom.Matrix4f matrixOut) { matrixOut.set(0, 0, matrixInput.m00()); matrixOut.set(0, 1, matrixInput.m10()); matrixOut.set(0, 2, matrixInput.m20()); matrixOut.set(0, 3, matrixInput.m30()); matrixOut.set(1, 0, matrixInput.m01()); matrixOut.set(1, 1, matrixInput.m11()); matrixOut.set(1, 2, matrixInput.m21()); matrixOut.set(1, 3, matrixInput.m31()); matrixOut.set(2, 0, matrixInput.m02()); matrixOut.set(2, 1, matrixInput.m12()); matrixOut.set(2, 2, matrixInput.m22()); matrixOut.set(2, 3, matrixInput.m32()); matrixOut.set(3, 0, matrixInput.m03()); matrixOut.set(3, 1, matrixInput.m13()); matrixOut.set(3, 2, matrixInput.m23()); matrixOut.set(3, 3, matrixInput.m33()); }
/** * A callback target for the controller listener. When this callback triggers, the pos of the mount point will * cuange to the value of the pose parameter. This is mainly designed as a callback, and not intended to be part * of the public interface of this class. * @param pose - the controller pose - a homogenous transformation matrix. * @param handIndex - the hand index - 0 for left and 1 for right. */ public void poseChanged(Matrix4f pose, int handIndex) { // do nothing for the second controller // TODO: put a hand for the second controller. if (handIndex != 0) { return; } trackingDataReceived = true; Matrix4f adjustedPose = pose.mul(toolAdjustmentMatrix); translate = new Vector3f(adjustedPose.m30(), adjustedPose.m31(), adjustedPose.m32()); org.joml.Vector4f jomlQuaternion = org.terasology.rendering.openvrprovider.OpenVRUtil.convertToQuaternion(adjustedPose); if (rotationQuaternion == null) { rotationQuaternion = new Quat4f(jomlQuaternion.x, jomlQuaternion.y, jomlQuaternion.z, jomlQuaternion.w); } else { rotationQuaternion.set(jomlQuaternion.x, jomlQuaternion.y, jomlQuaternion.z, jomlQuaternion.w); } } }
org.joml.Matrix4f leftEyePose = vrProvider.getState().getEyePose(0); org.joml.Matrix4f rightEyePose = vrProvider.getState().getEyePose(1); float halfIPD = (float) Math.sqrt(Math.pow(leftEyePose.m30() - rightEyePose.m30(), 2) + Math.pow(leftEyePose.m31() - rightEyePose.m31(), 2) + Math.pow(leftEyePose.m32() - rightEyePose.m32(), 2)) / 2.0f; Quaternionf quaternion = new Quaternionf(vecQuaternion.x, vecQuaternion.y, vecQuaternion.z, vecQuaternion.w); setOrientation(new Quat4f(quaternion.x, quaternion.y, quaternion.z, quaternion.w)); leftEyePose = leftEyePose.invert(); // view matrix is inverse of pose matrix rightEyePose = rightEyePose.invert(); if (Math.sqrt(Math.pow(leftEyePose.m30(), 2) + Math.pow(leftEyePose.m31(), 2) + Math.pow(leftEyePose.m32(), 2)) < 0.25) { return;
public Matrix4x3f shadow(Vector4fc light, Matrix4x3fc planeTransform, Matrix4x3f dest) { // compute plane equation by transforming (y = 0) float a = planeTransform.m10(); float b = planeTransform.m11(); float c = planeTransform.m12(); float d = -a * planeTransform.m30() - b * planeTransform.m31() - c * planeTransform.m32(); return shadow(light.x(), light.y(), light.z(), light.w(), a, b, c, d, dest); }
public Matrix4d shadow(Vector4dc light, Matrix4dc planeTransform, Matrix4d dest) { // compute plane equation by transforming (y = 0) double a = planeTransform.m10(); double b = planeTransform.m11(); double c = planeTransform.m12(); double d = -a * planeTransform.m30() - b * planeTransform.m31() - c * planeTransform.m32(); return shadow(light.x(), light.y(), light.z(), light.w(), a, b, c, d, dest); }
public Matrix4x3d reflect(Quaterniondc orientation, Vector3dc point, Matrix4x3d dest) { double num1 = orientation.x() + orientation.x(); double num2 = orientation.y() + orientation.y(); double num3 = orientation.z() + orientation.z(); double normalX = orientation.x() * num3 + orientation.w() * num2; double normalY = orientation.y() * num3 - orientation.w() * num1; double normalZ = 1.0 - (orientation.x() * num1 + orientation.y() * num2); return reflect(normalX, normalY, normalZ, point.x(), point.y(), point.z(), dest); }
public Matrix4f reflect(Quaternionfc orientation, Vector3fc point, Matrix4f dest) { double num1 = orientation.x() + orientation.x(); double num2 = orientation.y() + orientation.y(); double num3 = orientation.z() + orientation.z(); float normalX = (float) (orientation.x() * num3 + orientation.w() * num2); float normalY = (float) (orientation.y() * num3 - orientation.w() * num1); float normalZ = (float) (1.0 - (orientation.x() * num1 + orientation.y() * num2)); return reflect(normalX, normalY, normalZ, point.x(), point.y(), point.z(), dest); }
public Matrix4d reflect(Quaterniondc orientation, Vector3dc point, Matrix4d dest) { double num1 = orientation.x() + orientation.x(); double num2 = orientation.y() + orientation.y(); double num3 = orientation.z() + orientation.z(); double normalX = orientation.x() * num3 + orientation.w() * num2; double normalY = orientation.y() * num3 - orientation.w() * num1; double normalZ = 1.0 - (orientation.x() * num1 + orientation.y() * num2); return reflect(normalX, normalY, normalZ, point.x(), point.y(), point.z(), dest); }
static Matrix4f createIdentityMatrix4f() { return new Matrix4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } }
static void setSteamVRMatrix44ToMatrix4f(HmdMatrix44_t hmdMatrix, Matrix4f matrixToSet) { matrixToSet.set( hmdMatrix.m[0], hmdMatrix.m[4], hmdMatrix.m[8], hmdMatrix.m[12], hmdMatrix.m[1], hmdMatrix.m[5], hmdMatrix.m[9], hmdMatrix.m[13], hmdMatrix.m[2], hmdMatrix.m[6], hmdMatrix.m[10], hmdMatrix.m[14], hmdMatrix.m[3], hmdMatrix.m[7], hmdMatrix.m[11], hmdMatrix.m[15] ); }
void setControllerPose(HmdMatrix34_t inputPose, int nIndex) { OpenVRUtil.setSteamVRMatrix3ToMatrix4f(inputPose, controllerPose[nIndex]); controllerPose[nIndex] = new Matrix4f( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, groundPlaneYOffset, 0, 1 ).mul(controllerPose[nIndex]); for (ControllerListener listener : controllerListeners) { listener.poseChanged(controllerPose[nIndex], nIndex); } }