private void setViewportProjection(MeshRenderer viewport, MPPProjection projection) { if (viewport == null) { return; } viewport.material.SetVector("_Projection", new Vector4(projection.left, projection.top, projection.right, projection.bottom)); }
private double calcProjectionCoverage(Quaternion subjectOrientation, MPPProjection subjectProj, Quaternion clippingOrientation, MPPProjection clippingProj) { const float Scale = 100000; var deltaRotation = Quaternion.Inverse(subjectOrientation) * clippingOrientation; var subjectPath = subjectProj.GetProjectionPath(Scale); var clippingPath = rotatePath(clippingProj.GetProjectionPath(Scale), deltaRotation, Scale); return(calcCoverage(subjectPath, clippingPath)); }
private float calcRadiiArea(MPPProjection projection, float radius) { var overflow_l = calcOverflowedSideArea(radius, -projection.left); var overflow_t = calcOverflowedSideArea(radius, projection.top); var overflow_r = calcOverflowedSideArea(radius, projection.right); var overflow_b = calcOverflowedSideArea(radius, -projection.bottom); var overflow_lt = calcOverflowedCornerArea(radius, -projection.left, projection.top); var overflow_rt = calcOverflowedCornerArea(radius, projection.right, projection.top); var overflow_rb = calcOverflowedCornerArea(radius, projection.right, -projection.bottom); var overflow_lb = calcOverflowedCornerArea(radius, -projection.left, -projection.bottom); return(Mathf.PI * radius * radius - (overflow_l + overflow_t + overflow_r + overflow_b) + (overflow_lt + overflow_rt + overflow_rb + overflow_lb)); }
public static MPPProjection calcOptimalOverfilling(Quaternion headRotation, Quaternion frameRotation, MPPProjection eyeProjection) { var q_delta = Quaternion.Inverse(frameRotation) * headRotation; var p_lt = q_delta * new Vector3(eyeProjection.left, eyeProjection.top, 1.0f); p_lt /= p_lt.z; var p_rt = q_delta * new Vector3(eyeProjection.right, eyeProjection.top, 1.0f); p_rt /= p_rt.z; var p_rb = q_delta * new Vector3(eyeProjection.right, eyeProjection.bottom, 1.0f); p_rb /= p_rb.z; var p_lb = q_delta * new Vector3(eyeProjection.left, eyeProjection.bottom, 1.0f); p_lb /= p_lb.z; var p_l = Mathf.Min(p_lt.x, p_rt.x, p_rb.x, p_lb.x); var p_t = Mathf.Max(p_lt.y, p_rt.y, p_rb.y, p_lb.y); var p_r = Mathf.Max(p_lt.x, p_rt.x, p_rb.x, p_lb.x); var p_b = Mathf.Min(p_lt.y, p_rt.y, p_rb.y, p_lb.y); return(new MPPProjection { left = Mathf.Min(p_l, eyeProjection.left), top = Mathf.Max(p_t, eyeProjection.top), right = Mathf.Max(p_r, eyeProjection.right), bottom = Mathf.Min(p_b, eyeProjection.bottom) }); }
public void SetProjection(MPPProjection eyeProjection, MPPProjection frameProjection) { setViewportProjection(eyeViewport, eyeProjection); setViewportProjection(frameViewport, eyeProjection); setViewportProjection(frameBorder, frameProjection); }
public void Update() { if (_owner.bypassPrediction) { leftProjection = rightProjection = Rect.MinMaxRect(-1, -1, 1, 1); return; } if (_zmqPredictedMotion == null) { return; } _prevExternalInputActualPress = externalInputActualPress; _prevExternalInputPredictivePress = externalInputPredictivePress; while (_zmqPredictedMotion.TryReceive(ref _msgRecv, TimeSpan.Zero)) { if (_msgRecv.Size <= 0) { continue; } if (BitConverter.IsLittleEndian) { Array.Reverse(_msgRecv.Data, 0, 8); for (int i = 0; i < 49; i++) { Array.Reverse(_msgRecv.Data, 8 + i * 4, 4); } } int pos = 0; timestamp = getLong(_msgRecv.Data, ref pos); predictionTime = getFloat(_msgRecv.Data, ref pos); var inputLeftEyePosition = getPosition(_msgRecv.Data, ref pos); var inputRightEyePosition = getPosition(_msgRecv.Data, ref pos); var inputHeadOrientation = getRotation(_msgRecv.Data, ref pos); var inputProjection = getProjection(_msgRecv.Data, ref pos); var inputRightHandPose = new Pose(getPosition(_msgRecv.Data, ref pos), getRotation(_msgRecv.Data, ref pos)); var leftEyePosition = getPosition(_msgRecv.Data, ref pos); var rightEyePosition = getPosition(_msgRecv.Data, ref pos); var headOrientation = getRotation(_msgRecv.Data, ref pos); leftEye = new Pose(leftEyePosition, headOrientation); rightEye = new Pose(rightEyePosition, headOrientation); leftProjection = getProjection(_msgRecv.Data, ref pos); rightProjection = getProjection(_msgRecv.Data, ref pos); foveationInnerRadius = getFloat(_msgRecv.Data, ref pos); foveationMiddleRadius = getFloat(_msgRecv.Data, ref pos); rightHand = new Pose(getPosition(_msgRecv.Data, ref pos), getRotation(_msgRecv.Data, ref pos)); externalInputId = getUshort(_msgRecv.Data, ref pos); var actualPress = getBool(_msgRecv.Data, ref pos); var predictedPress = getBool(_msgRecv.Data, ref pos); if (_prevExternalInputActualPress != actualPress) { externalInputActualPress = actualPress; } if (_prevExternalInputPredictivePress != predictedPress) { externalInputPredictivePress = predictedPress; } _motionDataProvider.Put(timestamp, predictionTime, new Pose(inputLeftEyePosition, inputHeadOrientation), new Pose(inputRightEyePosition, inputHeadOrientation), MPPProjection.FromRect(inputProjection), inputRightHandPose, leftEye, rightEye, MPPProjection.FromRect(leftProjection), MPPProjection.FromRect(rightProjection), foveationInnerRadius, foveationMiddleRadius, rightHand); } }