Пример #1
0
        public virtual void Enable(bool enable, bool clearTextOnEnable = true)
        {
            if (enable)
            {
                Animator animator = QuickSingletonManager.GetInstance <QuickVRManager>().GetAnimatorTarget();
                if (animator)
                {
                    Vector2   hSize = GetComponent <RectTransform>().GetSizeHalf();
                    Transform t     = QuickVRManager.IsXREnabled() ? animator.transform : Camera.main.transform;
                    Vector3   pos   = animator.GetBoneTransform(HumanBodyBones.Head).position;
                    transform.position = pos - (t.right * hSize.x) + (t.up * hSize.y) + t.forward * 2;
                    transform.rotation = t.rotation;
                }
            }

            foreach (Transform t in transform)
            {
                t.gameObject.SetActive(enable);
            }

            if (enable && clearTextOnEnable)
            {
                SetText("");
            }

            if (!QuickVRManager.IsXREnabled())
            {
                InputManagerKeyboard iManager = QuickSingletonManager.GetInstance <InputManager>().GetComponentInChildren <InputManagerKeyboard>();
                iManager.enabled = !enable;
                _rootKeys.gameObject.SetActive(false);
            }

            _isEnabled = enable;
        }
Пример #2
0
        protected override void Awake()
        {
            _guiCalibration = QuickSingletonManager.GetInstance <QuickUserGUICalibration>();
            _vrManager      = QuickSingletonManager.GetInstance <QuickVRManager>();

            base.Awake();
        }
Пример #3
0
        protected override void Awake()
        {
            base.Awake();

            _sceneManager = QuickSingletonManager.GetInstance <QuickSceneManager>();
            _avoidable    = false;
        }
Пример #4
0
        protected virtual void UpdateVRNodeFingers()
        {
            if (IsTracked() && QuickVRManager._handTrackingMode == QuickVRManager.HandTrackingMode.Controllers)
            {
                //Update the nodes of the fingers
                foreach (QuickHumanFingers f in QuickHumanTrait.GetHumanFingers())
                {
                    List <QuickHumanBodyBones> fingerBones = QuickHumanTrait.GetBonesFromFinger(f, _isLeft);
                    for (int i = 0; i < QuickHumanTrait.NUM_BONES_PER_FINGER; i++)
                    {
                        QuickVRNode nFinger = QuickSingletonManager.GetInstance <QuickVRPlayArea>().GetVRNode(fingerBones[i]);

                        //The finger is tracked.
                        Transform t = _handAnimator[(int)f][i]; // .GetBoneFingerTransform(f, i);
                        nFinger.transform.position = t.position;
                        nFinger.transform.rotation = t.rotation;

                        //Correct the rotation
                        //if (IsLeft())
                        //{
                        //    nFinger.transform.Rotate(Vector3.right, 180, Space.Self);
                        //    nFinger.transform.Rotate(Vector3.up, -90, Space.Self);
                        //}
                        //else
                        //{
                        //    nFinger.transform.Rotate(Vector3.up, 90, Space.Self);
                        //}

                        nFinger.SetTracked(true);
                    }
                }
            }
        }
Пример #5
0
        protected override void Awake()
        {
            base.Awake();

            _cameraFade = QuickSingletonManager.GetInstance <CameraFade>();
            InitFadeCurve();
        }
Пример #6
0
        protected virtual void InitFingersData()
        {
            Animator animator = QuickSingletonManager.GetInstance <QuickVRManager>().GetAnimatorSource();

            QuickHumanFingers[] fingers = QuickHumanTrait.GetHumanFingers();
            int numFingers = fingers.Length;

            _handFingerConfidence = new int[numFingers];
            _vrNodeFingers        = new QuickVRNode[numFingers * NUM_BONES_PER_FINGER];
            _tBoneFingers         = new Transform[numFingers * NUM_BONES_PER_FINGER];

            for (int i = 0; i < numFingers; i++)
            {
                _handFingerConfidence[i] = NUM_FRAMES_CONFIDENCE;
                List <QuickHumanBodyBones> fingerBones = QuickHumanTrait.GetBonesFromFinger(fingers[i], IsLeft());
                for (int j = 0; j < NUM_BONES_PER_FINGER; j++)
                {
                    int       fingerBoneID = (i * NUM_BONES_PER_FINGER) + j;
                    Transform tBone        = animator.GetBoneTransform(fingerBones[j]);

                    _vrNodeFingers[fingerBoneID] = _playArea.GetVRNode(fingerBones[j]);
                    _tBoneFingers[fingerBoneID]  = tBone;
                }
            }
        }
