protected virtual void OnDisable() { _vrPlayArea.GetVRNode(HumanBodyBones.Head).OnCalibrateVRNode -= OnCalibrateVRNodeHead; _vrPlayArea.GetVRNode(HumanBodyBones.Hips).OnCalibrateVRNode -= OnCalibrateVRNodeHips; _vrPlayArea.GetVRNode(HumanBodyBones.LeftHand).OnCalibrateVRNode -= OnCalibrateVRNodeLeftHand; _vrPlayArea.GetVRNode(HumanBodyBones.RightHand).OnCalibrateVRNode -= OnCalibrateVRNodeRightHand; _vrPlayArea.GetVRNode(HumanBodyBones.LeftFoot).OnCalibrateVRNode -= OnCalibrateVRNodeFoot; _vrPlayArea.GetVRNode(HumanBodyBones.RightFoot).OnCalibrateVRNode -= OnCalibrateVRNodeFoot; if (!QuickVRManager.IsXREnabled()) { QuickVRManager.OnPostUpdateIKTargets -= UpdateHeadRotationMono; } }
public static bool Invoke(object obj, string methodName, object[] parameters = null) { System.Reflection.MethodInfo m = obj.GetType().GetMethod(methodName); if (m != null) { m.Invoke(obj, parameters); } else { QuickVRManager.LogError("Invoke failed!!! The method " + methodName + " does not exist on class " + obj.GetType().FullName); } return(m != null); }
public QuickTransformAnimationCurve(ref List <Vector3> positions, ref List <Quaternion> rotations, ref List <float> timeStamps) { if (positions.Count != timeStamps.Count || rotations.Count != timeStamps.Count) { QuickVRManager.LogWarning("Lists of positions, rotations and timeStamps have different size"); return; } for (int i = 0; i < timeStamps.Count; i++) // for every captured keyframe { AddPosition(timeStamps[i], positions[i]); AddRotation(timeStamps[i], rotations[i]); } }
public static void LoadFromXml(this ScriptableObject obj, string path) { if (path.Length == 0) { return; } XmlDocument doc = new XmlDocument(); doc.Load(path); QuickVRManager.Log("path = " + path); LoadClass(obj, (XmlElement)doc.FirstChild.FirstChild); }
protected override IEnumerator CoUpdate() { _guiCalibration.gameObject.SetActive(true); //Show the logos if any yield return(StartCoroutine(CoShowLogos())); if (QuickVRManager.IsXREnabled()) { yield return(StartCoroutine(CoUpdateStateForwardDirection())); //Wait for the VR Devices Calibration } _guiCalibration.gameObject.SetActive(false); _vrManager.RequestCalibration(); }
protected virtual void OnFinishStagesPre() { _state = State.StagesMain; QuickVRManager.Log("APPLICATION READY"); QuickVRManager.Log("Time.time = " + Time.time); if (OnRunning != null) { OnRunning(); } //Execute the stagesMain _timeRunning = 0.0f; }
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(); } }
protected virtual void LoadSceneAdditive(string sceneName, bool allowSceneActivation, bool isAsync) { //We can only Load a scene if it has not yet been loaded, or it is is preloaded if ( !_loadedScenes.TryGetValue(sceneName, out SceneData sceneData) || allowSceneActivation && (sceneData._state == SceneState.Loading || sceneData._state == SceneState.Preloaded) ) { StartCoroutine(CoLoadSceneAdditive(sceneName, allowSceneActivation, isAsync)); } else { QuickVRManager.LogWarning(sceneName + " is already " + SceneState.Loaded + ". Please, unload it first"); } }
protected override void OnEnable() { base.OnEnable(); _vrPlayArea.GetVRNode(HumanBodyBones.Head).OnCalibrateVRNode += OnCalibrateVRNodeHead; _vrPlayArea.GetVRNode(HumanBodyBones.Hips).OnCalibrateVRNode += OnCalibrateVRNodeHips; _vrPlayArea.GetVRNode(HumanBodyBones.LeftHand).OnCalibrateVRNode += OnCalibrateVRNodeLeftHand; _vrPlayArea.GetVRNode(HumanBodyBones.RightHand).OnCalibrateVRNode += OnCalibrateVRNodeRightHand; _vrPlayArea.GetVRNode(HumanBodyBones.LeftFoot).OnCalibrateVRNode += OnCalibrateVRNodeFoot; _vrPlayArea.GetVRNode(HumanBodyBones.RightFoot).OnCalibrateVRNode += OnCalibrateVRNodeFoot; if (!QuickVRManager.IsXREnabled()) { QuickVRManager.OnPostUpdateIKTargets += UpdateHeadRotationMono; } }
public virtual void Init() { PushStage(this); enabled = true; _timeStart = Time.time; QuickVRManager.Log("RUNNING STAGE: " + GetName()); if (OnInit != null) { OnInit(); } StartCoroutine(CoUpdateBase()); }
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(); } }
protected virtual void InitHipsAndHands(List <XRNodeState> bodyTrackers) { if (bodyTrackers.Count != 3) { QuickVRManager.LogError("BODY TRACKERS LIST MUST CONTAIN EXACTLY 3 ELEMENTS"); return; } Vector3 pos0; Vector3 pos1; Vector3 pos2; bodyTrackers[0].TryGetPosition(out pos0); bodyTrackers[1].TryGetPosition(out pos1); bodyTrackers[2].TryGetPosition(out pos2); Vector3 scale = new Vector3(1, 0, 1); pos0 = Vector3.Scale(pos0, scale); pos1 = Vector3.Scale(pos1, scale); pos2 = Vector3.Scale(pos2, scale); if (Vector3.Dot(pos1 - pos0, pos2 - pos0) < 0) { //0 is the hips tracker InitVRNode(HumanBodyBones.Hips, bodyTrackers[0]); InitVRNode(HumanBodyBones.LeftHand, bodyTrackers[1]); InitVRNode(HumanBodyBones.RightHand, bodyTrackers[2]); } else if (Vector3.Dot(pos0 - pos1, pos2 - pos1) < 0) { //1 is the hips tracker InitVRNode(HumanBodyBones.Hips, bodyTrackers[1]); InitVRNode(HumanBodyBones.LeftHand, bodyTrackers[0]); InitVRNode(HumanBodyBones.RightHand, bodyTrackers[2]); } else { //2 is the hips tracker InitVRNode(HumanBodyBones.Hips, bodyTrackers[2]); InitVRNode(HumanBodyBones.LeftHand, bodyTrackers[0]); InitVRNode(HumanBodyBones.RightHand, bodyTrackers[1]); } }
public static DateTime GetDateOnline() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.google.com"); try { var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; return(DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal)); } catch { QuickVRManager.Log("NO INTERNET CONNECTION!!!"); return(new DateTime()); } }
protected virtual IEnumerator CoUpdate() { //Check if the game has expired bool gameExpired = false; if (_useExpirationDate) { if (!QuickUtils.IsInternetConnection()) { _guiCalibration.SetCalibrationInstructions(QuickUserGUICalibration.CalibrationStep.InternetConnectionRequired); gameExpired = true; } else { int day, month, year; QuickUtils.GetDateOnline(out day, out month, out year); DateTime timeNow = new DateTime(year, month, day); DateTime timeExp = new DateTime(_expirationYear, _expirationMonth, _expirationDay); if (timeNow >= timeExp) { _guiCalibration.SetCalibrationInstructions(QuickUserGUICalibration.CalibrationStep.TimeExpired); gameExpired = true; QuickVRManager.Log("GAME DATE EXPIRED!!!"); } } } if (gameExpired) { while (!InputManager.GetButtonDown(InputManager.DEFAULT_BUTTON_CONTINUE)) { yield return(null); } QuickUtils.CloseApplication(); } else { //Execute the stagesPre _state = State.StagesPre; _stagesPre.Init(); } }
protected virtual void Update() { if (!QuickVRManager.IsXREnabled()) { UpdateKeyboardMono(); } _textInput.text = _text; if (_timeBlinking < _blinkTime) { _textInput.text += "|"; } _timeBlinking += Time.deltaTime; if (_timeBlinking > _blinkTime * 2) { _timeBlinking = 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; } } }
protected virtual void Awake() { if (!Camera.main) { Camera camera = _pfCamera ? Instantiate <Camera>(_pfCamera) : new GameObject().GetOrCreateComponent <Camera>(); camera.name = "__Camera__"; camera.tag = "MainCamera"; camera.gameObject.GetOrCreateComponent <FlareLayer>(); } _camera = Camera.main; _camera.transform.parent = transform; _camera.transform.ResetTransformation(); _camera.GetOrCreateComponent <AudioListener>(); if (!QuickVRManager.IsXREnabled()) { _camera.fieldOfView = 70.0f;//90.0f; } QuickUICursor.CreateVRCursor(QuickUICursor.Role.Head, _camera.transform); }
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); } } }
public static QuickUICursor GetVRCursorMain() { return(GetVRCursor(QuickVRManager.IsXREnabled() ? Role.RightHand : Role.Head)); }
public virtual void Calibrate() { //POSSIBLE TRACKER CONFIGURATIONS //1 -> Head //3 -> Head + Hands //4 -> Head + Hands + Hips //6 -> Head + Hands + Hips + Feet //10 -> Head + Hands + Hips + Feet + Elbows + Knees _isHandsSwaped = false; List <InputDevice> bodyTrackers = GetBodyTrackers(); int numTrackers = bodyTrackers.Count; QuickVRManager.Log("NUM BODY TRACKERS = " + numTrackers); //Try to assign the default nodes for Head and Hands QuickVRNode nodeHMD = GetVRNode(HumanBodyBones.Head); QuickVRNode nodeLeftHand = GetVRNode(HumanBodyBones.LeftHand); QuickVRNode nodeRightHand = GetVRNode(HumanBodyBones.RightHand); nodeHMD._inputDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head); nodeLeftHand._inputDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand); nodeRightHand._inputDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); if (numTrackers == 1 || numTrackers == 3 || numTrackers == 4 || numTrackers == 6 || numTrackers == 10) { if (!nodeHMD._inputDevice.isValid) { //The head will always be the upper body tracker nodeHMD._inputDevice = bodyTrackers[0]; } if (numTrackers == 3) { //Head + Hands if (!nodeLeftHand._inputDevice.isValid) { nodeLeftHand._inputDevice = bodyTrackers[1]; } if (!nodeRightHand._inputDevice.isValid) { nodeRightHand._inputDevice = bodyTrackers[2]; } } //else if (numTrackers == 4) //{ // //Head + Hands + Hips // //1) Remove the head node from the list // bodyTrackers.RemoveAt(0); // //2) The hips is the node that is "in the middle", i.e., the hands are in opposite sides of the hips node. // InitHipsAndHands(bodyTrackers); //} //else if (numTrackers == 6) //{ // //Head + Hands + Hips + Feet // //1) The Feet are the trackers with the lower y // InitVRNode(HumanBodyBones.LeftFoot, bodyTrackers[5]); // InitVRNode(HumanBodyBones.RightFoot, bodyTrackers[4]); // //2) Remove the unnecessary nodes and proceed as in the previous case // bodyTrackers.RemoveAt(5); // bodyTrackers.RemoveAt(4); // bodyTrackers.RemoveAt(0); // InitHipsAndHands(bodyTrackers); //} //UpdateVRNodes(); //IsVRNodesSwaped(HumanBodyBones.LeftFoot, HumanBodyBones.RightFoot); } else { QuickVRManager.LogWarning("BAD NUMBER OF BODY TRACKERS!!!"); } UpdateVRNodes(); _isHandsSwaped = IsVRNodesSwaped(HumanBodyBones.LeftHand, HumanBodyBones.RightHand); QuickVRManager.Log("handsSwaped = " + _isHandsSwaped); foreach (HumanBodyBones t in QuickVRNode.GetTypeList()) { QuickVRNode n = GetVRNode(t); if (n) { n.Calibrate(); } } }