public bool TryGrasp(IInteractionBehaviour intObj, Hand hand) { FixedUpdateClassifierHandState(); return(updateBehaviour(intObj, hand, GraspUpdateMode.BeginGrasp, ignoreTemporal: true)); }
private float helper_timeSlice_lastYUpdate = 0.0f; // helper value to keep track of the last y-position update of the Time Slice when moved through Leap Motion Grasp Interaction /// <summary> /// Method to identify the Activation Toggle of a 3D Radar Chart (from potentially multiple in the Scene) the Leap Motion controller collided with, and set link interface references accordingly. /// </summary> /// <param name="controller">InteractionController representing the Leap Motion hand controller a contact event occured with.</param> private void vrlmTriggerActivationToggleOnPerControllerContactBegin(InteractionController controller) { // Developer Note: This is basically required to support interaction with multiple 3D Radar Charts in the Scene, assuming interaction with each charts' Activation Toggle switches the focus. // Generally, the routine goes as follows // (1) Identify collided (contacted) GameObject (potentially one or multiple). // (2) Identify Activation Toggle component among collided GameObjects, and retrieve reference to its 3D Radar Chart's main interface. // (3) Link references between VRLM and TDRC interfaces accordingly. // (4) Continue with interaction. // (1) HashSet <IInteractionBehaviour> .Enumerator em = controller.contactingObjects.GetEnumerator(); IInteractionBehaviour ib = null; while (em.MoveNext()) { ib = em.Current; // (2) TDRCInteractionActivationToggle iatComponent = ib.transform.GetComponent <TDRCInteractionActivationToggle>(); if (iatComponent != null) { break; } } // (3) ThreeDimRadarChartInterface tdrcInterfaceRef = ib.transform.parent.parent.GetComponent <ThreeDimRadarChartInterface>(); tdrcInterface = tdrcInterfaceRef; // (4) vrlmTriggerActivationToggle(); }
public bool TryGrasp(IInteractionBehaviour intObj, Hand hand) { Debug.Log("HEY THIS SHOULDN'T BE BEING CALLED"); FixedUpdateClassifierHandState(); return(updateBehaviour(intObj, hand, GraspUpdateMode.BeginGrasp, ignoreTemporal: true)); }
public static void NotifyIntObjHasNewNoContactLayer(this IInternalInteractionManager manager, IInteractionBehaviour intObj, int oldNoContactLayer, int newNoContactLayer) { manager.NotifyIntObjRemovedNoContactLayer(intObj, oldNoContactLayer, false); manager.NotifyIntObjAddedNoContactLayer(intObj, newNoContactLayer, false); manager.RefreshLayersNow(); }
protected override bool checkShouldRelease(out IInteractionBehaviour objectToRelease) { bool shouldRelease = _graspButtonUp && isGraspingObject; objectToRelease = null; if (shouldRelease) { objectToRelease = graspedObject; } return(shouldRelease); }
public void NotifyGraspReleased(IInteractionBehaviour behaviour) { GrabClassifierHeuristics.GrabClassifier classifier; if (_classifiers.TryGetValue(behaviour, out classifier)) { classifier.prevGrabbing = false; classifier.isGrabbing = false; classifier.coolDownProgress = 0F; //for (int i = 0; i < classifier.probes.Length; i++) { // classifier.probes[i].isInside = false; //} } }
/*{ * get * { * if (isPinchGrip) * { * return pinchGrabDetector.DeactivatedThisFrame; * } * else * { * return grabAction.GetStateUp((isLeft) ? SteamVR_Input_Sources.LeftHand : * SteamVR_Input_Sources.RightHand); * } * } * }*/ protected override bool checkShouldGrasp(out IInteractionBehaviour objectToGrasp) { bool shouldGrasp = !isGraspingObject && (_graspButtonDown) && _closestGraspableObject != null; objectToGrasp = null; if (shouldGrasp) { objectToGrasp = _closestGraspableObject; } return(shouldGrasp); }
private void refreshClosestGraspableObject() { _closestGraspableObject = null; float closestGraspableDistance = float.PositiveInfinity; foreach (var intObj in graspCandidates) { float testDist = intObj.GetHoverDistance(this.position); if (testDist < maxGraspDistance && testDist < closestGraspableDistance) { _closestGraspableObject = intObj; closestGraspableDistance = testDist; } } }
protected void FillClassifier(IInteractionBehaviour behaviour, Hand hand, ref GrabClassifierHeuristics.GrabClassifier classifier) { classifier.handChirality = hand.IsLeft; classifier.handDirection = hand.Direction.ToVector3(); classifier.handXBasis = hand.Basis.xBasis.ToVector3(); float simScale = interactionHand.manager.SimulationScale; classifier.handGrabCenter = (hand.PalmPosition + (hand.Direction * 0.05f * simScale) + (hand.PalmNormal * 0.01f * simScale)).ToVector3(); for (int i = 0; i < hand.Fingers.Count; i++) { classifier.probes[i].direction = hand.Fingers[i].Direction.ToVector3(); } classifier.isGrabbed = behaviour.isGrasped; }
public bool FixedUpdateClassifierRelease(out IInteractionBehaviour releasedObject) { using (new ProfilerSample("Update Grab Classifier - Release", interactionHand.manager)) { releasedObject = null; if (!interactionHand.isGraspingObject) { // Can't release an object if the hand is already not grasping one. return(false); } if (UpdateBehaviour(interactionHand.graspedObject, interactionHand.leapHand, graspMode: GraspUpdateMode.ReleaseGrasp)) { releasedObject = interactionHand.graspedObject; return(true); } return(false); } }
public void GetGraspingFingertipPositions(IInteractionBehaviour behaviour, Vector3[] fingertipPositionsBuffer, out int numGraspingFingertips) { GrabClassifierHeuristics.GrabClassifier classifier; if (_classifiers.TryGetValue(behaviour, out classifier)) { int writeIdx = 0; for (int probeIdx = 0; probeIdx < classifier.probes.Length; probeIdx++) { if (classifier.probes[probeIdx].isInside) { fingertipPositionsBuffer[writeIdx++] = _fingerTipPositions[probeIdx]; } } numGraspingFingertips = writeIdx; } else { numGraspingFingertips = 0; } }
/// <summary> /// Returns true if the behaviour reflects the state-change (grasped or released) as specified by /// the graspMode. /// </summary> private bool updateBehaviour(IInteractionBehaviour behaviour, Hand hand, GraspUpdateMode graspMode, bool ignoreTemporal = false) { using (new ProfilerSample("Update Individual Grab Classifier", behaviour.gameObject)) { // Ensure a classifier exists for this Interaction Behaviour. GrabClassifierHeuristics.GrabClassifier classifier; if (!_classifiers.TryGetValue(behaviour, out classifier)) { classifier = new GrabClassifierHeuristics.GrabClassifier(behaviour.gameObject); _classifiers.Add(behaviour, classifier); } // Do the actual grab classification logic. FillClassifier(behaviour, hand, ref classifier); GrabClassifierHeuristics.UpdateClassifier(classifier, _scaledGrabParams, ref _collidingCandidates, ref _numberOfColliders, ignoreTemporal); // Determine whether there was a state change. bool didStateChange = false; if (!classifier.prevThisControllerGrabbing && classifier.isThisControllerGrabbing && graspMode == GraspUpdateMode.BeginGrasp) { didStateChange = true; classifier.prevThisControllerGrabbing = classifier.isThisControllerGrabbing; } else if (classifier.prevThisControllerGrabbing && !classifier.isThisControllerGrabbing && interactionHand.graspedObject == behaviour && graspMode == GraspUpdateMode.ReleaseGrasp) { didStateChange = true; classifier.coolDownProgress = 0f; classifier.prevThisControllerGrabbing = classifier.isThisControllerGrabbing; } return(didStateChange); } }
public bool FixedUpdateClassifierGrasp(out IInteractionBehaviour graspedObject) { using (new ProfilerSample("Update Grab Classifier - Grasp", interactionHand.manager)) { graspedObject = null; if (interactionHand.isGraspingObject || !interactionHand.isTracked) { // Cannot grasp another object with an untracked hand or while the hand is // already grasping an object or if the hand is not tracked. return(false); } foreach (var interactionObj in interactionHand.graspCandidates) { if (UpdateBehaviour(interactionObj, interactionHand.leapHand, graspMode: GraspUpdateMode.BeginGrasp)) { graspedObject = interactionObj; return(true); } } return(false); } }
protected override bool checkShouldGraspAtemporal(IInteractionBehaviour intObj) { bool shouldGrasp = !isGraspingObject && _graspButtonLastFrame && intObj.GetHoverDistance(position) < maxGraspDistance; if (shouldGrasp) { var tempControllers = Pool <List <InteractionController> > .Spawn(); try { intObj.BeginGrasp(tempControllers); } finally { tempControllers.Clear(); Pool <List <InteractionController> > .Recycle(tempControllers); } } return(shouldGrasp); }
public void SwapClassifierState(IInteractionBehaviour original, IInteractionBehaviour replacement) { if (original == null) { throw new ArgumentNullException("original"); } if (replacement == null) { throw new ArgumentNullException("replacement"); } GrabClassifierHeuristics.GrabClassifier classifier; if (!_classifiers.TryGetValue(original, out classifier)) { throw new InvalidOperationException("Cannot swap from something that is not currently grasped!"); } classifier.body = replacement.rigidbody; classifier.transform = replacement.transform; _classifiers.Remove(original); _classifiers[replacement] = classifier; }
public void UnregisterInteractionBehaviour(IInteractionBehaviour behaviour) { _classifiers.Remove(behaviour); }
protected override void onObjectUnregistered(IInteractionBehaviour intObj) { }