Пример #7
0
        protected static void Init()
        {
            QuickWebXRHandlersManager wxrHandlersManager = QuickSingletonManager.GetInstance <QuickWebXRHandlersManager>();
            QuickVRPlayArea           vrPlayArea         = QuickSingletonManager.GetInstance <QuickVRPlayArea>();

            wxrHandlersManager.transform.parent = vrPlayArea.transform;
            wxrHandlersManager.transform.ResetTransformation();
        }
Пример #8
0
 public static void StopVibrating(string virtualVibrator)
 {
     QuickBaseVibratorManager[] vManagers = QuickSingletonManager.GetInstance <QuickVibratorManager>().GetVibratorManagers();
     foreach (QuickBaseVibratorManager m in vManagers)
     {
         m.StopVibrating(virtualVibrator);
     }
 }
Пример #9
0
        public virtual void ResetPosition()
        {
            Animator animator = QuickSingletonManager.GetInstance <QuickVRManager>().GetAnimatorTarget();
            //Vector3 fwd = animator.transform.forward;
            Vector3 fwd = Vector3.ProjectOnPlane(QuickVRCameraController.GetCamera().transform.forward, animator.transform.up);

            transform.position = animator.GetBoneTransform(HumanBodyBones.Head).position + fwd * 3;
            transform.forward  = fwd;
        }
        protected virtual void Start()
        {
            QuickVRPlayArea vrPlayArea = QuickSingletonManager.GetInstance <QuickVRPlayArea>();

            _leftHand = Instantiate(Resources.Load <QuickOVRHand>("Prefabs/pf_QuickOVRHandLeft"), vrPlayArea.GetVRNode(HumanBodyBones.LeftHand).transform);
            _leftHand.transform.ResetTransformation();

            _rightHand = Instantiate(Resources.Load <QuickOVRHand>("Prefabs/pf_QuickOVRHandRight"), vrPlayArea.GetVRNode(HumanBodyBones.RightHand).transform);
            _rightHand.transform.ResetTransformation();
        }
Пример #11
0
        protected override void Awake()
        {
            base.Awake();

            _vrPlayArea = QuickSingletonManager.GetInstance <QuickVRPlayArea>();
            _vrPlayArea.transform.parent = transform;

            CreateVRCursors();
            CreateFootPrints();
        }
Пример #12
0
 public static void Vibrate(string virtualVibrator, float timeOut = 0.15f)
 {
     QuickBaseVibratorManager[] vManagers = QuickSingletonManager.GetInstance <QuickVibratorManager>().GetVibratorManagers();
     foreach (QuickBaseVibratorManager m in vManagers)
     {
         if (m._active)
         {
             m.Vibrate(virtualVibrator, timeOut);
         }
     }
 }
Пример #13
0
        public virtual void ResetAllMapping()
        {
            _vibratorMapping.Clear();

            int numVibrators = QuickSingletonManager.GetInstance <QuickVibratorManager>().GetNumVibrators();

            for (int i = 0; i < numVibrators; i++)
            {
                AddVibratorMapping();
            }
        }
Пример #14
0
 protected virtual void UpdateCameraRotationXR()
 {
     //On the legacy XRMode, the camera is automatically rotated with the movement of the HMD. In The XRPlugin mode, we
     //have to manually apply the rotation of the HMD to the camera.
     if (QuickSingletonManager.GetInstance <QuickVRManager>()._XRMode == QuickVRManager.XRMode.XRPlugin)
     {
         QuickVRNode vrNodeHead = QuickSingletonManager.GetInstance <QuickVRPlayArea>().GetVRNode(HumanBodyBones.Head);
         vrNodeHead.UpdateState();
         _camera.transform.localRotation = vrNodeHead.transform.localRotation;
     }
 }
Пример #15
0
        protected virtual void Awake()
        {
            _cameraFade = QuickSingletonManager.GetInstance <CameraFade>();
            if (!_pfTrajectoryTarget)
            {
                _pfTrajectoryTarget = Resources.Load <Transform>("Prefabs/pf_QuickTeleportTarget");
            }
            _trajectoryTarget = Instantiate <Transform>(_pfTrajectoryTarget);

            SetTrajectoryVisible(false);
        }
        protected virtual void Awake()
        {
            Reset();

            _guiCalibration = QuickSingletonManager.GetInstance <QuickUserGUICalibration>();
            _vrManager      = QuickSingletonManager.GetInstance <QuickVRManager>();
            //_calibrationAssisted = !QuickUtils.IsMobileTarget();
            _instructionsManager = QuickSingletonManager.GetInstance <QuickInstructionsManager>();

            InitGameConfiguration();

            AwakePlayer();
        }
Пример #17
0
        protected virtual void Awake()
        {
            _interactionManager = QuickSingletonManager.GetInstance <QuickVRInteractionManager>();

            _interactorGrabDirect  = CreateInteractor(_interactionManager._pfInteractorGrabDirect);
            _interactorGrabRay     = CreateInteractor(_interactionManager._pfInteractorGrabRay);
            _interactorTeleportRay = CreateInteractor(_interactionManager._pfInteractorTeleportRay);
            _interactorUIRay       = CreateInteractor(_interactionManager._pfInteractorUIRay);

            EnableInteractorGrab(false);
            EnableInteractorTeleport(false);
            EnableInteractorUI(false);
        }
