protected override void Start() { base.Start(); if (_deviceOffsetMode == DeviceOffsetMode.Transform && _deviceOrigin == null) { Debug.LogError("Cannot use the Transform device offset mode without " + "specifying a Transform to use as the device origin.", this); _deviceOffsetMode = DeviceOffsetMode.Default; } if (Application.isPlaying && _mainCamera == null && _temporalWarpingMode != TemporalWarpingMode.Off) { Debug.LogError("Cannot perform temporal warping with no pre-cull camera."); } //Get the local tracked pose from the XR Headset so we can calculate the _trackingBaseDeltaPose from it var trackedPose = new Pose(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); //Find the pose delta from the "local" tracked pose to the actual camera pose, we will use this later on to maintain offsets if (!_trackingBaseDeltaPose.HasValue) { _trackingBaseDeltaPose = _mainCamera.transform.ToLocalPose().mul(trackedPose.inverse()); } }
void OnPreCull() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif // Get most recent tracked pose. Pose trackedPose = new Pose(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); // BEGIN EDIT YUJIN if (_useLocalTracking) { trackedPose = new Pose(transform.localPosition, transform.localRotation); } // END EDIT YUJIN // If we don't know of any pose offset yet, account for it by finding the pose // delta from the "local" tracked pose to the actual camera pose. if (!_trackingBaseDeltaPose.HasValue) { _trackingBaseDeltaPose = _cachedCamera.transform.ToLocalPose() * trackedPose.inverse; } // This way, we always track a scene-space tracked pose. Pose effTransformPose = _trackingBaseDeltaPose.Value * trackedPose; transformHistory.UpdateDelay(effTransformPose, _leapController.Now()); OnPreCullHandTransforms(_cachedCamera); }
protected void LateUpdate() { if (_forceCustomUpdate) { ManuallyUpdateTemporalWarping(); } else if (XRSupportUtil.IsXREnabled()) { updateTemporalWarping(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } }
protected virtual void onPreCull(Camera preCullingCamera) { if (preCullingCamera != preCullCamera) { return; } #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif Pose trackedPose; if (_deviceOffsetMode == DeviceOffsetMode.Default || _deviceOffsetMode == DeviceOffsetMode.ManualHeadOffset) { // Get most recent tracked pose from the XR subsystem. trackedPose = new Pose(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); // If we don't know of any pose offset yet, account for it by finding // the pose delta from the "local" tracked pose to the actual camera // pose. if (!_trackingBaseDeltaPose.HasValue) { _trackingBaseDeltaPose = _cachedCamera.transform.ToLocalPose() * trackedPose.inverse; } // This way, we always track a scene-space tracked pose. trackedPose = _trackingBaseDeltaPose.Value * trackedPose; } else if (_deviceOffsetMode == DeviceOffsetMode.Transform) { trackedPose = deviceOrigin.ToPose(); } else { Debug.LogError("Unsupported DeviceOffsetMode: " + _deviceOffsetMode); return; } transformHistory.UpdateDelay(trackedPose, _leapController.Now()); OnPreCullHandTransforms(_cachedCamera); }
protected virtual void onPreCull(Camera preCullingCamera) { if (preCullingCamera != _mainCamera) { return; } #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif if (_mainCamera == null || _leapController == null) { if (_temporalWarpingMode == TemporalWarpingMode.Auto || _temporalWarpingMode == TemporalWarpingMode.Manual) { Debug.LogError("The camera or controller need to be set for temporal warping to work"); } return; } Pose trackedPose; if (_deviceOffsetMode == DeviceOffsetMode.Default || _deviceOffsetMode == DeviceOffsetMode.ManualHeadOffset) { //Get the local tracked pose from the XR Headset trackedPose = new Pose(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); //Use the _trackingBaseDeltaPose calculated on start to convert the local spaced trackedPose into a world space position trackedPose = _trackingBaseDeltaPose.Value.mul(trackedPose); } else if (_deviceOffsetMode == DeviceOffsetMode.Transform) { trackedPose = deviceOrigin.ToPose(); } else { Debug.LogError($"Unsupported DeviceOffsetMode: {_deviceOffsetMode}"); return; } transformHistory.UpdateDelay(trackedPose, _leapController.Now()); OnPreCullHandTransforms(_mainCamera); }
private void onValidCameraParams(LeapVRCameraControl.CameraParams cameraParams) { _projectionMatrix = cameraParams.ProjectionMatrix; if (XRSupportUtil.IsXREnabled()) { if (provider != null) { updateHistory(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } if (_syncMode == SyncMode.LOW_LATENCY) { updateTemporalWarping(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } } }