Beispiel #1
0
 private void UpdateHandJoints(HandTracker handTracker, FrameTime frameTime)
 {
     if (handTracker.TryLocateHandJoints(frameTime, handJointLocations))
     {
         ApplyWrist(handProxy.Wrist, HandJoint.Wrist);
         Apply(handProxy.ThumbMetacarpal, HandJoint.ThumbMetacarpal);
         Apply(handProxy.ThumbProximal, HandJoint.ThumbProximal);
         Apply(handProxy.ThumbDistal, HandJoint.ThumbDistal);
         Apply(handProxy.ThumbTip, HandJoint.ThumbTip);
         Apply(handProxy.IndexMetacarpal, HandJoint.IndexMetacarpal);
         Apply(handProxy.IndexProximal, HandJoint.IndexProximal);
         Apply(handProxy.IndexIntermediate, HandJoint.IndexIntermediate);
         Apply(handProxy.IndexDistal, HandJoint.IndexDistal);
         Apply(handProxy.IndexTip, HandJoint.IndexTip);
         Apply(handProxy.MiddleMetacarpal, HandJoint.MiddleMetacarpal);
         Apply(handProxy.MiddleProximal, HandJoint.MiddleProximal);
         Apply(handProxy.MiddleIntermediate, HandJoint.MiddleIntermediate);
         Apply(handProxy.MiddleDistal, HandJoint.MiddleDistal);
         Apply(handProxy.MiddleTip, HandJoint.MiddleTip);
         Apply(handProxy.RingMetacarpal, HandJoint.RingMetacarpal);
         Apply(handProxy.RingProximal, HandJoint.RingProximal);
         Apply(handProxy.RingIntermediate, HandJoint.RingIntermediate);
         Apply(handProxy.RingDistal, HandJoint.RingDistal);
         Apply(handProxy.RingTip, HandJoint.RingTip);
         Apply(handProxy.LittleMetacarpal, HandJoint.LittleMetacarpal);
         Apply(handProxy.LittleProximal, HandJoint.LittleProximal);
         Apply(handProxy.LittleIntermediate, HandJoint.LittleIntermediate);
         Apply(handProxy.LittleDistal, HandJoint.LittleDistal);
         Apply(handProxy.LittleTip, HandJoint.LittleTip);
     }
     else
     {
         // Disable the hand
     }
 }
 private static void UpdateHandJoints(HandTracker handTracker, Hand hand, FrameTime frameTime)
 {
     if (handTracker.TryLocateHandJoints(frameTime, HandJointLocations))
     {
         hand?.UpdateHandJoints(HandJointLocations);
     }
     else
     {
         hand?.DisableHandJoints();
     }
 }