Пример #18
0
        public virtual string GetVibratorMapping(string virtualVibrator)
        {
            List <string> virtualVibrators = QuickSingletonManager.GetInstance <QuickVibratorManager>().GetVirtualVibrators();

            for (int i = 0; i < virtualVibrators.Count; i++)
            {
                if (virtualVibrators[i] == virtualVibrator)
                {
                    return(_vibratorMapping[i]);
                }
            }

            return(BaseInputManager.NULL_MAPPING);
        }
Пример #19
0
        protected static void Init()
        {
            Camera tmpCamera = Camera.main;

            QuickVRCameraController cameraController = QuickSingletonManager.GetInstance <QuickVRCameraController>();
            QuickWebXRCamera        wxrCameras       = cameraController.transform.CreateChild("WebXRCameras").GetOrCreateComponent <QuickWebXRCamera>();

            if (tmpCamera)
            {
                wxrCameras.transform.position = tmpCamera.transform.position;
                wxrCameras.transform.forward  = tmpCamera.transform.forward;

                tmpCamera.gameObject.SetActive(false);
            }
        }
        protected virtual void Start()
        {
            StartPlayer();

            if (_hTracking)
            {
                QuickSingletonManager.GetInstance <CameraFade>().SetColor(Color.black);
                StartCoroutine(CoUpdate());
            }
            else
            {
                QuickVRManager.LogError("NO HEAD TRACKING FOUND!!! APPLICATION IS CLOSED");
                QuickUtils.CloseApplication();
            }
        }
Пример #21
0
 protected virtual void CheckHandsSwapped()
 {
     if (_xrControllerLeft != null && _xrControllerRight != null)
     {
         if (QuickSingletonManager.GetInstance <QuickVRPlayArea>().IsHandsSwapped())
         {
             InputSystem.SetDeviceUsage(_xrControllerLeft, CommonUsages.RightHand);
             InputSystem.SetDeviceUsage(_xrControllerRight, CommonUsages.LeftHand);
         }
         else
         {
             InputSystem.SetDeviceUsage(_xrControllerLeft, CommonUsages.LeftHand);
             InputSystem.SetDeviceUsage(_xrControllerRight, CommonUsages.RightHand);
         }
     }
 }
        protected virtual void Awake()
        {
            _ovrHandsInitializer = QuickSingletonManager.GetInstance <QuickOVRHandsInitializer>();

            _collider           = transform.GetOrCreateComponent <SphereCollider>();
            _collider.radius    = 0.5f;
            _collider.isTrigger = true;

            _rigidBody             = transform.GetOrCreateComponent <Rigidbody>();
            _rigidBody.isKinematic = true;

            _debugger = transform.CreateChild("__Debugger__");
            _debugger.GetOrCreateComponent <MeshRenderer>().material = Resources.Load <Material>("Materials/QuickDiffuseRed");
            _debugger.GetOrCreateComponent <MeshFilter>().mesh       = QuickUtils.GetUnityPrimitiveMesh(PrimitiveType.Sphere);
            _debugger.gameObject.SetActive(false);
        }
        public virtual void Finish()
        {
            if (_state != State.StagesPost)
            {
                _state = State.StagesPost;

                //Kill the pre and main stages
                _stagesPre.gameObject.SetActive(false);
                _stagesMain.gameObject.SetActive(false);
                QuickSingletonManager.GetInstance <QuickInstructionsManager>().Stop();

                QuickStageBase.ClearStackStages();

                QuickVRManager.Log("Elapsed Time = " + _timeRunning.ToString("f3") + " seconds");
                _stagesPost.Init();
            }
        }
Пример #24
0
        protected virtual void Awake()
        {
            Reset();

            _vrPlayArea       = QuickSingletonManager.GetInstance <QuickVRPlayArea>();
            _cameraController = QuickSingletonManager.GetInstance <QuickVRCameraController>();
            _inputManager     = QuickSingletonManager.GetInstance <InputManager>();
            _fpsCounter       = QuickSingletonManager.GetInstance <PerformanceFPS>();

            _copyPose = gameObject.GetOrCreateComponent <QuickCopyPoseBase>();
            //_copyPose = gameObject.GetOrCreateComponent<QuickCopyPoseDirect>();
            _copyPose.enabled = false;

            //Legacy XR Mode is deprecated on 2020 onwards.
#if UNITY_2020_1_OR_NEWER
            _XRMode = XRMode.XRPlugin;
#endif
        }
        protected override void DrawGUI()
        {
            base.DrawGUI();

            _inputManager     = QuickSingletonManager.GetInstance <InputManager>();
            _baseInputManager = target as BaseInputManager;

            _axisCodes   = _baseInputManager.GetAxisCodes();
            _buttonCodes = _baseInputManager.GetButtonCodes();

            EditorGUI.BeginChangeCheck();
            DrawAxesMapping();
            EditorGUILayout.Separator();
            DrawButtonsMapping();
            if (EditorGUI.EndChangeCheck())
            {
                QuickUtilsEditor.MarkSceneDirty();
            }
        }
