private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { uint id = obj.state.source.id; Vector3 pos; Quaternion rot; // Tracked Object if (trackingObject.ContainsKey(id)) { if (obj.state.sourcePose.TryGetPosition(out pos)) { trackingObject[id].transform.localPosition = pos; } if (obj.state.sourcePose.TryGetRotation(out rot)) { trackingObject[id].transform.localRotation = rot; } } // Hardware Based Movment - No dependecy on detection if (obj.state.source.handedness == InteractionSourceHandedness.Left) { leftStick = obj.state.thumbstickPosition; } else if (obj.state.source.handedness == InteractionSourceHandedness.Right) { rightStick = obj.state.thumbstickPosition; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.supportsGrasp && obj.state.grasped && (Time.frameCount - boltFrame > 20)) { boltFrame = Time.frameCount; Vector3 boltStart; if (!obj.state.sourcePose.TryGetPosition(out boltStart, InteractionSourceNode.Pointer)) { return; } Vector3 boltDirection; if (!obj.state.sourcePose.TryGetForward(out boltDirection, InteractionSourceNode.Pointer)) { return; } Vector3 boltTarget = boltStart + boltDirection * 15.0f; Transform LevelTransform = levelState.transform; boltStart = MixedRealityTeleport.Instance.transform.TransformPoint(boltStart); boltTarget = MixedRealityTeleport.Instance.transform.TransformPoint(boltTarget); CmdSetupBolt(LevelTransform.InverseTransformPoint(boltTarget), LevelTransform.InverseTransformPoint(boltStart)); } if (obj.state.source.supportsMenu && obj.state.menuPressed) { ResetPosition(); } }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.handedness == Handedness & obj.state.grasped & !previousGraspedCondition) { //Debug.Log("grasped:" + obj.state.grasped); previousGraspedCondition = true; } if (obj.state.source.handedness == Handedness & !obj.state.grasped & previousGraspedCondition) { //Debug.Log("grasped:" + obj.state.grasped); player = GameObject.Find("Player - MRCP"); player_move_script = player.GetComponent <MoveCtrl>(); if (player_move_script.moveSpeed == 0) { player_move_script.moveSpeed = 1.0f; } else { player_move_script.moveSpeed = 0.0f; } previousGraspedCondition = false; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) { //Check to see that the source is a hand if (args.state.source.kind != InteractionSourceKind.Hand) { return; } //Change the position to the hand position if (trackedHands.Contains(args.state.source.id)) { Vector3 position; if (args.state.sourcePose.TryGetPosition(out position)) { if (args.state.source.id == leftHand.GetComponent <Hand>().id) { leftHand.transform.position = position; } else if (args.state.source.id == rightHand.GetComponent <Hand>().id) { rightHand.transform.position = position; } } } }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.touchpadTouched) { print("Touchpad touched."); } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) { uint id = args.state.source.id; Vector3 pos; Quaternion rot; if (args.state.source.kind == InteractionSourceKind.Hand) { if (trackingObject.ContainsKey(id)) { if (args.state.sourcePose.TryGetPosition(out pos)) { //var camera = Camera.main; //Vector3 headPosition = camera.transform.position; //Vector3 positionDelta = pos - headPosition; //Vector3 factoredDelta = 0.5f * positionDelta; //trackingObject[id].transform.position = pos+factoredDelta; trackingObject[id].transform.position = pos; } if (args.state.sourcePose.TryGetRotation(out rot)) { trackingObject[id].transform.rotation = rot; } } } }
private void HandleNavigation(ControllerInformation ci, InteractionSourceUpdatedEventArgs obj) { float displacementAlongX = obj.state.thumbstickPosition.x; float displacementAlongY = obj.state.thumbstickPosition.y; if (Mathf.Abs(displacementAlongX) >= 0.1f || Mathf.Abs(displacementAlongY) >= 0.1f || navigatingHand != null) { if (navigatingHand == null) { navigatingHand = ci; //Raise navigation started event. InputRouter.Instance.OnNavigationStartedWorker(InteractionSourceKind.Controller, Vector3.zero, new Ray()); } if (navigatingHand.id == ci.id) { Vector3 thumbValues = new Vector3( displacementAlongX, displacementAlongY, 0f); InputRouter.Instance.OnNavigationUpdatedWorker(InteractionSourceKind.Controller, thumbValues, new Ray()); } } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) { uint id = args.state.source.id; Vector3 pos; Quaternion rot; if (args.state.source.kind == InteractionSourceKind.Hand) { if (trackingObject.ContainsKey(id)) { if (args.state.sourcePose.TryGetPosition(out pos)) { trackingObject[id].transform.position = pos; if (!mapPlaced) { configuration.transform.position = pos + Camera.main.transform.forward * 5f; placementAreas.transform.position = pos + Camera.main.transform.forward * 5f; navigationObjects.transform.position = pos + Camera.main.transform.forward * 5f; light.transform.position = pos + Camera.main.transform.forward * 5f; } } if (args.state.sourcePose.TryGetRotation(out rot)) { trackingObject[id].transform.rotation = rot; } } } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { // 手の位置の更新のコールバック // 手の移動、ジェスチャーの処理はここでやるとよい。 if (state == RingCommandState.ACTIVE) { // 手の位置を取得 Vector3 handPos; obj.state.sourcePose.TryGetPosition(out handPos); if (lastHandPos != Vector3.zero) { // 前回の手の位置からの移動量を計算 var move = handPos - lastHandPos; // カメラ座標系を基準とした左右移動に変換する var right = Vector3.Dot(move, Camera.main.transform.right); // 移動量を蓄積して、選択状態の変更の判定を行う MoveHand(right); } lastHandPos = handPos; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) { if (!is_holding_object) { return; } uint id = args.state.source.id; Vector3 pos; Quaternion rot; if (args.state.source.kind == InteractionSourceKind.Hand) { if (trackingObject.ContainsKey(id)) { if (args.state.sourcePose.TryGetPosition(out pos)) { trackingObject[id].transform.position = pos + (m_MainCamera.transform.forward) * 0.1f - (m_MainCamera.transform.right) * 0.1f; //m_MainCamera.transform.right * 0.2f; } if (args.state.sourcePose.TryGetRotation(out rot)) { trackingObject[id].transform.rotation = rot; } } } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (InteractionSourceUpdated != null) { InteractionSourceUpdated(obj); } }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if ((obj.state.source.handedness == InteractionSourceHandedness.Left && right) || (obj.state.source.handedness == InteractionSourceHandedness.Right && !right)) { return; } if (obj.state.source.handedness == InteractionSourceHandedness.Left) { if (obj.state.thumbstickPosition.magnitude > 0.25f) { Vector3 cameraDirection = Camera.main.transform.TransformDirection(new Vector3(obj.state.thumbstickPosition.x, 0, obj.state.thumbstickPosition.y)); Vector3 direction = new Vector3(cameraDirection.x, 0, cameraDirection.z); guardian.Translate(new Vector3(2 * Time.deltaTime * direction.x, 0, 2 * Time.deltaTime * direction.z), Space.Self); } } if (obj.state.source.handedness == InteractionSourceHandedness.Right) { if (grabbedObject) { if (obj.state.thumbstickPosition.magnitude > 0.25f) { float horizontal = obj.state.thumbstickPosition.x; float vertical = obj.state.thumbstickPosition.y; Vector3 torque = new Vector3(0, -horizontal * 1, 0); torque += vertical * transform.right * 1; grabbedObject.GetComponent <Rigidbody>().AddTorque(torque); } else { grabbedObject.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } } } }
private void InteractionManager_SourceUpdated(InteractionSourceUpdatedEventArgs args) { if (args.state.source.kind == InteractionSourceKind.Hand) { Vector3 handPos; if (args.state.sourcePose.TryGetPosition(out handPos)) { if (_collider.bounds.Contains(handPos)) { // How far has the hand travelled into the object var halfHeight = _collider.bounds.extents.y; var centerTop = _collider.bounds.center + transform.up * halfHeight; var handDist = Vector3.Project(handPos - centerTop, transform.up); var t = handDist.magnitude / halfHeight; // Make sure it is in the right range [0; 1] if (t >= 0 && t <= 1) { // Apply Skinned mesh blending / morphing var blendWeight = Mathf.Lerp(0, BlendShapeTargetWeight, t); BlendShapeRenderer.SetBlendShapeWeight(0, blendWeight); BlendShapeRenderer.material.SetFloat("_Crossfade", t); // Better use cached Shader property ID } } } } }
void SourceUpdated(InteractionSourceUpdatedEventArgs state) { Vector3 v; Quaternion r; if (state.state.sourcePose.TryGetPosition(out v) == true) { state.state.sourcePose.TryGetRotation(out r); for (int i = 0; i < HandPointList.Count; i++) { if (HandPointList[i].id == state.state.source.id) { HandPointList[i].pos = v; HandPointList[i].rot = r; HandPointList[i].select = state.state.selectPressedAmount; HandPointList[i].stick = state.state.thumbstickPosition; if (state.state.touchpadTouched == true) { HandPointList[i].touchpad = state.state.touchpadPosition; } else { HandPointList[i].touchpad = null; } HandPointList[i].menu = state.state.menuPressed; HandPointList[i].grip = state.state.grasped; if (onUpdated != null) { onUpdated(HandPointList[i]); } break; } } } }
// Call these events from HandsManager. This fires when the hand is moved. private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { // Only display hand indicators when we have targeted an interactible and the hand is in a pressed state. if (!obj.state.selectPressed || HandsManager.Instance.FocusedGameObject == null || (HandsManager.Instance.FocusedGameObject != null && HandsManager.Instance.FocusedGameObject.GetComponent <Interactible>() == null)) { return; } // Only track a new hand if are not currently tracking a hand. if (!currentlyTrackedHand.HasValue) { currentlyTrackedHand = obj.state.source.id; } else if (currentlyTrackedHand.Value != obj.state.source.id) { // This hand is not the currently tracked hand, do not drawn a guidance indicator for this hand. return; } // Start showing an indicator to move your hand toward the center of the view. if (obj.state.properties.sourceLossRisk > HandGuidanceThreshold) { ShowHandGuidanceIndicator(obj.state); } else { HideHandGuidanceIndicator(obj.state); } }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.handedness == handedness) { selectorPosition = obj.state.thumbstickPosition; } }
private void SourceUpdated(InteractionSourceUpdatedEventArgs args) { uint id = args.state.source.id; Vector3 position; Quaternion rotation; //if (args.state.source.kind == InteractionSourceKind.Hand) { // if (hands.ContainsKey(id)) { // if (args.state.sourcePose.TryGetPosition(out position)) { // hands[id].transform.position = position; // } // if (args.state.sourcePose.TryGetRotation(out rotation)) { // hands[id].transform.rotation = rotation; // } // } //} if (args.state.source.kind == InteractionSourceKind.Hand) { if (args.state.sourcePose.TryGetPosition(out position)) { hand.transform.position = position; } if (args.state.sourcePose.TryGetRotation(out rotation)) { hand.transform.rotation = rotation; } } }
private void SourceManager_SourceUpdated(InteractionSourceUpdatedEventArgs obj) { InteractionSourcePose statePose = obj.state.sourcePose; obj.state.sourcePose.TryGetPosition(out handPosition); }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.touchpadPressed) { manager.StartListening(); } }
private void SetLaserPointer(InteractionSourceUpdatedEventArgs obj, InteractionSourceHandedness handedness, Vector3 controllerPosition, Vector3 pointerPosition) { if (handedness == InteractionSourceHandedness.Left) if (LeftGrasped && obj.state.grasped || LeftMenuDown && obj.state.menuPressed || LeftSelectDown && obj.state.selectPressed || LeftThumbstickDown && obj.state.thumbstickPressed || LeftTouchpadTouched && obj.state.touchpadTouched) { _leftLaserPointer.positionCount = 2; _leftLaserPointer.SetPosition(0, controllerPosition); _leftLaserPointer.SetPosition(1, pointerPosition); } else { _leftLaserPointer.positionCount = 0; } else if (handedness == InteractionSourceHandedness.Right) if (RightGrasped && obj.state.grasped || RightMenuDown && obj.state.menuPressed || RightSelectDown && obj.state.selectPressed || RightThumbstickDown && obj.state.thumbstickPressed || RightTouchpadTouched && obj.state.touchpadTouched) { _rightLaserPointer.positionCount = 2; _rightLaserPointer.SetPosition(0, controllerPosition); _rightLaserPointer.SetPosition(1, pointerPosition); } else { _rightLaserPointer.positionCount = 0; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { ControllerState controllerState; if (controllers.TryGetValue(obj.state.source.id, out controllerState)) { obj.state.sourcePose.TryGetPosition(out controllerState.PointerPosition, InteractionSourceNode.Pointer); obj.state.sourcePose.TryGetRotation(out controllerState.PointerRotation, InteractionSourceNode.Pointer); obj.state.sourcePose.TryGetPosition(out controllerState.GripPosition, InteractionSourceNode.Grip); obj.state.sourcePose.TryGetRotation(out controllerState.GripRotation, InteractionSourceNode.Grip); controllerState.Grasped = obj.state.grasped; controllerState.MenuPressed = obj.state.menuPressed; controllerState.SelectPressed = obj.state.selectPressed; controllerState.SelectPressedAmount = obj.state.selectPressedAmount; controllerState.ThumbstickPressed = obj.state.thumbstickPressed; controllerState.ThumbstickPosition = obj.state.thumbstickPosition; controllerState.TouchpadPressed = obj.state.touchpadPressed; controllerState.TouchpadTouched = obj.state.touchpadTouched; controllerState.TouchpadPosition = obj.state.touchpadPosition; } if (controllerState.TouchpadPressed && isReadyForNextPhoto) { IsMakingPhoto = true; print("Touchpad touched"); StartCoroutine(MakingPhoto()); } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.kind == InteractionSourceKind.Hand) { InteractionSourceState hand = obj.state; // Only display hand indicators when we are in a holding state, since hands going out of view will affect any active gestures. if (!hand.anyPressed) { return; } // Only track a new hand if are not currently tracking a hand. if (!currentlyTrackedHand.HasValue) { currentlyTrackedHand = hand.source.id; } else if (currentlyTrackedHand.Value != hand.source.id) { // This hand is not the currently tracked hand, do not drawn a guidance indicator for this hand. return; } // Start showing an indicator to move your hand toward the center of the view. if (hand.properties.sourceLossRisk > HandGuidanceThreshold) { ShowHandGuidanceIndicator(hand); } else { HideHandGuidanceIndicator(hand); } } }
private void SourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.kind != InteractionSourceKind.Hand) { return; } Vector3 pos; if (Time.time - lastTime > 0 && obj.state.sourcePose.TryGetPosition(out pos)) { if (pressed) { handVelocity = (pos - lastPos) / (Time.time - lastTime); if (handVelocity.sqrMagnitude > maxVelocity * maxVelocity) { handVelocity = handVelocity.normalized * maxVelocity; } } lastPos = handPos; lastTime = Time.time; handPos = pos; if (pressed) { targetPos += (pos - lastPos) * moveScale; } } }
/// <summary> /// 入力ソースの情報が更新されたときの処理 /// </summary> /// <param name="obj">入力情報</param> private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.id == id) { // 位置回転の取得 obj.state.sourcePose.TryGetPosition(out pos, InteractionSourceNode.Pointer); obj.state.sourcePose.TryGetRotation(out rot); // モーションコントローラの少し先にポインタを描画する Vector3 angle = rot * r35 * Vector3.forward; transform.position = pos + angle * 0.1f; pos = transform.position; // スティックの上下操作によるペンの太さ変更 if (Mathf.Abs(obj.state.thumbstickPosition.y) > 0.3f) { if (obj.state.thumbstickPosition.y > 0) { size += Time.deltaTime / 30; } else if (obj.state.thumbstickPosition.y < 0) { size -= Time.deltaTime / 30; } if (size < 0.005f) size = 0.005f; if (size > 1) size = 1f; transform.localScale = new Vector3(size, size, size); } // ボタンが押されていない場合は以降の処理を行わない if (buttonPressed == false) { return; } // トリガーボタンが押されているときの処理 if (obj.state.selectPressedAmount > 0) { if (mode == actmode.none) { return; } else if (mode == actmode.draw) { //線を追加 line.positionCount = pointCount + 1; line.SetPosition(pointCount, pos); //Colliderを追加 SphereCollider ccol = lines.AddComponent<SphereCollider>(); ccol.center = Vector3.Lerp(line.GetPosition(pointCount - 1), line.GetPosition(pointCount), 0.5f); ccol.radius = size / 2; ccol.isTrigger = true; pointCount++; } } } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.supportsThumbstick && obj.state.thumbstickPressed && Time.frameCount - resetFrame > 30) { resetFrame = Time.frameCount; OnInputClicked(null); } }
private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { print("interactionSourceUpdated - we are inside"); if (obj.state.touchpadTouched) { print("Inside if(obj.state.touchpadTouched)"); IsMakingPhoto = true; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { ControllerState controllerState; if (controllers.TryGetValue(obj.state.source.id, out controllerState)) { controllerState.MenuPressed = obj.state.menuPressed; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.source.handedness == handedness) { touchingtouchpad = obj.state.touchpadTouched; touchpadPos = obj.state.touchpadPosition; thumbstickPos = obj.state.thumbstickPosition; } }
void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { if (obj.state.thumbstickPressed) { inputAction = MultiARInterop.InputAction.Grip; inputNavCoordinates = obj.state.thumbstickPosition; inputTimestamp = lastFrameTimestamp; } }
private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdatedEventArgs args) { InputSource data; if (_inputSources.TryGetValue(args.state.source.id, out data)) { UpdateControllerPosition(data, args.state); } }