Exemple #1
0
    /// <summary>
    /// Updates the internal state of the OVRDisplay. Called by OVRManager.
    /// </summary>
    public void Update()
    {
        UpdateTextures();

        if (recenterRequested && Time.frameCount > recenterRequestedFrameCount)
        {
            Debug.Log("Recenter event detected");
            if (RecenteredPose != null)
            {
                RecenteredPose();
            }
            recenterRequested           = false;
            recenterRequestedFrameCount = int.MaxValue;
        }

        if (OVRPlugin.GetSystemHeadsetType() >= OVRPlugin.SystemHeadset.Oculus_Quest &&
            OVRPlugin.GetSystemHeadsetType() < OVRPlugin.SystemHeadset.Rift_DK1)             // all Oculus Standalone headsets
        {
            int recenterCount = OVRPlugin.GetLocalTrackingSpaceRecenterCount();
            if (localTrackingSpaceRecenterCount != recenterCount)
            {
                Debug.Log("Recenter event detected");
                if (RecenteredPose != null)
                {
                    RecenteredPose();
                }
                localTrackingSpaceRecenterCount = recenterCount;
            }
        }
    }
        public void UpdateHeight()
        {
            var pos = transform.localPosition;

            switch (VRModule.activeModule)
            {
            case VRModuleActiveEnum.DayDream:
                transform.localPosition = new Vector3(pos.x, m_height, pos.z);
                break;

#if VIU_OCULUSVR && !VIU_OCULUSVR_19_0_OR_NEWER
            case VRModuleActiveEnum.OculusVR:
                if (OVRPlugin.GetSystemHeadsetType().Equals(OVRPlugin.SystemHeadset.Oculus_Go))
                {
                    transform.localPosition = new Vector3(pos.x, m_height, pos.z);
                }
                break;
#endif
#if UNITY_2019_2_OR_NEWER && !UNITY_2019_3_OR_NEWER
            case VRModuleActiveEnum.UnityNativeVR:
                if (XRDevice.model.Equals("Oculus Go"))
                {
                    transform.localPosition = new Vector3(pos.x, m_height, pos.z);
                }
                break;
#endif
            }
        }
Exemple #3
0
    /// <summary>
    /// Updates the internal state of the OVRDisplay. Called by OVRManager.
    /// </summary>
    public void Update()
    {
        UpdateTextures();

        if (recenterRequested && Time.frameCount > recenterRequestedFrameCount)
        {
            if (RecenteredPose != null)
            {
                RecenteredPose();
            }
            recenterRequested           = false;
            recenterRequestedFrameCount = int.MaxValue;
        }
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest)
        {
            OVRManager.TrackingOrigin relativeOrigin = (OVRManager.instance.trackingOriginType != OVRManager.TrackingOrigin.Stage) ? OVRManager.TrackingOrigin.Stage : OVRManager.TrackingOrigin.EyeLevel;
            OVRPose relativeTrackingSpacePose        = OVRPlugin.GetTrackingTransformRelativePose((OVRPlugin.TrackingOrigin)relativeOrigin).ToOVRPose();
            //If the tracking origin type hasn't switched and the relative pose changes, a recenter occurred.
            if (previousTrackingOrigin == OVRManager.instance.trackingOriginType && previousRelativeTrackingSpacePose != relativeTrackingSpacePose && RecenteredPose != null)
            {
                RecenteredPose();
            }
            previousRelativeTrackingSpacePose = relativeTrackingSpacePose;
            previousTrackingOrigin            = OVRManager.instance.trackingOriginType;
        }
    }
Exemple #4
0
 // Update is called once per frame
 void Update()
 {
     // If we are running on a Go.
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go)
     {
         UpdateHand(0, OVRInput.GetActiveController(), OVRInput.Button.PrimaryIndexTrigger, OVRInput.Button.PrimaryHandTrigger, 3.0f, (hand[0].transform.position - lastPosition) / Time.deltaTime);
         // Use the touchpad to move.
         if (OVRInput.Get(OVRInput.Button.PrimaryTouchpad))
         {
             Vector2 thumb   = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
             Vector3 forward = hand[0].transform.forward;
             Vector3 right   = hand[0].transform.right;
             forward.y           = 0.0f;
             right.y             = 0.0f;
             transform.position += (forward.normalized * thumb.y + right.normalized * thumb.x) * Time.deltaTime * 1.5f;
         }
         lastPosition = hand[0].transform.position;
     }
     else
     {
         // Update both left and right hands for Rift or Quest.
         UpdateHand(0, OVRInput.Controller.LTouch, OVRInput.Button.PrimaryIndexTrigger, OVRInput.Button.PrimaryHandTrigger, 0, Vector3.zero);
         UpdateHand(1, OVRInput.Controller.RTouch, OVRInput.Button.SecondaryIndexTrigger, OVRInput.Button.SecondaryHandTrigger, 0, Vector3.zero);
     }
 }
    // Return correct reference position depending on what model Quest is being used
    public Transform ReturnReferencePosition()
    {
        // If Oculus Quest 2
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest_2)
        {
            ReferencePosition = Oculus2_ReferencePosition;
        }

        // If Oculus Quest
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest)
        {
            ReferencePosition = Oculus_ReferencePosition;
        }

        // If Oculus Quest 2 Link
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Link_Quest_2)
        {
            ReferencePosition = Oculus2_ReferencePosition;
        }

        // If Oculus Quest Link
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Link_Quest)
        {
            ReferencePosition = Oculus_ReferencePosition;
        }

        return(ReferencePosition);
    }
    public int SetUserPosition(UserPosition position, Action callback = null)
    {
        if ((position == UserPosition.ThirdPartyTable || position == UserPosition.ThirdPartyRoom) &&
            AlcoveThirdPartyExperienceController.CurrentThirdPartyExperience == null)
        {
            if (m_ThirdPartyExperienceSelectionCanvas)
            {
                m_ThirdPartyExperienceSelectionCanvas.SetActive(true);
            }
            CameraController.getInstance().PositionObjectInFrontOfCamera(m_ThirdPartyExperienceSelectionCanvas.gameObject, 1.25f);
            return(-1);
        }
        else
        {
            if (m_ThirdPartyExperienceSelectionCanvas)
            {
                m_ThirdPartyExperienceSelectionCanvas.SetActive(false);
            }
        }

        int availablePositionIndex = GetPositionIndex(position);

        SetUserPosition(position, availablePositionIndex, callback);

        if (OVRPlugin.GetSystemHeadsetType().ToString().Contains("Quest") || OVRPlugin.GetSystemHeadsetType().ToString().Contains("Rift"))
        {
            CameraController.CameraContainer.transform.position = new Vector3(CameraController.CameraContainer.transform.position.x, m_FloorHeight, CameraController.CameraContainer.transform.position.z);
        }

        return(availablePositionIndex);
    }
