/// <summary> /// Provides the position of a Leap Anchor at a given Leap Time. Cannot extrapolate. /// </summary> public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation, long leapTime) { if (_trackingAnchor == null) { rewoundPosition = Vector3.one; rewoundRotation = Quaternion.identity; return(false); } TransformData past = transformAtTime(leapTime); // Rewind position and rotation rewoundRotation = _trackingAnchor.rotation * past.localRotation; rewoundPosition = _trackingAnchor.TransformPoint(past.localPosition) + rewoundRotation * Vector3.forward * deviceInfo.focalPlaneOffset; switch (anchor) { case WarpedAnchor.CENTER: break; case WarpedAnchor.LEFT: rewoundPosition += rewoundRotation * Vector3.left * deviceInfo.baseline * 0.5f; break; case WarpedAnchor.RIGHT: rewoundPosition += rewoundRotation * Vector3.right * deviceInfo.baseline * 0.5F; break; default: throw new Exception("Unexpected Rewind Type " + anchor); } return(true); }
/// <summary> /// Provides the position of a Leap Anchor at a given Leap Time. Cannot extrapolate. /// </summary> public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation, long leapTime) { // Operation is only valid if we have a head transform. if (_headTransform == null) { rewoundPosition = Vector3.one; rewoundRotation = Quaternion.identity; return(false); } // Prepare past transform data. TransformData past = transformAtTime((leapTime - warpingAdjustment * 1000) + (_syncMode == SyncMode.SYNC_WITH_IMAGES ? 20000 : 0)); // Prepare device offset parameters. Quaternion deviceTilt = Quaternion.Euler(deviceTiltXAxis, 0f, 0f); Vector3 deviceOffset = new Vector3(0f, deviceOffsetYAxis, deviceOffsetZAxis).CompMul(this.transform.lossyScale); // TODO: We no longer use deviceInfo.forwardOffset. We should consider removing it // entirely or more approrpriately when we collapse the rig hierarchy. 9/1/17 // Rewind position and rotation. if (_trackingAnchor == null) { rewoundRotation = past.localRotation * deviceTilt; rewoundPosition = past.localPosition + rewoundRotation * deviceOffset; } else { rewoundRotation = _trackingAnchor.rotation * past.localRotation * deviceTilt; rewoundPosition = _trackingAnchor.TransformPoint(past.localPosition) + rewoundRotation * deviceOffset; } // Move position if we are left-eye-only or right-eye-only. switch (anchor) { case WarpedAnchor.CENTER: break; case WarpedAnchor.LEFT: rewoundPosition += rewoundRotation * Vector3.left * _deviceInfo.baseline * 0.5f; break; case WarpedAnchor.RIGHT: rewoundPosition += rewoundRotation * Vector3.right * _deviceInfo.baseline * 0.5f; break; default: throw new Exception("Unexpected Rewind Type " + anchor); } return(true); }
public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation) { long timestamp = provider.imageTimeStamp; if (TryGetWarpedTransform(anchor, out rewoundPosition, out rewoundRotation, timestamp)) { return(true); } rewoundPosition = Vector3.zero; rewoundRotation = Quaternion.identity; return(false); }
public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation) { long timestamp = HandController.Main.GetFrame().Timestamp; if (TryGetWarpedTransform(anchor, out rewoundPosition, out rewoundRotation, timestamp)) { return(true); } rewoundPosition = Vector3.zero; rewoundRotation = Quaternion.identity; return(false); }
public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation) { long timestamp = provider.CurrentFrame.Timestamp; if (TryGetWarpedTransform(anchor, out rewoundPosition, out rewoundRotation, timestamp)) { return true; } rewoundPosition = Vector3.zero; rewoundRotation = Quaternion.identity; return false; }
/// <summary> /// Provides the position of a Leap Anchor at a given Leap Time. Cannot extrapolate. /// </summary> public bool TryGetWarpedTransform(WarpedAnchor anchor, out Vector3 rewoundPosition, out Quaternion rewoundRotation, long leapTime) { if (_headTransform == null) { rewoundPosition = Vector3.one; rewoundRotation = Quaternion.identity; return false; } TransformData past = transformAtTime(leapTime - warpingAdjustment * 1000); // Rewind position and rotation if (_trackingAnchor == null) { rewoundRotation = past.localRotation; rewoundPosition = past.localPosition + rewoundRotation * Vector3.forward * deviceInfo.focalPlaneOffset; } else { rewoundRotation = _trackingAnchor.rotation * past.localRotation; rewoundPosition = _trackingAnchor.TransformPoint(past.localPosition) + rewoundRotation * Vector3.forward * deviceInfo.focalPlaneOffset; } switch (anchor) { case WarpedAnchor.CENTER: break; case WarpedAnchor.LEFT: rewoundPosition += rewoundRotation * Vector3.left * deviceInfo.baseline * 0.5f; break; case WarpedAnchor.RIGHT: rewoundPosition += rewoundRotation * Vector3.right * deviceInfo.baseline * 0.5F; break; default: throw new Exception("Unexpected Rewind Type " + anchor); } return true; }