Esempio n. 1
0
 void Start()
 {
     if (VRInfo.IsDeviceOculus())
     {
         OffsetTransform();
     }
 }
Esempio n. 2
0
        public bool GetDeviceTransformByRole(DeviceRole role, out Vector3 position, out Quaternion rotation)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(GetDeviceTransformByRole_SteamVR(role, out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                return(GetDeviceTransformByRole_Oculus(role, out position, out rotation));
            }
#endif

            if (Application.isEditor)
            {
                position = Camera.main.transform.localPosition;
                rotation = Camera.main.transform.localRotation;
                return(true);
            }

            position = Vector3.zero;
            rotation = Quaternion.identity;
            return(false);
        }
Esempio n. 3
0
        public bool IsSensorAvailable(int requestIndex)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(IsSteamSensorAvailable(requestIndex));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                return(IsOculusSensorAvailable(requestIndex));
            }
#endif
            Debug.LogError(UNKNOWN_MESSAGE);
            return(false);
        }
        public bool GetTrackingTransform(out Vector3 position, out Quaternion rotation)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(GetTrackedTransform_Steam(out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                return(GetTrackedTransform_Oculus(out position, out rotation));
            }
#endif
            position = Vector3.zero;
            rotation = Quaternion.identity;

            return(false);
        }
Esempio n. 5
0
        public bool GetDeviceTransformByGuid(string guid, out Vector3 position, out Quaternion rotation)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(GetDeviceTransformByGuid_SteamVR(guid, out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                return(GetDeviceTransformByGuid_Oculus(guid, out position, out rotation));
            }
#endif

            position = Vector3.zero;
            rotation = Quaternion.identity;
            return(false);
        }
Esempio n. 6
0
        public bool GetSensorPosition(int index, out Vector3 position, out Quaternion rotation)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(GetSteamSensorPosition(index, out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                return(GetOculusSensorPosition(index, out position, out rotation));
            }
#endif
            Debug.LogError(UNKNOWN_MESSAGE);
            position = Vector3.zero;
            rotation = Quaternion.identity;
            return(false);
        }
Esempio n. 7
0
        public bool GetTrackingTransform(out Vector3 position, out Quaternion rotation)
        {
            if (!string.IsNullOrEmpty(context.Data.trackedByDeviceId))
            {
                if (TrackedDeviceManager.Instance.GetDeviceTransformByGuid(context.Data.trackedByDeviceId, out position, out rotation))
                {
                    return(true);
                }
            }

#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                //Fall back to index if guid isn't found
                SteamVR_TrackedObject.EIndex deviceIndex = (SteamVR_TrackedObject.EIndex)System.Enum.Parse(typeof(SteamVR_TrackedObject.EIndex), context.Data.trackedByDevice);
                return(TrackedDeviceManager.Instance.GetDeviceTransformByIndex((int)deviceIndex, out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                switch (context.Data.trackedByDevice)
                {
                case "Hmd":
                    return(TrackedDeviceManager.Instance.GetDeviceTransformByRole(TrackedDeviceManager.DeviceRole.Head, out position, out rotation));

                case "Device1":
                    return(TrackedDeviceManager.Instance.GetDeviceTransformByRole(TrackedDeviceManager.DeviceRole.LeftHand, out position, out rotation));

                case "Device2":
                    return(TrackedDeviceManager.Instance.GetDeviceTransformByRole(TrackedDeviceManager.DeviceRole.RightHand, out position, out rotation));

                default:
                    break;
                }
            }
#endif

            position = Vector3.zero;
            rotation = Quaternion.identity;
            return(false);
        }
Esempio n. 8
0
        bool CalculateNewState()
        {
            if (context.Data == null || context.Data.wasTracked == false)
            {
                return(false);
            }

#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR() && IsTracked_Steam())
            {
                return(true);
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus() && IsTracked_Oculus())
            {
                return(true);
            }
#endif

            return(false);
        }
Esempio n. 9
0
        public bool GetDeviceTransform(string guid, string role, out Vector3 position, out Quaternion rotation)
        {
#if MIXCAST_STEAMVR
            if (VRInfo.IsDeviceOpenVR())
            {
                return(GetDeviceTransformByGuid_SteamVR(guid, out position, out rotation));
            }
#endif
#if MIXCAST_OCULUS
            if (VRInfo.IsDeviceOculus())
            {
                DeviceRole vrRole;

                try
                {
                    vrRole = (DeviceRole)Enum.Parse(typeof(DeviceRole), role);
                }
                catch
                {
                    // Invalid role name
                    if (!loggedTrackingError)
                    {
                        // Avoid thousands of logged errors
                        Debug.LogError("Trying to get position for invalid controller role: " + role);
                        loggedTrackingError = true;
                    }
                    position = Vector3.zero;
                    rotation = Quaternion.identity;
                    return(false);
                }

                return(GetDeviceTransformByRole_Oculus(vrRole, out position, out rotation));
            }
#endif

            position = Vector3.zero;
            rotation = Quaternion.identity;
            return(false);
        }