Exemple #7
0
 private void Start()
 {
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go || OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest)
     {
         Destroy(this);
     }
 }
    void Start()
    {
        var headsetType = OVRPlugin.GetSystemHeadsetType();

        switch (headsetType)
        {
        case OVRPlugin.SystemHeadset.GearVR_R320:
        case OVRPlugin.SystemHeadset.GearVR_R321:
        case OVRPlugin.SystemHeadset.GearVR_R322:
        case OVRPlugin.SystemHeadset.GearVR_R323:
        case OVRPlugin.SystemHeadset.GearVR_R324:
        case OVRPlugin.SystemHeadset.GearVR_R325:
            ControllerType = ovrAvatarControllerType.Malibu;
            break;

        case OVRPlugin.SystemHeadset.Oculus_Go:
            ControllerType = ovrAvatarControllerType.Go;
            break;

        case OVRPlugin.SystemHeadset.Oculus_Quest:
        case OVRPlugin.SystemHeadset.Rift_S:
            ControllerType = ovrAvatarControllerType.Quest;
            break;

        case OVRPlugin.SystemHeadset.Rift_DK1:
        case OVRPlugin.SystemHeadset.Rift_DK2:
        case OVRPlugin.SystemHeadset.Rift_CV1:
        default:
            ControllerType = ovrAvatarControllerType.Touch;
            break;
        }
    }
    void Start()
    {
        OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
        switch (headset)
        {
        case OVRPlugin.SystemHeadset.Rift_CV1:
            activeControllerType = ControllerType.Rift;
            break;

        case OVRPlugin.SystemHeadset.Oculus_Quest_2:
            activeControllerType = ControllerType.Quest2;
            break;

        default:
            activeControllerType = ControllerType.QuestAndRiftS;
            break;
        }

        Debug.LogFormat("OVRControllerHelp: Active controller type: {0} for product {1}", activeControllerType, OVRPlugin.productName);

        // Hide all controller models until controller get connected
        m_modelOculusTouchQuestAndRiftSLeftController.SetActive(false);
        m_modelOculusTouchQuestAndRiftSRightController.SetActive(false);
        m_modelOculusTouchRiftLeftController.SetActive(false);
        m_modelOculusTouchRiftRightController.SetActive(false);
        m_modelOculusTouchQuest2LeftController.SetActive(false);
        m_modelOculusTouchQuest2RightController.SetActive(false);
    }
Exemple #10
0
    public static DeviceOptions getActivePlatform()
    {
        DeviceOptions detectedDevice = DeviceOptions.NoDevice;

        if (XRSettings.loadedDeviceName.Equals("Oculus"))
        {
            // Based on OVRControllerHelper.cs. See this file for other classes of oculus device.
            OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
            switch (headset)
            {
            case OVRPlugin.SystemHeadset.Oculus_Go:
                detectedDevice = DeviceOptions.OculusGo;
                break;

            case OVRPlugin.SystemHeadset.Oculus_Quest:
                detectedDevice = DeviceOptions.OculusQuest;
                break;
            }
        }
        if (XRSettings.loadedDeviceName.Equals("daydream"))
        {
            detectedDevice = DeviceOptions.Daydream;
        }

        return(detectedDevice);
    }
 public override void VibrateController(bool right, AudioClip audio)
 {
     base.VibrateController(right, audio);
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.None)
     {
         return;
     }
     StartCoroutine(VibrationCoroutine(right ? OVRInput.Controller.RTouch : OVRInput.Controller.LTouch, audio.length));
 }
