コード例 #1
0
        protected virtual void DetectController()
        {
            controllerType = VRTK_DeviceFinder.GetCurrentControllerType(controllerReference);
            if (controllerType != SDK_BaseController.ControllerType.Undefined)
            {
                if (setFingersForControllerType)
                {
                    switch (controllerType)
                    {
                    case SDK_BaseController.ControllerType.SteamVR_ViveWand:
                    case SDK_BaseController.ControllerType.SteamVR_WindowsMRController:
                    case SDK_BaseController.ControllerType.WindowsMR_MotionController:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Axis;
                        middleState      = VRTK_ControllerEvents.AxisType.Digital;
                        ringState        = VRTK_ControllerEvents.AxisType.Digital;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Digital;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Digital;
                        break;

                    case SDK_BaseController.ControllerType.Oculus_OculusTouch:
                    case SDK_BaseController.ControllerType.SteamVR_OculusTouch:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Axis;
                        middleState      = VRTK_ControllerEvents.AxisType.Digital;
                        ringState        = VRTK_ControllerEvents.AxisType.Digital;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Digital;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Axis;
                        break;

                    case SDK_BaseController.ControllerType.SteamVR_ValveKnuckles:
                        thumbState            = VRTK_ControllerEvents.AxisType.Digital;
                        indexState            = VRTK_ControllerEvents.AxisType.SenseAxis;
                        middleState           = VRTK_ControllerEvents.AxisType.SenseAxis;
                        ringState             = VRTK_ControllerEvents.AxisType.SenseAxis;
                        pinkyState            = VRTK_ControllerEvents.AxisType.SenseAxis;
                        threeFingerState      = VRTK_ControllerEvents.AxisType.SenseAxis;
                        threeFingerAxisButton = SDK_BaseController.ButtonTypes.StartMenu;
                        break;

                    default:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Digital;
                        middleState      = VRTK_ControllerEvents.AxisType.Digital;
                        ringState        = VRTK_ControllerEvents.AxisType.Digital;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Digital;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Digital;
                        break;
                    }
                }
                UnsubscribeEvents();
                SubscribeEvents();
                if (mirrorModel)
                {
                    mirrorModel = false;
                    MirrorHand();
                }
            }
        }
コード例 #2
0
        protected virtual void DetectController()
        {
            controllerType = VRTK_DeviceFinder.GetCurrentControllerType();
            if (controllerType != SDK_BaseController.ControllerType.Undefined)
            {
                if (setFingersForControllerType)
                {
                    switch (controllerType)
                    {
                    case SDK_BaseController.ControllerType.SteamVR_ViveWand:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Axis;
                        middleState      = VRTK_ControllerEvents.AxisType.Digital;
                        ringState        = VRTK_ControllerEvents.AxisType.Digital;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Digital;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Digital;
                        break;

                    case SDK_BaseController.ControllerType.Oculus_OculusTouch:
                    case SDK_BaseController.ControllerType.SteamVR_OculusTouch:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Axis;
                        middleState      = VRTK_ControllerEvents.AxisType.Axis;
                        ringState        = VRTK_ControllerEvents.AxisType.Axis;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Axis;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Axis;
                        break;

                    default:
                        thumbState       = VRTK_ControllerEvents.AxisType.Digital;
                        indexState       = VRTK_ControllerEvents.AxisType.Digital;
                        middleState      = VRTK_ControllerEvents.AxisType.Digital;
                        ringState        = VRTK_ControllerEvents.AxisType.Digital;
                        pinkyState       = VRTK_ControllerEvents.AxisType.Digital;
                        threeFingerState = VRTK_ControllerEvents.AxisType.Digital;
                        break;
                    }
                }
                UnsubscribeEvents();
                SubscribeEvents();
                if (mirrorModel)
                {
                    mirrorModel = false;
                    MirrorHand();
                }
            }
        }
コード例 #3
0
 protected virtual void ProcessFinger(VRTK_ControllerEvents.AxisType state, int arrayIndex)
 {
     axisTypes[arrayIndex] = state;
     if (state == VRTK_ControllerEvents.AxisType.Digital)
     {
         if (fingerChangeStates[arrayIndex])
         {
             fingerChangeStates[arrayIndex] = false;
             float startAxis  = (fingerStates[arrayIndex] ? 0f : 1f);
             float targetAxis = (fingerStates[arrayIndex] ? 1f : 0f);
             LerpChangePosition(arrayIndex, startAxis, targetAxis, animationSnapSpeed);
         }
     }
     else
     {
         SetFingerPosition(arrayIndex, fingerAxis[arrayIndex]);
     }
 }
コード例 #4
0
        protected virtual void ProcessFinger(VRTK_ControllerEvents.AxisType state, int arrayIndex)
        {
            axisTypes[arrayIndex] = state;
            if (overrideAxisValues[arrayIndex] != OverrideState.NoOverride)
            {
                if (fingerAxis[arrayIndex] != fingerForceAxis[arrayIndex])
                {
                    LerpChangePosition(arrayIndex, fingerAxis[arrayIndex], fingerForceAxis[arrayIndex], animationSnapSpeed);
                }
                else if (overrideAxisValues[arrayIndex] == OverrideState.WasOverring)
                {
                    SetOverrideValue(arrayIndex, ref overrideAxisValues, OverrideState.NoOverride);
                }
            }
            else
            {
                if (state == VRTK_ControllerEvents.AxisType.Digital)
                {
                    if (fingerChangeStates[arrayIndex])
                    {
                        fingerChangeStates[arrayIndex] = false;
                        float startAxis  = (fingerStates[arrayIndex] ? 0f : 1f);
                        float targetAxis = (fingerStates[arrayIndex] ? 1f : 0f);
                        LerpChangePosition(arrayIndex, startAxis, targetAxis, animationSnapSpeed);
                    }
                }
                else
                {
                    SetFingerPosition(arrayIndex, fingerAxis[arrayIndex]);
                }
            }

            //Final sanity check, if you're not touching anything but the override is still set, then clear the override.
            if (((interactTouch == null && interactNearTouch == null) || (interactNearTouch == null && interactTouch.GetTouchedObject() == null) || (interactNearTouch != null && interactNearTouch.GetNearTouchedObjects().Count == 0)) && overrideAxisValues[arrayIndex] != OverrideState.NoOverride)
            {
                SetOverrideValue(arrayIndex, ref overrideAxisValues, OverrideState.NoOverride);
            }
        }
コード例 #5
0
 protected virtual void UnsubscribeButtonAxisEvent(SDK_BaseController.ButtonTypes buttonType, VRTK_ControllerEvents.AxisType axisType, ControllerInteractionEventHandler eventHandler)
 {
     controllerEvents.UnsubscribeToAxisAliasEvent(buttonType, axisType, eventHandler);
 }