Пример #26
0
        protected override void DrawGUI()
        {
            _vibratorManager     = QuickSingletonManager.GetInstance <QuickVibratorManager>();
            _baseVibratorManager = target as QuickBaseVibratorManager;

            _vibratorCodes = _baseVibratorManager.GetVibratorCodes();

            DrawVibratorsMapping();
            EditorGUILayout.Separator();
            if (DrawButton(WARNING_TITLE))
            {
                if (EditorUtility.DisplayDialog(WARNING_TITLE + "?", WARNING_MESSAGE + target.name + "?", "Confirm", "Cancel"))
                {
                    _baseVibratorManager.ResetAllMapping();
                }
            }

            base.DrawGUI();
        }
Пример #27
0
        protected virtual void Awake()
        {
            _vrManager = QuickSingletonManager.GetInstance <QuickVRManager>();
            QuickVRCameraController cameraController = QuickSingletonManager.GetInstance <QuickVRCameraController>();

            cameraController._visibleLayers &= ~(1 << (int)LayerMask.NameToLayer("Hair"));

            _animator = GetComponent <Animator>();

            Renderer[] renderers = GetComponentsInChildren <Renderer>();

            foreach (Renderer r in renderers)
            {
                if (r.name == "Hair")
                {
                    _hairRenderer = r;
                    break;
                }
            }
        }
Пример #28
0
        protected virtual void OnEndMove(LocomotionSystem lSystem)
        {
            Animator animator = _vrManager.GetAnimatorTarget();
            Camera   cam      = QuickVRCameraController.GetCamera();

            if (animator && cam)
            {
                QuickVRPlayArea playArea = QuickSingletonManager.GetInstance <QuickVRPlayArea>();
                Transform       tmp      = playArea.transform.parent;
                playArea.transform.parent = null;

                Vector3 fwd       = animator.transform.forward;
                Vector3 rotAxis   = animator.transform.up;
                Vector3 targetFwd = Vector3.ProjectOnPlane(cam.transform.forward, rotAxis);

                animator.GetBoneTransform(HumanBodyBones.Head).Rotate(rotAxis, Vector3.SignedAngle(targetFwd, fwd, rotAxis), Space.World);
                animator.transform.forward = targetFwd;

                playArea.transform.parent = tmp;
            }
        }
Пример #29
0
        protected virtual void Awake()
        {
            Reset();
            CheckPrefabs();
            CheckEventSystem();

            _vrManager            = QuickSingletonManager.GetInstance <QuickVRManager>();
            _xrInteractionManager = QuickSingletonManager.GetInstance <XRInteractionManager>();

            _interactorHandLeft         = transform.CreateChild("__InteractorHandLeft__").GetOrCreateComponent <QuickVRInteractor>();
            _interactorHandLeft._xrNode = XRNode.LeftHand;

            _interactorHandRight         = transform.CreateChild("__InteractorHandRight__").GetOrCreateComponent <QuickVRInteractor>();
            _interactorHandRight._xrNode = XRNode.RightHand;

            //By default, disable all the locomotion providers
            foreach (DefaultLocomotionProvider lProvider in QuickUtils.GetEnumValues <DefaultLocomotionProvider>())
            {
                EnableLocomotionSystem(lProvider, false);
            }

            BaseTeleportationInteractable[] teleportationInteractables = FindObjectsOfType <BaseTeleportationInteractable>();
            foreach (BaseTeleportationInteractable t in teleportationInteractables)
            {
                t.teleportationProvider = _teleportProvider;
            }

            _grabInteractables = new List <XRGrabInteractable>(FindObjectsOfType <XRGrabInteractable>());
            foreach (XRGrabInteractable g in _grabInteractables)
            {
                if (!g.attachTransform)
                {
                    //Try to find the default attach transform
                    g.attachTransform = g.transform.Find(GRAB_PIVOT_NAME);
                }
            }
        }
Пример #30
0
 protected virtual void Awake()
 {
     _instructionsManager = QuickSingletonManager.GetInstance <QuickInstructionsManager>();
     _gameManager         = QuickSingletonManager.GetInstance <QuickBaseGameManager>();
     _coManager           = QuickSingletonManager.GetInstance <QuickCoroutineManager>();
 }