Exemple #12
0
 /// <summary>
 /// Creates an instance of OVRDisplay. Called by OVRManager.
 /// </summary>
 public OVRDisplay()
 {
     UpdateTextures();
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest)
     {
         previousTrackingOrigin = OVRManager.instance.trackingOriginType;
         OVRManager.TrackingOrigin relativeOrigin = (previousTrackingOrigin != OVRManager.TrackingOrigin.Stage) ? OVRManager.TrackingOrigin.Stage : OVRManager.TrackingOrigin.EyeLevel;
         previousRelativeTrackingSpacePose = OVRPlugin.GetTrackingTransformRelativePose((OVRPlugin.TrackingOrigin)relativeOrigin).ToOVRPose();
     }
 }
Exemple #13
0
    private void Start()
    {
        if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go && grabButton == OVRInput.Button.SecondaryIndexTrigger)
        {
            gameObject.SetActive(false);
        }

        interactionSoundManager = GetComponent <InteractionSoundManager>();
        player = FindObjectOfType <PlayerScript>();
        SetLineColour();
    }
Exemple #14
0
    void Start()
    {
        OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
        switch (headset)
        {
        case OVRPlugin.SystemHeadset.Oculus_Quest:
            activeControllerType = ControllerType.QuestAndRiftS;
            break;

        case OVRPlugin.SystemHeadset.Rift_CV1:
            activeControllerType = ControllerType.Rift;
            break;

        case OVRPlugin.SystemHeadset.Rift_S:
            activeControllerType = ControllerType.QuestAndRiftS;
            break;

        default:
#if UNITY_EDITOR || !UNITY_ANDROID
            activeControllerType = ControllerType.Rift;
#else
            activeControllerType = ControllerType.GearVR;
#endif
            break;
        }

        Debug.LogFormat("OVRControllerHelp: Active controller type: {0} for product {1}", activeControllerType, OVRPlugin.productName);

        /*
         * if ((activeControllerType != ControllerType.GearVR) && (activeControllerType != ControllerType.Go))
         * {
         *      if (m_controller == OVRInput.Controller.LTrackedRemote)
         *      {
         *              m_controller = OVRInput.Controller.LTouch;
         *      }
         *      else if (m_controller == OVRInput.Controller.RTrackedRemote)
         *      {
         *              m_controller = OVRInput.Controller.RTouch;
         *      }
         * }
         * else
         * {
         *      if (m_controller == OVRInput.Controller.LTouch)
         *      {
         *              m_controller = OVRInput.Controller.LTrackedRemote;
         *      }
         *      else if (m_controller == OVRInput.Controller.RTouch)
         *      {
         *              m_controller = OVRInput.Controller.RTrackedRemote;
         *      }
         * }
         */
    }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        animator = GetComponent <Animator>();
        // Initializing animator values
        animator.SetFloat("walk_forward", 0.0f);
        animator.SetFloat("walk_backward", 0.0f);
        animator.SetFloat("walk_right", 0.0f);
        animator.SetFloat("walk_left", 0.0f);

        // Setting Initial rotation of spine to make it
        spineInitialLocalRotation = Quaternion.Euler(new Vector3(0.0f, 40.0f, 0.0f));

        isOculusVREnabled = OVRPlugin.GetSystemHeadsetType() != OVRPlugin.SystemHeadset.None;
    }
        public OVRPointerPoseSelector(Handedness handedness)
        {
            OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
            switch (headset)
            {
            case OVRPlugin.SystemHeadset.Oculus_Quest_2:
            case OVRPlugin.SystemHeadset.Oculus_Link_Quest_2:
                LocalPointerPose = QUEST2_POINTERS[(int)handedness];
                break;

            default:
                LocalPointerPose = QUEST1_POINTERS[(int)handedness];
                break;
            }
        }
Exemple #17
0
 // Start is called before the first frame update
 void Start()
 {
     // To make left and right handed Go controllers easier, check at runtime which is active and make both hands refer to the same controller.
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go)
     {
         if (OVRInput.GetDominantHand() == OVRInput.Handedness.LeftHanded)
         {
             hand[1] = hand[0];
         }
         else
         {
             hand[0] = hand[1];
         }
     }
 }
    public static bool IsRift()
    {
        OVRPlugin.SystemHeadset headsetType = OVRPlugin.GetSystemHeadsetType();
        switch (headsetType)
        {
        case OVRPlugin.SystemHeadset.Rift_DK1:
        case OVRPlugin.SystemHeadset.Rift_DK2:
        case OVRPlugin.SystemHeadset.Rift_CV1:
        case OVRPlugin.SystemHeadset.Rift_CB:
        case OVRPlugin.SystemHeadset.Rift_S:
            return(true);

        default:
            return(false);
        }
    }
Exemple #19
0
    void Start()
    {
        OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
        switch (headset)
        {
        case OVRPlugin.SystemHeadset.Rift_CV1:
            activeControllerType = ControllerType.Rift;
            break;

        default:
            activeControllerType = ControllerType.QuestAndRiftS;
            break;
        }

        Debug.LogFormat("OVRControllerHelp: Active controller type: {0} for product {1}", activeControllerType, OVRPlugin.productName);
    }
