private void HandleIntentChanged(ManagedHand hand, IntentPose intent)
 {
     if (intent == IntentPose.Pointing)
     {
         point.gameObject.SetActive(true);
     }
     else
     {
         point.gameObject.SetActive(false);
     }
 }
Example #2
0
        private void HandleIntent(ManagedHand hand, IntentPose pose)
        {
            //grab:
            if (pose == IntentPose.Grasping || pose == IntentPose.Pinching)
            {
                Fire0Down();
            }

            //release:
            if (pose == IntentPose.Relaxed)
            {
                Fire0Up();
            }
        }
        public InteractionPoint GetInteractionPoint(IntentPose type)
        {
            switch (type)
            {
            case IntentPose.Pointing:
                return(Point);

            case IntentPose.Grasping:
                return(Grasp);

            case IntentPose.Pinching:
                return(Pinch);

            default:
                break;
            }

            return(null);
        }
Example #4
0
        //Public Methods:
        public void Update()
        {
            //set visibility:
            if (Hand.HandConfidence > .85f && !Visible)
            {
                Visible = true;
                OnVisibilityChanged?.Invoke(this, true);
            }
            else if (Visible)
            {
                IntentPose pose          = Gesture.Intent;
                var        isPinching    = (pose == IntentPose.Grasping || pose == IntentPose.Pinching);
                float      minConfidence = isPinching ? .80f : .85f;
                if (Hand.HandConfidence <= minConfidence)
                {
                    Visible = false;
                    OnVisibilityChanged?.Invoke(this, false);
                }
            }

            Skeleton.Update();
            Gesture.Update();
        }
        public void DoUpdate()
        {
            if (!Enabled || managedHand == null)
            {
                return;
            }

            managedHand.Update();
            IntentPose pose = managedHand.Gesture.Intent;

            IsPinching = (pose == IntentPose.Grasping || pose == IntentPose.Pinching);

            IsPositionAvailable = IsRotationAvailable = managedHand.Visible;

            if (IsPositionAvailable)
            {
                UpdateHandData(managedHand.Skeleton);
                UpdateHandRay(managedHand.Skeleton);
                UpdateVelocity();

                currentGripPose = jointPoses[TrackedHandJoint.Palm];
                CoreServices.InputSystem?.RaiseSourcePoseChanged(InputSource, this, currentGripPose);
            }

            for (int i = 0; i < Interactions?.Length; i++)
            {
                switch (Interactions[i].InputType)
                {
                case DeviceInputType.SpatialPointer:
                    Interactions[i].PoseData = currentPointerPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentPointerPose);
                    }
                    break;

                case DeviceInputType.SpatialGrip:
                    Interactions[i].PoseData = currentGripPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentGripPose);
                    }
                    break;

                case DeviceInputType.Select:
                    Interactions[i].BoolData = IsPinching;

                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.TriggerPress:
                    Interactions[i].BoolData = IsPinching;

                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.IndexFinger:
                    UpdateIndexFingerData(Interactions[i]);
                    break;
                }
            }
        }
        public void DoUpdate()
        {
            if (!Enabled || managedHand == null)
            {
                return;
            }

            managedHand.Update();
            IntentPose pose = managedHand.Gesture.Intent;

            IsPinching = false;

            IsPositionAvailable = IsRotationAvailable = managedHand.Visible;

            if (IsPositionAvailable)
            {
                UpdateHandData(managedHand.Skeleton);

                currentGripPose = pose == IntentPose.Pinching
                    ? new MixedRealityPose(managedHand.Gesture.Pinch.position, jointPoses[TrackedHandJoint.Palm].Rotation)
                    : jointPoses[TrackedHandJoint.Palm];

                currentPointerPose = jointPoses[TrackedHandJoint.Palm];

                currentIndexPose = jointPoses[TrackedHandJoint.IndexTip];

                //The pinch pose is lost if the hand joints are not visible because they are in the camera's clip plane.
                //The clip plane value is set to the default Magic Leap clip plane to insure a valid hand pose.
                IsPinching = (pose == IntentPose.Grasping || pose == IntentPose.Pinching);

                UpdateHandRay(managedHand.Skeleton);

                UpdateVelocity();

                CoreServices.InputSystem?.RaiseSourcePoseChanged(InputSource, this, currentGripPose);
            }

            for (int i = 0; i < Interactions?.Length; i++)
            {
                switch (Interactions[i].InputType)
                {
                case DeviceInputType.SpatialPointer:
                    Interactions[i].PoseData = currentPointerPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentPointerPose);
                    }
                    break;

                case DeviceInputType.SpatialGrip:
                    Interactions[i].PoseData = currentGripPose;
                    if (Interactions[i].Changed)
                    {
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentGripPose);
                    }
                    break;

                case DeviceInputType.Select:
                    Interactions[i].BoolData = IsPinching;

                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.TriggerPress:
                    Interactions[i].BoolData = IsPinching;
                    if (Interactions[i].Changed)
                    {
                        if (Interactions[i].BoolData)
                        {
                            CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                        else
                        {
                            CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
                        }
                    }
                    break;

                case DeviceInputType.IndexFinger:
                    Interactions[i].PoseData = currentIndexPose;
                    // If our value changed raise it.
                    if (Interactions[i].Changed)
                    {
                        // Raise input system Event if it enabled
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentIndexPose);
                    }
                    break;
                }
            }
        }