示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     // To make left and right handed Go controllers easier, check at runtime which is active and make both hands refer to the same controller.
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go)
     {
         if (OVRInput.GetDominantHand() == OVRInput.Handedness.LeftHanded)
         {
             hand[1] = hand[0];
         }
         else
         {
             hand[0] = hand[1];
         }
     }
 }
示例#2
0
    public static bool isLeftHanded()
    {
        bool result = true;

        switch (getActivePlatform())
        {
        case DeviceOptions.OculusGo:
            result = (OVRInput.GetDominantHand() == OVRInput.Handedness.LeftHanded);
            break;

        case DeviceOptions.Daydream:
            result = (GvrSettings.Handedness == GvrSettings.UserPrefsHandedness.Left);
            break;
        }
        return(result);
    }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        // Set starting active hand
        OVRInput.Handedness handedness = OVRInput.GetDominantHand();
        switch (handedness)
        {
        case OVRInput.Handedness.LeftHanded:
            DominantHand = OVRInput.Controller.LTouch;
            break;

        case OVRInput.Handedness.RightHanded:
            DominantHand = OVRInput.Controller.RTouch;
            break;

        case OVRInput.Handedness.Unsupported:
            DominantHand = OVRInput.Controller.RTouch;
            break;
        }
    }
        protected override void UpdateData()
        {
            _handDataAsset.Config      = Config;
            _handDataAsset.IsDataValid = true;
            _handDataAsset.IsConnected = (OVRInput.GetConnectedControllers() & _ovrController) > 0;
            if (!_handDataAsset.IsConnected)
            {
                // revert state fields to their defaults
                _handDataAsset.IsTracked         = default;
                _handDataAsset.RootPoseOrigin    = default;
                _handDataAsset.PointerPoseOrigin = default;
                _handDataAsset.IsHighConfidence  = default;
                for (var fingerIdx = 0; fingerIdx < Constants.NUM_FINGERS; fingerIdx++)
                {
                    _handDataAsset.IsFingerPinching[fingerIdx]       = default;
                    _handDataAsset.IsFingerHighConfidence[fingerIdx] = default;
                }
                return;
            }

            _handDataAsset.IsTracked        = true;
            _handDataAsset.IsHighConfidence = true;
            _handDataAsset.HandScale        = 1f;

            _handDataAsset.IsDominantHand =
                OVRInput.GetDominantHand() == OVRInput.Handedness.LeftHanded &&
                _handedness == Handedness.Left ||
                (OVRInput.GetDominantHand() == OVRInput.Handedness.RightHanded &&
                 _handedness == Handedness.Right);

            float indexStrength = _pinchCurve.Evaluate(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, _ovrController));
            float gripStrength  = _pinchCurve.Evaluate(OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, _ovrController));

            _handDataAsset.IsFingerHighConfidence[(int)HandFinger.Thumb] = true;
            _handDataAsset.IsFingerPinching[(int)HandFinger.Thumb]       = indexStrength >= 1f || gripStrength >= 1f;
            _handDataAsset.FingerPinchStrength[(int)HandFinger.Thumb]    = Mathf.Max(indexStrength, gripStrength);

            _handDataAsset.IsFingerHighConfidence[(int)HandFinger.Index] = true;
            _handDataAsset.IsFingerPinching[(int)HandFinger.Index]       = indexStrength >= 1f;
            _handDataAsset.FingerPinchStrength[(int)HandFinger.Index]    = indexStrength;

            _handDataAsset.IsFingerHighConfidence[(int)HandFinger.Middle] = true;
            _handDataAsset.IsFingerPinching[(int)HandFinger.Middle]       = gripStrength >= 1f;
            _handDataAsset.FingerPinchStrength[(int)HandFinger.Middle]    = gripStrength;

            _handDataAsset.IsFingerHighConfidence[(int)HandFinger.Ring] = true;
            _handDataAsset.IsFingerPinching[(int)HandFinger.Ring]       = gripStrength >= 1f;
            _handDataAsset.FingerPinchStrength[(int)HandFinger.Ring]    = gripStrength;

            _handDataAsset.IsFingerHighConfidence[(int)HandFinger.Pinky] = true;
            _handDataAsset.IsFingerPinching[(int)HandFinger.Pinky]       = gripStrength >= 1f;
            _handDataAsset.FingerPinchStrength[(int)HandFinger.Pinky]    = gripStrength;

            _handDataAsset.PointerPoseOrigin = PoseOrigin.RawTrackedPose;
            _handDataAsset.PointerPose       = new Pose(
                OVRInput.GetLocalControllerPosition(_ovrController),
                OVRInput.GetLocalControllerRotation(_ovrController));

            for (int i = 0; i < _bones.Length; i++)
            {
                _handDataAsset.Joints[i] = _bones[i].localRotation;
            }

            _handDataAsset.Joints[0] = WristFixupRotation;

            // Convert controller pose from world to tracking space.
            Pose pose = new Pose(_ovrControllerAnchor.position, _ovrControllerAnchor.rotation);

            pose = Config.TrackingToWorldTransformer.ToTrackingPose(pose);

            PoseUtils.Multiply(pose, _poseOffset, ref _handDataAsset.Root);
            _handDataAsset.RootPoseOrigin = PoseOrigin.RawTrackedPose;
        }