Exemple #20
0
    void Awake()
    {
        _Reticle = FindObjectOfType <GvrReticlePointer>();
        _Laser   = FindObjectOfType <GvrLaserPointer>();
        SetupGearVrOrGo();

#if UNITY_EDITOR || UNITY_STANDALONE
        if (OVRPlugin.GetSystemHeadsetType().ToString().Contains("Rift"))
        {
            SetupForRift();
        }
        else
        {
            ActivateMouse();
        }
#endif
    }
    public static bool IsGearVRHeadset()
    {
        OVRPlugin.SystemHeadset headsetType = OVRPlugin.GetSystemHeadsetType();
        switch (headsetType)
        {
        case OVRPlugin.SystemHeadset.GearVR_R320:
        case OVRPlugin.SystemHeadset.GearVR_R321:
        case OVRPlugin.SystemHeadset.GearVR_R322:
        case OVRPlugin.SystemHeadset.GearVR_R323:
        case OVRPlugin.SystemHeadset.GearVR_R324:
        case OVRPlugin.SystemHeadset.GearVR_R325:
            return(true);

        default:
            return(false);
        }
    }
Exemple #22
0
    void Start()
    {
        string debugString = "";

        debugString += "Device model: " + OVRPlugin.GetSystemHeadsetType().ToString() + Environment.NewLine;

        debugString   += "Version: 2" + Environment.NewLine;
        debugString   += "Searching from " + NLUtility.GetNLDirectory() + Environment.NewLine;
        debugText.text = debugString;
        debugString   += "Moving to " + NLUtility.GetAudicaDirectory() + Environment.NewLine;
        debugText.text = debugString;
        debugString   += "Audica directory exists: " + Directory.Exists(NLUtility.GetAudicaDirectory()).ToString() + Environment.NewLine;
        debugText.text = debugString;
        debugString   += "Attempting to find audica files" + Environment.NewLine;
        debugText.text = debugString;

        //try
        //{
        Stopwatch sw = new Stopwatch();

        sw.Start();
        foreach (var audicaFilePath in GetAllFiles(NLUtility.GetAudicaDirectory(), "*.audica"))
        {
            //debugString += "Found Audica File:" + audicaFile + Environment.NewLine;

            //Method 1
            //var audica = new Audica(audicaFilePath);
            //debugString += $"{audica.desc.title}-{audica.desc.artist} mapped by {audica.desc.author}";

            //var audica = Audica.GetMetadata(audicaFilePath);
            //debugString += $"{audica.desc.title} - {audica.fileInfo.FullName} \n";
        }
        print($"Loaded songs in: {sw.ElapsedMilliseconds}ms");
        debugText.text = debugString;


        NLUtility.PlayPreviewFromAudicaFile(this, FindObjectOfType <AudioSource>(), Path.Combine(NLUtility.GetAudicaDirectory(), "7Years-Continuum.audica"));

        //}
        //catch (Exception e)
        //{
        //    debugString += e.Message;
        //    debugText.text = debugString;
        //}
    }
        public void SetDeviceIndex(uint index)
        {
            //Debug.Log(transform.parent.parent.name + " SetDeviceIndex " + index);
            m_deviceIndex = index;
#if (VIU_OCULUSVR_1_32_0_OR_NEWER || VIU_OCULUSVR_1_36_0_OR_NEWER) && VIU_OCULUSVR_AVATAR
            ovrController = this.GetComponent <OvrAvatarTouchController>();
#endif
#if VIU_OCULUSVR && VIU_OCULUSVR_AVATAR
            var headsetType = OVRPlugin.GetSystemHeadsetType();
            switch (headsetType)
            {
#if !VIU_OCULUSVR_19_0_OR_NEWER
            case OVRPlugin.SystemHeadset.GearVR_R320:
            case OVRPlugin.SystemHeadset.GearVR_R321:
            case OVRPlugin.SystemHeadset.GearVR_R322:
            case OVRPlugin.SystemHeadset.GearVR_R323:
            case OVRPlugin.SystemHeadset.GearVR_R324:
            case OVRPlugin.SystemHeadset.GearVR_R325:
                m_controllerType = ovrAvatarControllerType.Malibu;
                break;

            case OVRPlugin.SystemHeadset.Oculus_Go:
                m_controllerType = ovrAvatarControllerType.Go;
                break;
#endif
#if VIU_OCULUSVR_16_0_OR_NEWER
            case OVRPlugin.SystemHeadset.Oculus_Link_Quest:
#endif
            case OVRPlugin.SystemHeadset.Oculus_Quest:
#if VIU_OCULUSVR_1_37_0_OR_NEWER
            case OVRPlugin.SystemHeadset.Rift_S:
                m_controllerType = ovrAvatarControllerType.Quest;
                break;
#endif
            case OVRPlugin.SystemHeadset.Rift_DK1:
            case OVRPlugin.SystemHeadset.Rift_DK2:
            case OVRPlugin.SystemHeadset.Rift_CV1:
            default:
                m_controllerType = ovrAvatarControllerType.Touch;
                break;
            }
#endif
            LoadPreferedModel();
        }
Exemple #24
0
    void Start()
    {
        var headsetType = OVRPlugin.GetSystemHeadsetType();

        switch (headsetType)
        {
        case OVRPlugin.SystemHeadset.Oculus_Quest:
        case OVRPlugin.SystemHeadset.Rift_S:
            ControllerType = ovrAvatarControllerType.Quest;
            break;

        case OVRPlugin.SystemHeadset.Rift_DK1:
        case OVRPlugin.SystemHeadset.Rift_DK2:
        case OVRPlugin.SystemHeadset.Rift_CV1:
        default:
            ControllerType = ovrAvatarControllerType.Touch;
            break;
        }
    }
