public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation) { yield return(null); SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft; handData.Update(true, false, GenerateHandPose(handPose, handedness, handLocation, Quaternion.identity)); // Wait one frame for the hand to actually appear yield return(null); }
public static IEnumerator HideHand(Handedness handedness, InputSimulationService inputSimulationService) { yield return(null); SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft; handData.Update(false, false, GenerateHandPose(ArticulatedHandPose.GestureId.Open, handedness, Vector3.zero, Quaternion.identity)); // Wait one frame for the hand to actually disappear yield return(null); }
public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation) { yield return(null); Assert.That(inputSimulationService.ControllerSimulationMode == ControllerSimulationMode.HandGestures || inputSimulationService.ControllerSimulationMode == ControllerSimulationMode.ArticulatedHand, "The current ControllerSimulationMode must be HandGestures or ArticulatedHand!"); SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft; handData.Update(true, false, GenerateHandPose(handPose, handedness, handLocation, Quaternion.identity)); // Wait one frame for the hand to actually appear yield return(null); }
public static IEnumerator SetHandRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, int numSteps, InputSimulationService inputSimulationService) { Debug.Assert(handedness == Handedness.Right || handedness == Handedness.Left, "handedness must be either right or left"); bool isPinching = gestureId == ArticulatedHandPose.GestureId.Grab || gestureId == ArticulatedHandPose.GestureId.Pinch || gestureId == ArticulatedHandPose.GestureId.PinchSteadyWrist; for (int i = 1; i <= numSteps; i++) { float t = i / (float)numSteps; Quaternion handRotation = Quaternion.Lerp(fromRotation, toRotation, t); var handDataGenerator = GenerateHandPose( gestureId, handedness, handPos, handRotation); SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft; handData.Update(true, isPinching, handDataGenerator); yield return(null); } }
internal static IEnumerator MoveHandFromTo( Vector3 startPos, Vector3 endPos, int numSteps, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService) { Debug.Assert(handedness == Handedness.Right || handedness == Handedness.Left, "handedness must be either right or left"); bool isPinching = gestureId == ArticulatedHandPose.GestureId.Grab || gestureId == ArticulatedHandPose.GestureId.Pinch || gestureId == ArticulatedHandPose.GestureId.PinchSteadyWrist; for (int i = 1; i <= numSteps; i++) { float t = i / (float)numSteps; Vector3 handPos = Vector3.Lerp(startPos, endPos, t); var handDataGenerator = GenerateHandPose( gestureId, handedness, handPos, Quaternion.identity); SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft; handData.Update(true, isPinching, handDataGenerator); yield return(null); } }
protected override void UpdateInteractions(SimulatedHandData handData) { lastPointerPose = currentPointerPose; lastGripPose = currentGripPose; Vector3 pointerPosition = jointPoses[TrackedHandJoint.Palm].Position; IsPositionAvailable = IsRotationAvailable = pointerPosition != Vector3.zero; if (IsPositionAvailable) { HandRay.Update(pointerPosition, GetPalmNormal(), CameraCache.Main.transform, ControllerHandedness); Ray ray = HandRay.Ray; currentPointerPose.Position = ray.origin; currentPointerPose.Rotation = Quaternion.LookRotation(ray.direction); currentGripPose = jointPoses[TrackedHandJoint.Palm]; currentIndexPose = jointPoses[TrackedHandJoint.IndexTip]; } if (lastGripPose != currentGripPose) { if (IsPositionAvailable && IsRotationAvailable) { CoreServices.InputSystem?.RaiseSourcePoseChanged(InputSource, this, currentGripPose); } else if (IsPositionAvailable && !IsRotationAvailable) { CoreServices.InputSystem?.RaiseSourcePositionChanged(InputSource, this, currentPointerPosition); } else if (!IsPositionAvailable && IsRotationAvailable) { CoreServices.InputSystem?.RaiseSourceRotationChanged(InputSource, this, currentPointerRotation); } } 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 = handData.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 = handData.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 (Interactions[i].Changed) { CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, currentIndexPose); } break; } } }