Beispiel #3
0
        public void UpdateHandJoints(Hand hand, ref MixedRealityPose[] jointPoses)
        {
#if MSFT_OPENXR && (UNITY_STANDALONE_WIN || UNITY_WSA)
            if (handTracker != null && handTracker.TryLocateHandJoints(FrameTime.OnUpdate, locations))
            {
                if (jointPoses == null)
                {
                    jointPoses = new MixedRealityPose[ArticulatedHandPose.JointCount];
                }

                foreach (HandJoint handJoint in HandJoints)
                {
                    HandJointLocation handJointLocation = locations[(int)handJoint];

                    // We want input sources to follow the playspace, so fold in the playspace transform here to
                    // put the pose into world space.
                    Vector3    position = MixedRealityPlayspace.TransformPoint(handJointLocation.Pose.position);
                    Quaternion rotation = MixedRealityPlayspace.Rotation * handJointLocation.Pose.rotation;

                    jointPoses[ConvertToArrayIndex(handJoint)] = new MixedRealityPose(position, rotation);
                }
#else
            if (jointPoses == null)
            {
                jointPoses = new MixedRealityPose[ArticulatedHandPose.JointCount];
            }

            foreach (HandFinger finger in HandFingers)
            {
                if (hand.TryGetRootBone(out Bone rootBone) && TryReadHandJoint(rootBone, out MixedRealityPose rootPose))
                {
                    jointPoses[(int)TrackedHandJoint.Palm] = rootPose;
                }

                if (hand.TryGetFingerBones(finger, fingerBones))
                {
                    for (int i = 0; i < fingerBones.Count; i++)
                    {
                        if (TryReadHandJoint(fingerBones[i], out MixedRealityPose pose))
                        {
                            jointPoses[ConvertToArrayIndex(finger, i)] = pose;
                        }
                    }
                }
#endif // MSFT_OPENXR && (UNITY_STANDALONE_WIN || UNITY_WSA)
            }
        }
        /// <summary>
        /// Update the hand data from the device.
        /// </summary>
        /// <param name="interactionSourceState">The InteractionSourceState retrieved from the platform.</param>
        private void UpdateHandData(InputDevice inputDevice)
        {
            using (UpdateHandDataPerfMarker.Auto())
            {
#if MSFT_OPENXR
                if (handTracker != null && handTracker.TryLocateHandJoints(FrameTime.OnUpdate, locations))
                {
                    foreach (HandJoint handJoint in HandJoints)
                    {
                        HandJointLocation handJointLocation = locations[(int)handJoint];

                        // We want input sources to follow the playspace, so fold in the playspace transform here to
                        // put the pose into world space.
                        Vector3    position = MixedRealityPlayspace.TransformPoint(handJointLocation.Position);
                        Quaternion rotation = MixedRealityPlayspace.Rotation * handJointLocation.Rotation;

                        unityJointPoses[ConvertToTrackedHandJoint(handJoint)] = new MixedRealityPose(position, rotation);
                    }
#else
                if (inputDevice.TryGetFeatureValue(CommonUsages.handData, out Hand hand))
                {
                    foreach (HandFinger finger in handFingers)
                    {
                        if (hand.TryGetRootBone(out Bone rootBone))
                        {
                            ReadHandJoint(TrackedHandJoint.Wrist, rootBone);
                        }

                        if (hand.TryGetFingerBones(finger, fingerBones))
                        {
                            for (int i = 0; i < fingerBones.Count; i++)
                            {
                                ReadHandJoint(ConvertToTrackedHandJoint(finger, i), fingerBones[i]);
                            }
                        }
                    }
#endif // MSFT_OPENXR

                    handDefinition?.UpdateHandJoints(unityJointPoses);
                }
            }
        }
        public void UpdateHandJoints(InputDevice inputDevice, Dictionary <TrackedHandJoint, MixedRealityPose> jointPoses)
        {
#if MSFT_OPENXR && (UNITY_STANDALONE_WIN || UNITY_WSA)
            if (handTracker != null && handTracker.TryLocateHandJoints(FrameTime.OnUpdate, locations))
            {
                foreach (HandJoint handJoint in HandJoints)
                {
                    HandJointLocation handJointLocation = locations[(int)handJoint];

                    // We want input sources to follow the playspace, so fold in the playspace transform here to
                    // put the pose into world space.
                    Vector3    position = MixedRealityPlayspace.TransformPoint(handJointLocation.Pose.position);
                    Quaternion rotation = MixedRealityPlayspace.Rotation * handJointLocation.Pose.rotation;

                    jointPoses[ConvertToTrackedHandJoint(handJoint)] = new MixedRealityPose(position, rotation);
                }
#else
            if (inputDevice.TryGetFeatureValue(CommonUsages.handData, out Hand hand))
            {
                foreach (HandFinger finger in HandFingers)
                {
                    if (hand.TryGetRootBone(out Bone rootBone) && TryReadHandJoint(rootBone, out MixedRealityPose rootPose))
                    {
                        jointPoses[TrackedHandJoint.Palm] = rootPose;
                    }

                    if (hand.TryGetFingerBones(finger, fingerBones))
                    {
                        for (int i = 0; i < fingerBones.Count; i++)
                        {
                            if (TryReadHandJoint(fingerBones[i], out MixedRealityPose pose))
                            {
                                jointPoses[ConvertToTrackedHandJoint(finger, i)] = pose;
                            }
                        }
                    }
                }
#endif // MSFT_OPENXR && (UNITY_STANDALONE_WIN || UNITY_WSA)
            }
        }