public void FixedUpdateClassifierHandState()
        {
            using (new ProfilerSample("Update Classifier Hand State")) {
                var hand = interactionHand.leapHand;

                if (interactionHand.isTracked)
                {
                    // Ensure that all scale dependent variables are properly set.
                    _scaledGrabParams.FINGERTIP_RADIUS = _defaultGrabParams.FINGERTIP_RADIUS
                                                         * interactionHand.manager.SimulationScale;
                    _scaledGrabParams.THUMBTIP_RADIUS = _defaultGrabParams.THUMBTIP_RADIUS
                                                        * interactionHand.manager.SimulationScale;
                    _scaledGrabParams.MAXIMUM_DISTANCE_FROM_HAND = _defaultGrabParams.MAXIMUM_DISTANCE_FROM_HAND
                                                                   * interactionHand.manager.SimulationScale;

                    // Ensure layer mask is up-to-date.
                    _scaledGrabParams.LAYER_MASK = interactionHand.manager.GetInteractionLayerMask();

                    for (int i = 0; i < hand.Fingers.Count; i++)
                    {
                        _fingerTipPositions[i] = hand.Fingers[i].TipPosition.ToVector3();
                    }

                    GrabClassifierHeuristics.UpdateAllProbeColliders(_fingerTipPositions, ref _collidingCandidates, ref _numberOfColliders, _scaledGrabParams);
                }
            }
        }
Esempio n. 2
0
        public void FixedUpdateClassifierHandState(Transform headTransform = null)
        {
            using (new ProfilerSample("Update Classifier Hand State"))
            {
                var hand = interactionHand.leapHand;

                if (interactionHand.isTracked)
                {
                    // Ensure that all scale dependent variables are properly set.
                    _scaledGrabParams.FINGERTIP_RADIUS = _defaultGrabParams.FINGERTIP_RADIUS
                                                         * interactionHand.manager.SimulationScale;
                    _scaledGrabParams.THUMBTIP_RADIUS = _defaultGrabParams.THUMBTIP_RADIUS
                                                        * interactionHand.manager.SimulationScale;
                    _scaledGrabParams.MAXIMUM_DISTANCE_FROM_HAND = _defaultGrabParams.MAXIMUM_DISTANCE_FROM_HAND
                                                                   * interactionHand.manager.SimulationScale;

                    // Ensure layer mask is up-to-date.
                    _scaledGrabParams.LAYER_MASK = interactionHand.manager.GetInteractionLayerMask();


                    /*if (headTransform != null) {
                     * //SERIOUS HACKS: Have the collider for the grab classifier stretch along the camera's projective axis
                     * //This will make it easier for users to grab far away objects (while being uncertain of their depth)
                     * for (int i = 0; i < hand.Fingers.Count; i++) {
                     *  Vector3 fingerTipPosition = hand.Fingers[i].TipPosition.ToVector3();
                     *  Vector3 stretchDirection = (fingerTipPosition - headTransform.position) * 0.1f;
                     *  _fingerTipPositions[i] = fingerTipPosition + stretchDirection;
                     *  _fingerKnucklePositions[i] = fingerTipPosition - stretchDirection;
                     * }
                     * } else {*/
                    for (int i = 0; i < hand.Fingers.Count; i++)
                    {
                        _fingerTipPositions[i]     = hand.Fingers[i].TipPosition.ToVector3();
                        _fingerKnucklePositions[i] = hand.Fingers[i].Bone(Bone.BoneType.TYPE_METACARPAL).NextJoint.ToVector3();
                    }
                    // }

                    GrabClassifierHeuristics.UpdateAllProbeColliders(_fingerTipPositions, _fingerKnucklePositions, ref _collidingCandidates, ref _numberOfColliders, _scaledGrabParams);
                }
            }
        }
Esempio n. 3
0
        //Classifier bookkeeping
        public void UpdateHeuristicClassifier(Hand hand)
        {
            if (hand != null)
            {
                //Ensure that all scale dependent variables are properly set
                scaledGrabParams.FINGERTIP_RADIUS           = defaultGrabParams.FINGERTIP_RADIUS * _manager.SimulationScale;
                scaledGrabParams.THUMBTIP_RADIUS            = defaultGrabParams.THUMBTIP_RADIUS * _manager.SimulationScale;
                scaledGrabParams.MAXIMUM_DISTANCE_FROM_HAND = defaultGrabParams.MAXIMUM_DISTANCE_FROM_HAND * _manager.SimulationScale;

                //Ensure that the temporally variant variables are updated
                //scaledGrabParams.LAYER_MASK = 1<<_manager.InteractionLayer;
                for (int i = 0; i < hand.Fingers.Count; i++)
                {
                    fingerTipPositions[i] = hand.Fingers[i].TipPosition.ToVector3();
                }

                using (new ProfilerSample("Update All Grab Classifiers", _manager)) {
                    GrabClassifierHeuristics.UpdateAllProbeColliders(fingerTipPositions, ref collidingCandidates, ref numberOfColliders, scaledGrabParams);

                    //First check if already holding an object and only process that one
                    var graspedBehaviours = _manager.GraspedObjects;
                    for (int i = 0; i < graspedBehaviours.Count; i++)
                    {
                        if (graspedBehaviours[i].IsBeingGraspedByHand(hand.Id))
                        {
                            UpdateBehaviour(graspedBehaviours[i], hand);
                            return;
                        }
                    }

                    //If not, process all objects
                    var activeBehaviours = _manager._activityManager.ActiveBehaviours;
                    for (int i = 0; i < activeBehaviours.Count; i++)
                    {
                        UpdateBehaviour(activeBehaviours[i], hand);
                    }
                }
            }
        }