/// <summary> /// This is an optional code path we might enable at some point to use the native arm model on Gear VR, rather than the custom one. /// </summary> /// <param name="needed"></param> void UpdateHandedness(bool needed) { if (!needed || (_node != XRNode.GameController)) { return; } switch (TBInput.Get3DOFHandedness()) { case TBInput.Mobile3DOFHandedness.Left: if (TBCore.GetActivePlatform() == VRPlatform.OculusPC) { _controller = OVRInput.Controller.LTouch; } else { _controller = OVRInput.Controller.LTrackedRemote; } break; case TBInput.Mobile3DOFHandedness.Right: if (TBCore.GetActivePlatform() == VRPlatform.OculusPC) { _controller = OVRInput.Controller.RTouch; } else { _controller = OVRInput.Controller.RTrackedRemote; } break; } }
void Update() { if (!_elbowTransform || !_shoulderTransform) { return; } _elbowTransform.localRotation = TBInput.GetRotation(TBInput.Controller.Mobile3DOFController); _shoulderTransform.position = Vector3.Lerp(_shoulderTransform.position, GetTargetPosition(), TBInput.GetAcceleration(TBInput.Controller.Mobile3DOFController).magnitude *Time.unscaledDeltaTime); }
public void ToggleCenteredAlignment(bool on) { if (on) { shoulderPosition = new Vector3(0f, shoulderPosition.y, shoulderPosition.z); _shoulderTransform.localPosition = shoulderPosition; } else { OnHandednessChanged(TBInput.Get3DOFHandedness()); } _centered = on; }
/// <summary> /// Runs through events. Should only be called by TBInput. /// </summary> public static void UpdateEvents() { switch (TBInput.GetActiveControlType()) { case ControlType.HandControllers: Button.UpdateButtonEvents(Controller.LHandController); Button.UpdateButtonEvents(Controller.RHandController); Touch.UpdateButtonEvents(Controller.LHandController); Touch.UpdateButtonEvents(Controller.RHandController); break; default: Button.UpdateButtonEvents(Controller.Active); Touch.UpdateButtonEvents(Controller.Active); break; } }
public static void InitializeStartup() { // Initialize all required TButt components. switch (TBCore.GetActivePlatform()) { case VRPlatform.None: // On platforms where we have to first initialize the HMD, wait for that to finish before initializing TButt. TBCore.instance.StartCheckingForHMD(); break; default: TBLogging.LogMessage("TBCore is starting up..."); TBSettings.Initialize(); TBInput.Initialize(GetActivePlatform()); instance.InitializePerScene(); DontDestroyOnLoad(instance.gameObject); TBLogging.LogMessage("TBCore has finished starting up."); _initialized = true; break; } }
void Start() { OnHandednessChanged(TBInput.Get3DOFHandedness()); // Attach the arm to the camera container. _shoulderTransform.SetParent(TBCameraRig.instance.transform); _shoulderTransform.localRotation = Quaternion.identity; _shoulderTransform.localPosition = shoulderPosition; // Attach the elbow to the arm pivot. _elbowTransform.SetParent(_shoulderTransform); _elbowTransform.localPosition = elbowPosition; // Attach the hand to the elbow. _handTransform.SetParent(_elbowTransform); _handTransform.localPosition = handPosition; _pointerSourceTransform.MakeZeroedChildOf(_handTransform); SetPointerSourceRotation(); _shoulderTransform.localScale = Vector3.one; }
/// <summary> /// Runs through events. Should only be called by TBInput. /// </summary> public static void UpdateButtonEvents(Controller controller) { // Action Button Events if (OnAction1TouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Action1, controller)) { OnAction1TouchDown(); } } if (OnAction1TouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Action1, controller)) { OnAction1TouchUp(); } } if (OnAction2TouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Action2, controller)) { OnAction2TouchDown(); } } if (OnAction2TouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Action2, controller)) { OnAction2TouchUp(); } } if (OnAction3TouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Action3, controller)) { OnAction3TouchDown(); } } if (OnAction3TouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Action3, controller)) { OnAction3TouchUp(); } } if (OnAction4TouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Action4, controller)) { OnAction4TouchDown(); } } if (OnAction4TouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Action4, controller)) { OnAction4TouchUp(); } } // Trigger Events if (OnPrimaryTriggerTouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.PrimaryTrigger, controller)) { OnPrimaryTriggerTouchDown(); } } if (OnPrimaryTriggerTouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.PrimaryTrigger, controller)) { OnPrimaryTriggerTouchUp(); } } if (OnSecondaryTriggerTouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.SecondaryTrigger, controller)) { OnSecondaryTriggerTouchDown(); } } if (OnSecondaryTriggerTouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.SecondaryTrigger, controller)) { OnSecondaryTriggerTouchUp(); } } // Start / Options Events if (OnStartTouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Start, controller)) { OnStartTouchDown(); } } if (OnStartTouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Start, controller)) { OnStartTouchUp(); } } if (OnOptionsTouchDown != null) { if (TBInput.GetTouchDown(TBInput.Button.Options, controller)) { OnOptionsTouchDown(); } } if (OnOptionsTouchUp != null) { if (TBInput.GetTouchUp(TBInput.Button.Options, controller)) { OnOptionsTouchUp(); } } }
public static void Initialize() { if (_nodes != null) { _nodes.Clear(); } // Add tracked controller nodes under the camera rig if we need them. if (TBSettings.GetControlSettings().supportsHandControllers) { switch (TBCore.GetActivePlatform()) { case VRPlatform.OculusPC: case VRPlatform.SteamVR: case VRPlatform.PlayStationVR: case VRPlatform.WindowsMR: AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); break; case VRPlatform.OculusMobile: if (TBInput.GetControllerModel(TBInput.Controller.RHandController) != VRController.None) { AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); } break; case VRPlatform.Daydream: if (TBInput.GetControllerModel(TBInput.Controller.RHandController) != VRController.None) { AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); } break; default: break; } } if (TBSettings.GetControlSettings().supports3DOFControllers) { if (TBInput.GetControllerModel(TBInput.Controller.Mobile3DOFController) != VRController.None) { TBCameraRig.instance.GetTrackingVolume().gameObject.AddComponent <TB3DOFArmModel>().Initialize(); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.GameController); } } if (TBSettings.GetControlSettings().supportsGamepad) { switch (TBCore.GetActivePlatform()) { case VRPlatform.PlayStationVR: AddTrackedDeviceForNode(UnityEngine.XR.XRNode.GameController); break; default: break; } } }