Exemple #25
0
    void Start()
    {
        OVRPlugin.SystemHeadset headset = OVRPlugin.GetSystemHeadsetType();
        switch (headset)
        {
        case OVRPlugin.SystemHeadset.Oculus_Go:
            activeControllerType = ControllerType.Go;
            break;

        case OVRPlugin.SystemHeadset.Rift_CV1:
            activeControllerType = ControllerType.Rift;
            break;

        default:
            activeControllerType = ControllerType.QuestAndRiftS;
            break;
        }

        Debug.LogFormat("OVRControllerHelp: Active controller type: {0} for product {1}", activeControllerType, OVRPlugin.productName);
        if (activeControllerType != ControllerType.Go)
        {
            if (m_controller == OVRInput.Controller.LTrackedRemote)
            {
                m_controller = OVRInput.Controller.LTouch;
            }
            else if (m_controller == OVRInput.Controller.RTrackedRemote)
            {
                m_controller = OVRInput.Controller.RTouch;
            }
        }
        else
        {
            if (m_controller == OVRInput.Controller.LTouch)
            {
                m_controller = OVRInput.Controller.LTrackedRemote;
            }
            else if (m_controller == OVRInput.Controller.RTouch)
            {
                m_controller = OVRInput.Controller.RTrackedRemote;
            }
        }
    }
    public override void Awake()
    {
        base.Awake();

        //Setup initial prefs
        if (PlayerPrefs.GetInt(SettingsManager.graphicsSettingName) == 0)
        {
            //If this is the first boot of the system, and player is using a quest, turn on performance lighting
            if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest ||
                OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest_2 ||
                OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Link_Quest ||
                OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Link_Quest_2)
            {
                AnalyticsLogger.UpdateLogFile("Detecting Oculus Quest - lowering lighting quality");
                PlayerPrefs.SetInt(SettingsManager.graphicsSettingName, 1);
                TogglePerformanceLighting(true);
            }
            else
            {
                PlayerPrefs.SetInt(SettingsManager.graphicsSettingName, 2);
            }
        }
        else if (PlayerPrefs.GetInt(SettingsManager.graphicsSettingName) == 1)
        {
            TogglePerformanceLighting(true);
        }

        if (PlayerPrefs.GetInt(SettingsManager.colorblindSettingName) == 0)
        {
            PlayerPrefs.SetInt(SettingsManager.colorblindSettingName, 1);
        }

        if (PlayerPrefs.GetInt(SettingsManager.usageDataSettingName) == 0)
        {
            PlayerPrefs.SetInt(SettingsManager.usageDataSettingName, 2);
        }
    }
        private OculusDeviceType GetDeviceType()
        {
            var result    = OculusDeviceType.Undefined;
            var curDevice = OVRPlugin.GetSystemHeadsetType().ToString().ToLower();

            if (curDevice.Contains("gearvr"))
            {
                result = OculusDeviceType.GearVR;
            }
            else if (curDevice.Contains("rift"))
            {
                result = curDevice == "rift_s" ? OculusDeviceType.RiftS : OculusDeviceType.Rift;
            }
            else if (curDevice.Contains("oculus_go"))
            {
                result = OculusDeviceType.Go;
            }
            else if (curDevice.Contains("quest"))
            {
                result = OculusDeviceType.Quest;
            }

            return(result);
        }
    void Start()
    {
        if (OvrAvatarSDKManager.Instance == null)
        {
            return;
        }
#if !UNITY_ANDROID
        if (CombineMeshes)
        {
            CombineMeshes = false;
            AvatarLogger.Log("Combined Meshes currently only supported on mobile");
        }
#endif
#if !UNITY_5_5_OR_NEWER
        if (CombineMeshes)
        {
            CombineMeshes = false;
            AvatarLogger.LogWarning("Combined Meshes requires Unity 5.5.0+");
        }
#endif
        materialManager = gameObject.AddComponent <OvrAvatarMaterialManager>();

        try
        {
            oculusUserIDInternal = UInt64.Parse(oculusUserID);
        }
        catch (Exception)
        {
            oculusUserIDInternal = 0;
            AvatarLogger.LogWarning("Invalid Oculus User ID Format");
        }

        // If no oculus ID is supplied then turn off combine meshes to prevent the texture arrays
        // being populated by invalid textures.
        if (oculusUserIDInternal == 0)
        {
            AvatarLogger.LogWarning("Oculus User ID set to 0. Provide actual user ID: " + gameObject.name);
            CombineMeshes = false;
        }

        AvatarLogger.Log("Starting OvrAvatar " + gameObject.name);
        AvatarLogger.Log(AvatarLogger.Tab + "LOD: " + LevelOfDetail.ToString());
        AvatarLogger.Log(AvatarLogger.Tab + "Combine Meshes: " + CombineMeshes);
        AvatarLogger.Log(AvatarLogger.Tab + "Force Mobile Textures: " + USE_MOBILE_TEXTURE_FORMAT);
        AvatarLogger.Log(AvatarLogger.Tab + "Oculus User ID: " + oculusUserIDInternal);

        Capabilities = 0;

        bool is3Dof      = false;
        var  headsetType = OVRPlugin.GetSystemHeadsetType();
        switch (headsetType)
        {
        case OVRPlugin.SystemHeadset.GearVR_R320:
        case OVRPlugin.SystemHeadset.GearVR_R321:
        case OVRPlugin.SystemHeadset.GearVR_R322:
        case OVRPlugin.SystemHeadset.GearVR_R323:
        case OVRPlugin.SystemHeadset.GearVR_R324:
        case OVRPlugin.SystemHeadset.GearVR_R325:
        case OVRPlugin.SystemHeadset.Oculus_Go:
            is3Dof = true;
            break;

        case OVRPlugin.SystemHeadset.Oculus_Quest:
        case OVRPlugin.SystemHeadset.Rift_S:
        case OVRPlugin.SystemHeadset.Rift_DK1:
        case OVRPlugin.SystemHeadset.Rift_DK2:
        case OVRPlugin.SystemHeadset.Rift_CV1:
        default:
            break;
        }

        // The SDK 3 DOF Arm Model requires the body skeleton to pose itself. It will crash without it
        // The likely use case here is trying to have an invisible body.
        // T45010595
        if (is3Dof && !EnableBody)
        {
            AvatarLogger.Log("Forcing the Body component for 3Dof hand tracking, and setting the visibility to 1st person");
            EnableBody      = true;
            ShowFirstPerson = true;
            ShowThirdPerson = false;
        }

        if (EnableBody)
        {
            Capabilities |= ovrAvatarCapabilities.Body;
        }
        if (EnableHands)
        {
            Capabilities |= ovrAvatarCapabilities.Hands;
        }
        if (EnableBase && EnableBody)
        {
            Capabilities |= ovrAvatarCapabilities.Base;
        }
        if (EnableExpressive)
        {
            Capabilities |= ovrAvatarCapabilities.Expressive;
        }

        // Enable body tilt on 6dof devices
        if (OVRPlugin.positionSupported)
        {
            Capabilities |= ovrAvatarCapabilities.BodyTilt;
        }

        ShowLeftController(StartWithControllers);
        ShowRightController(StartWithControllers);

        OvrAvatarSDKManager.AvatarSpecRequestParams avatarSpecRequest = new OvrAvatarSDKManager.AvatarSpecRequestParams(
            oculusUserIDInternal,
            this.AvatarSpecificationCallback,
            CombineMeshes,
            LevelOfDetail,
            USE_MOBILE_TEXTURE_FORMAT,
            LookAndFeelVersion,
            FallbackLookAndFeelVersion,
            EnableExpressive);

        OvrAvatarSDKManager.Instance.RequestAvatarSpecification(avatarSpecRequest);
        OvrAvatarSDKManager.Instance.AddLoadingAvatar(GetInstanceID());

        waitingForCombinedMesh = CombineMeshes;
        if (Driver != null)
        {
            Driver.Mode = UseSDKPackets ? OvrAvatarDriver.PacketMode.SDK : OvrAvatarDriver.PacketMode.Unity;
        }
    }
        public override void BeforeRenderUpdate()
        {
            FlushDeviceState();

            for (uint i = 0u, imax = GetDeviceStateLength(); i < imax; ++i)
            {
                var node = s_index2node[i];
                if (node == OVRPlugin.Node.None)
                {
                    continue;
                }

                IVRModuleDeviceState   prevState;
                IVRModuleDeviceStateRW currState;
                EnsureValidDeviceState(i, out prevState, out currState);

                if (!OVRPlugin.GetNodePresent(node))
                {
                    if (prevState.isConnected)
                    {
                        currState.Reset();
                    }

                    continue;
                }

                // update device connected state
                if (!prevState.isConnected)
                {
                    var platform       = OVRPlugin.GetSystemHeadsetType();
                    var ovrProductName = platform.ToString();
                    var deviceClass    = s_node2class[(int)node];

                    currState.isConnected = true;
                    currState.deviceClass = deviceClass;
                    // FIXME: how to get device id from OVRPlugin?
                    currState.modelNumber     = ovrProductName + " " + deviceClass;
                    currState.renderModelName = ovrProductName + " " + deviceClass;
                    currState.serialNumber    = ovrProductName + " " + deviceClass;

                    switch (deviceClass)
                    {
                    case VRModuleDeviceClass.HMD:
                        currState.deviceModel = VRModuleDeviceModel.OculusHMD;
                        break;

                    case VRModuleDeviceClass.TrackingReference:
                        currState.deviceModel = VRModuleDeviceModel.OculusSensor;
                        break;

                    case VRModuleDeviceClass.Controller:
                        switch (platform)
                        {
                        case OVRPlugin.SystemHeadset.Oculus_Go:
                            currState.deviceModel = VRModuleDeviceModel.OculusGoController;
                            break;

                        case OVRPlugin.SystemHeadset.GearVR_R320:
                        case OVRPlugin.SystemHeadset.GearVR_R321:
                        case OVRPlugin.SystemHeadset.GearVR_R322:
                        case OVRPlugin.SystemHeadset.GearVR_R323:
                        case OVRPlugin.SystemHeadset.GearVR_R324:
                        case OVRPlugin.SystemHeadset.GearVR_R325:
                            currState.deviceModel = VRModuleDeviceModel.OculusGearVrController;
                            break;

                        case OVRPlugin.SystemHeadset.Rift_DK1:
                        case OVRPlugin.SystemHeadset.Rift_DK2:
                        case OVRPlugin.SystemHeadset.Rift_CV1:
                        default:
                            switch (node)
                            {
                            case OVRPlugin.Node.HandLeft:
                                currState.deviceModel = VRModuleDeviceModel.OculusTouchLeft;
                                break;

                            case OVRPlugin.Node.HandRight:
                            default:
                                currState.deviceModel = VRModuleDeviceModel.OculusTouchRight;
                                break;
                            }
                            break;
                        }
                        break;
                    }
                }

                // update device pose
                currState.pose            = ToPose(OVRPlugin.GetNodePose(node, OVRPlugin.Step.Render));
                currState.velocity        = OVRPlugin.GetNodeVelocity(node, OVRPlugin.Step.Render).FromFlippedZVector3f();
                currState.angularVelocity = OVRPlugin.GetNodeAngularVelocity(node, OVRPlugin.Step.Render).FromFlippedZVector3f();
                currState.isPoseValid     = currState.pose != RigidPose.identity;
                currState.isConnected     = OVRPlugin.GetNodePresent(node);

                // update device input
                switch (currState.deviceModel)
                {
                case VRModuleDeviceModel.OculusTouchLeft:
                {
                    var ctrlState = OVRPlugin.GetControllerState((uint)OVRPlugin.Controller.LTouch);

                    currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, (ctrlState.Buttons & (uint)OVRInput.RawButton.Y) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.A, (ctrlState.Buttons & (uint)OVRInput.RawButton.X) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.Touchpad, (ctrlState.Buttons & (uint)OVRInput.RawButton.LThumbstick) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(currState.GetButtonPress(VRModuleRawButton.Trigger), ctrlState.LIndexTrigger, 0.55f, 0.45f));
                    currState.SetButtonPress(VRModuleRawButton.Grip, AxisToPress(currState.GetButtonPress(VRModuleRawButton.Grip), ctrlState.LHandTrigger, 0.55f, 0.45f));
                    currState.SetButtonPress(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonPress(VRModuleRawButton.CapSenseGrip), ctrlState.LHandTrigger, 0.55f, 0.45f));

                    currState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, (ctrlState.Touches & (uint)OVRInput.RawTouch.Y) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.A, (ctrlState.Touches & (uint)OVRInput.RawTouch.X) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & (uint)OVRInput.RawTouch.LThumbstick) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.Trigger, (ctrlState.Touches & (uint)OVRInput.RawTouch.LIndexTrigger) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), ctrlState.LHandTrigger, 0.25f, 0.20f));

                    currState.SetAxisValue(VRModuleRawAxis.TouchpadX, ctrlState.LThumbstick.x);
                    currState.SetAxisValue(VRModuleRawAxis.TouchpadY, ctrlState.LThumbstick.y);
                    currState.SetAxisValue(VRModuleRawAxis.Trigger, ctrlState.LIndexTrigger);
                    currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, ctrlState.LHandTrigger);
                    break;
                }

                case VRModuleDeviceModel.OculusTouchRight:
                {
                    var ctrlState = OVRPlugin.GetControllerState((uint)OVRPlugin.Controller.RTouch);

                    currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, (ctrlState.Buttons & (uint)OVRInput.RawButton.B) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.A, (ctrlState.Buttons & (uint)OVRInput.RawButton.A) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.Touchpad, (ctrlState.Buttons & (uint)OVRInput.RawButton.RThumbstick) != 0u);
                    currState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(currState.GetButtonPress(VRModuleRawButton.Trigger), ctrlState.RIndexTrigger, 0.55f, 0.45f));
                    currState.SetButtonPress(VRModuleRawButton.Grip, AxisToPress(currState.GetButtonPress(VRModuleRawButton.Grip), ctrlState.RHandTrigger, 0.55f, 0.45f));
                    currState.SetButtonPress(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonPress(VRModuleRawButton.CapSenseGrip), ctrlState.RHandTrigger, 0.55f, 0.45f));

                    currState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, (ctrlState.Touches & (uint)OVRInput.RawTouch.B) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.A, (ctrlState.Touches & (uint)OVRInput.RawTouch.A) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & (uint)OVRInput.RawTouch.RThumbstick) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.Trigger, (ctrlState.Touches & (uint)OVRInput.RawTouch.RIndexTrigger) != 0u);
                    currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), ctrlState.RHandTrigger, 0.25f, 0.20f));

                    currState.SetAxisValue(VRModuleRawAxis.TouchpadX, ctrlState.RThumbstick.x);
                    currState.SetAxisValue(VRModuleRawAxis.TouchpadY, ctrlState.RThumbstick.y);
                    currState.SetAxisValue(VRModuleRawAxis.Trigger, ctrlState.RIndexTrigger);
                    currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, ctrlState.RHandTrigger);
                    break;
                }

                case VRModuleDeviceModel.OculusGoController:
                case VRModuleDeviceModel.OculusGearVrController:
                    switch (node)
                    {
                    case OVRPlugin.Node.HandLeft:
                    {
                        var ctrlState = OVRPlugin.GetControllerState((uint)OVRPlugin.Controller.LTrackedRemote);

                        currState.SetButtonPress(VRModuleRawButton.Touchpad, (ctrlState.Buttons & (uint)OVRInput.RawButton.LTouchpad) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, (ctrlState.Buttons & (uint)OVRInput.RawButton.Back) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.Trigger, (ctrlState.Buttons & (uint)(OVRInput.RawButton.A | OVRInput.RawButton.LIndexTrigger)) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadLeft, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadLeft) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadUp, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadUp) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadRight, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadRight) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadDown, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadDown) != 0u);

                        currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & (uint)OVRInput.RawTouch.LTouchpad) != 0u);
                    }
                    break;

                    case OVRPlugin.Node.HandRight:
                    default:
                    {
                        var ctrlState = OVRPlugin.GetControllerState((uint)OVRPlugin.Controller.RTrackedRemote);

                        currState.SetButtonPress(VRModuleRawButton.Touchpad, (ctrlState.Buttons & unchecked ((uint)OVRInput.RawButton.RTouchpad)) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, (ctrlState.Buttons & (uint)OVRInput.RawButton.Back) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.Trigger, (ctrlState.Buttons & (uint)(OVRInput.RawButton.A | OVRInput.RawButton.RIndexTrigger)) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadLeft, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadLeft) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadUp, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadUp) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadRight, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadRight) != 0u);
                        currState.SetButtonPress(VRModuleRawButton.DPadDown, (ctrlState.Buttons & (uint)OVRInput.RawButton.DpadDown) != 0u);

                        currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & unchecked ((uint)OVRInput.RawTouch.RTouchpad)) != 0u);
                    }
                    break;
                    }
                    break;
                }
            }

            ProcessConnectedDeviceChanged();
            ProcessDevicePoseChanged();
            ProcessDeviceInputChanged();
        }
