void Start()
        {
            if (UnityEngine.XR.XRDevice.isPresent)
            {
                var oldOrigin = MixCast.Settings.oculusOrigin;
                var newOrigin = TrackingSpaceOrigin.GetOriginOffsetData();

                //Debug.Log("Old: " + oldOrigin);
                //Debug.Log("New: " + newOrigin);

                if (WasOriginChanged(oldOrigin, newOrigin))
                {
                    Debug.Log("MixCast: Tracking Space Origin change detected! All cameras will reset to default positions.");

                    if (handle == ChangeHandle.ResetPositions)
                    {
                        ResetCamerasPosition();
                    }
                    else
                    {
                        ApplyNewOffsetToSettings(oldOrigin, newOrigin);
                    }

                    SaveSettings(newOrigin);
                }
            }
        }
        public bool GetDeviceTransformByIndex_SteamVR(int index, out Vector3 position, out Quaternion rotation)
        {
            if (index < 0 || index >= trackedObjects.Length)
            {
                position = Vector3.zero;
                rotation = Quaternion.identity;
                return(false);
            }

            TrackedDevicePose_t pose = trackedObjects[index];

            if (pose.bDeviceIsConnected && pose.bPoseIsValid && pose.eTrackingResult == ETrackingResult.Running_OK)
            {
                Matrix4x4 poseMat = TrackingSpaceOrigin.ConvertMatrixOpenVRToUnity(pose.mDeviceToAbsoluteTracking);
                position    = TrackingSpaceOrigin.ExtractPosition(poseMat);
                position.z *= -1;   //flip for OpenGL to DirectX conversion
                Quaternion quat = TrackingSpaceOrigin.ExtractRotation(poseMat);
                quat     = Quaternion.Euler(new Vector3(-quat.eulerAngles.x, -quat.eulerAngles.y, quat.eulerAngles.z));
                rotation = quat;
                return(true);
            }
            else
            {
                position = Vector3.zero;
                rotation = Quaternion.identity;
                return(false);
            }
        }
Пример #3
0
        private void SetTransformFromOldPoseToNewPose(MixCastData.SensorPose oldPose, Vector3 newPos, Quaternion newRot)
        {
            Vector3    pos;
            Quaternion rot;

            TrackingSpaceOrigin.GetOriginOffsetData(newPos, newRot, oldPose.position, oldPose.rotation, out pos, out rot);

            transform.localPosition = cachedPosition + pos;
            //Remove orientation change for the camera. Will remove for next release.
            //transform.localRotation = cachedRotation * rot;
        }