コード例 #1
0
        public void _UpdateHands(Vox.Hands.HandController voxHands, SteamVR_Input_Sources source)
        {
            if (selectionHands.Count == 0)
            {
                return;
            }

            var position      = SteamVR_Input.GetVector2("default", "Selection", source);
            var elementsCount = selectionHands.Count;
            int index         = 0;

            if (position != Vector2.zero)
            {
                var angle = (Vector2.SignedAngle(Vector2.down, position) + 180) / 360;
                index = Mathf.FloorToInt(((angle * elementsCount) + 0.5f) % elementsCount);
            }

            //var blendShapeKey = new BlendShapeKey (element.blendShapeName);
            var targetWeight = SteamVR_Input.GetSingle("default", "GrabGrip", source);

            //var targetWeight = element.GetValue (HandType);

            //element.weight += (targetWeight - element.weight) * Time.deltaTime * element.speed;
            //element.weight = Mathf.Clamp01 (element.weight);

            voxHands.SetHandPose(selectionHands[index].presetName, targetWeight);
        }
コード例 #2
0
        public static Vector2 GetJoystickState(XRNode hand)
        {
            Vector2 value = Vector2.zero;

#if USING_STEAMVR
            SteamVR_Input_Sources svrHand = hand == XRNode.LeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;
            value = SteamVR_Input.GetSingle("2dAxisState", svrHand, false);
#else
            InputDevice controllerDevice = InputDevices.GetDeviceAtXRNode(hand);
            if (controllerDevice.isValid)
            {
                controllerDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out value);
            }
#endif
            return(value);
        }
コード例 #3
0
        public static float GetGripState(XRNode hand)
        {
            float value = 0.0f;

#if USING_STEAMVR
            SteamVR_Input_Sources svrHand = hand == XRNode.LeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;
            value = SteamVR_Input.GetSingle("GripState", svrHand, false);
#else
            InputDevice controllerDevice = InputDevices.GetDeviceAtXRNode(hand);
            if (controllerDevice.isValid)
            {
                controllerDevice.TryGetFeatureValue(CommonUsages.grip, out value);
            }
#endif
            return(value);
        }