Exemple #30
0
        protected override void RefreshPage()
        {
            m_NoLikesMessage.SetActive(false);
            m_NoAuthoredModelsMessage.SetActive(false);
            m_NotLoggedInMessage.SetActive(false);
            if (VrAssetService.m_Instance.NoConnection)
            {
                m_NoPolyConnectionMessage.SetActive(true);
                RefreshPanelText();
                base.RefreshPage();
                return;
            }
            if (!VrAssetService.m_Instance.Available)
            {
                m_OutOfDateMessage.SetActive(true);
                RefreshPanelText();
                base.RefreshPage();
                return;
            }

#if UNITY_ANDROID && OCULUS_SUPPORTED
            if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest)
            {
                m_NotSupportedMessage.SetActive(true);
                RefreshPanelText();
                base.RefreshPage();
                return;
            }
#endif

            m_NumPages = ((App.PolyAssetCatalog.NumCloudModels(m_CurrentSet) - 1) / Icons.Count) + 1;
            int numCloudModels = App.PolyAssetCatalog.NumCloudModels(m_CurrentSet);

            if (m_LastPageIndexForLoad != PageIndex || m_LastSetTypeForLoad != m_CurrentSet)
            {
                // Unload the previous page's models.

                // This function may be called multiple times as icons load, only unload the old models once,
                // otherwise the current page's models will be thrashed.
                m_LastPageIndexForLoad = PageIndex;
                m_LastSetTypeForLoad   = m_CurrentSet;

                // Destroy previews so only the thumbnail is visible.
                for (int i = 0; i < Icons.Count; i++)
                {
                    ((ModelButton)Icons[i]).DestroyModelPreview();
                }

                App.PolyAssetCatalog.UnloadUnusedModels();
            }

            for (int i = 0; i < Icons.Count; i++)
            {
                PolyModelButton icon = (PolyModelButton)Icons[i];
                // Set sketch index relative to page based index
                int iMapIndex = m_IndexOffset + i;

                // Init icon according to availability of sketch
                GameObject go = icon.gameObject;
                if (iMapIndex < numCloudModels)
                {
                    PolyAssetCatalog.AssetDetails asset =
                        App.PolyAssetCatalog.GetPolyAsset(m_CurrentSet, iMapIndex);
                    go.SetActive(true);

                    if (icon.Asset != null && asset.AssetId != icon.Asset.AssetId)
                    {
                        icon.DestroyModelPreview();
                    }
                    icon.SetPreset(asset, iMapIndex);

                    // Note that App.UserConfig.Flags.PolyModelPreload falls through to
                    // App.PlatformConfig.EnablePolyPreload if it isn't set in Tilt Brush.cfg.
                    if (App.UserConfig.Flags.PolyModelPreload)
                    {
                        icon.RequestModelPreload(PageIndex);
                    }
                }
                else
                {
                    go.SetActive(false);
                }
            }

            bool internetError =
                App.PolyAssetCatalog.NumCloudModels(PolySetType.Featured) == 0;
            m_InternetError.SetActive(internetError);

            RefreshPanelText();
            switch (m_CurrentSet)
            {
            case PolySetType.User:
                if (!internetError)
                {
                    if (App.GoogleIdentity.LoggedIn)
                    {
                        if (numCloudModels == 0)
                        {
                            m_NoAuthoredModelsMessage.SetActive(true);
                        }
                    }
                    else
                    {
                        m_NotLoggedInMessage.SetActive(true);
                    }
                }
                break;

            case PolySetType.Liked:
                if (!internetError)
                {
                    if (App.GoogleIdentity.LoggedIn)
                    {
                        if (numCloudModels == 0)
                        {
                            m_NoLikesMessage.SetActive(true);
                        }
                    }
                    else
                    {
                        m_NotLoggedInMessage.SetActive(true);
                    }
                }
                break;
            }

            base.RefreshPage();
        }