public void OnGestureDown(GestureInfo info) { // Down時に呼ばれます // キャンセル命令発行 //GestureManager.Instance.BreakTouchEvent(): }
void HandleManoMotionFrameUpdated() { GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; UpdateStateForGesture(gesture, warning); }
/// <summary> /// Displayes palm center cursor /// </summary> /// <param name="palmCenter">Requires the estimated position of the bounding box center.</param> void DisplayPalmCenter(Vector3 palmCenter, GestureInfo gesture, Warning warning) { if (ShowPalmCenter) { if (warning != Warning.WARNING_HAND_NOT_FOUND) { if (!palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(true); } float smoothing = 1 - ManomotionManager.Instance.Manomotion_Session.smoothing_controller; palmCenterRectTransform.position = Camera.main.ViewportToScreenPoint(palmCenter); float newFillAmmount = 1 - ((int)(gesture.state / 6) * 0.25f); palmCenterFillAmmount.localScale = Vector3.Lerp(palmCenterFillAmmount.localScale, Vector3.one * newFillAmmount, 0.9f); } else { if (palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(false); } } } else { if (palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(false); } } }
/// <summary> /// Fires a raycast from the position of the cursor forward seeking to hit an example block. /// The fire will only happen with the user performes the interaction trigger. /// </summary> /// <param name="gestureInfo">Gesture info.</param> /// <param name="trackingInfo">Tracking info.</param> void InteractTrigger(GestureInfo gestureInfo) { if (gestureInfo.mano_gesture_trigger == interactionTrigger) { Ray ray = Camera.main.ScreenPointToRay(cursorRectTransform.position); RaycastHit hit; Debug.Log("Ray is fired"); if (Physics.Raycast(ray.origin, ray.direction, out hit)) { Debug.Log("Ray has hit: " + hit.transform.name); //if (hit.transform.tag == interactableTag) //{ // hit.transform.GetComponent<CubeSpawn>().AwardPoints(); // Handheld.Vibrate(); //} } //if (Physics.Raycast(ray, out hit)) //{ // PlacementObject placementObject = hit.transform.GetComponent<PlacementObject>(); // if (placementObject != null) // { // ChangeSelectedObject(placementObject); // } //} //else //{ // ChangeSelectedObject(); //} } }
/// <summary> /// Fires a raycast from the position of the cursor forward seeking to hit an example block. /// The fire will only happen with the user performes the interaction trigger. /// </summary> /// <param name="gestureInfo">Gesture info.</param> /// <param name="trackingInfo">Tracking info.</param> void FireAt(GestureInfo gestureInfo) { if (gestureInfo.mano_gesture_trigger == interactionTrigger) { fireSound.Play(); if (!gameHasStarted) { gameHasStarted = true; instructions.SetActive(!gameHasStarted); scoreKeeper.enabled = gameHasStarted; } Ray ray = Camera.main.ScreenPointToRay(cursorRectTransform.transform.position); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit)) { if (hit.transform.tag == interactableTag) { hit.transform.GetComponent <CubeSpawn>().AwardPoints(); Handheld.Vibrate(); } } } }
/// <summary> /// Up入力処理を行います /// </summary> /// <param name="info"></param> void DoUp(GestureInfo info) { if (this.ProcessingGesture == null) { return; } // OnGestureUp info.DeltaTime = GetTraceDeltaTime(); info.DragDistance = GetTraceVector(0, 0); this.ProcessingGesture.OnGestureUp(info); // Flick判定 var v1 = GetTraceVector(0, 0); var v2 = GetTraceVector(this.tracePositionQueue.Count - 5, 0); var dot = Vector3.Dot(v1.normalized, v2.normalized); if (dot > 0.9) { // Flick発生 this.ProcessingGesture.OnGestureFlick(info); } // Gesture終了 this.ProcessingGesture = null; }
protected override void FixedUpdate() { GestureInformation = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; TrackingInformation = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; ScreenPosition = TrackingInformation.poi; Distance = Mathf.Pow(TrackingInformation.depth_estimation, 2); if (Distance > 0.0f && ScreenPosition.x > 0.0f) { MoveCursor(); } if (IsGrabPieceGesture(GestureInformation.mano_gesture_trigger)) { Debug.Log("Grab Gesture"); GestureGrab(); } if (IsReleaseGesture(GestureInformation.mano_gesture_trigger)) { Debug.Log("Release"); Release(); } if (SelectedPiece == null) { return; } else { UpdateScreenPosition(); SelectedPlacer.TouchPosition = WorldPosition; } }
/// <summary> /// タッチ入力情報をGestureInfoへ変換します /// </summary> /// <returns>入力情報があればtrueを返します</returns> /// <param name="info"></param> bool InputForTouch(ref GestureInfo info) { // 基本的にタッチは1点のみ検出するインターフェースとする Touch?touch = GetTouch(); if (!touch.HasValue) { return(false); } info.ScreenPosition = touch.GetValueOrDefault().position; info.DeltaPosition = touch.GetValueOrDefault().deltaPosition; switch (touch.GetValueOrDefault().phase) { case TouchPhase.Began: info.IsDown = true; break; case TouchPhase.Moved: case TouchPhase.Stationary: info.IsDrag = true; break; case TouchPhase.Ended: case TouchPhase.Canceled: info.IsUp = true; this.TouchId = -1; // タッチ終了 break; } return(true); }
/// <summary> /// Spawns a cube in front of the user when the user performs a Click Gesture and its detected by the system. /// </summary> private void SpawnCubewithclickTriggerGesture() { //All the information for a detected hand. It refers to a single hand. HandInfo handInformation = ManomotionManager.Instance.Hand_infos[0].hand_info; //All the gesture information for this hand. GestureInfo gestureInformation = handInformation.gesture_info; //The trigger gesture that is detected in this frame. ManoGestureTrigger currentDetectedTriggerGesture = gestureInformation.mano_gesture_trigger; if (currentDetectedTriggerGesture == ManoGestureTrigger.CLICK) { //A click has been performed by the user and it has been detected as the current trigger Gesture. ManoClicked = true; StartCoroutine(timer(1)); //GameObject newItem = Instantiate(itemPrefab); ////Spawn a cube at the position of the camera, also adding a small offset forward so it does not spawn right in front of it. //Vector3 positionToMove = Camera.main.transform.position + (Camera.main.transform.forward * 2); //newItem.transform.position = positionToMove; ////Make the phone vibrate for feedback. Handheld.Vibrate(); } else if (currentDetectedTriggerGesture == ManoGestureTrigger.RELEASE_GESTURE) { //A grab and release has been performed by the user and it has been detected as the current trigger Gesture. ManoReleased = true; StartCoroutine(timer(2)); Handheld.Vibrate(); } }
/// <summary> /// Displays information regarding the Mano class of the detected hand /// </summary> /// <param name="info"></param> void DisplayManoclass(GestureInfo gesture_info) { manoClassGizmo.SetActive(Show_mano_class); if (Show_mano_class) { ManoClass manoclass = gesture_info.mano_class; switch (manoclass) { case ManoClass.NO_HAND: manoClassText.text = "Manoclass: "; break; case ManoClass.GRAB_GESTURE_FAMILY: manoClassText.text = "Manoclass: Grab Class"; break; case ManoClass.PINCH_GESTURE_FAMILY: manoClassText.text = "Manoclass: Pinch Class"; break; case ManoClass.POINTER_GESTURE_FAMILY: manoClassText.text = "Manoclass: Pointer Class"; break; default: manoClassText.text = "Manoclass: "; break; } } }
void FireAt(GestureInfo gestureInfo) { if (gestureInfo.mano_gesture_trigger == interactionTrigger1) { ScreenClick(); } }
/// <summary> /// Displayes rough estimation of depth /// </summary> /// <param name="palmCenter">Requires the estimated position of the bounding box center.</param> void DisplayPalmCenter(TrackingInfo tracking_info, GestureInfo gesture, Warning warning) { if (ShowPalmCenter) { if (warning != Warning.WARNING_HAND_NOT_FOUND) { if (!palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(true); } float smoothing = 1 - ManomotionManager.Instance.Manomotion_Session.smoothing_controller; palmCenterRectTransform.position = ManoUtils.Instance.CalculateScreenPosition(tracking_info.palm_center, tracking_info.depth_estimation); float newFillAmmount = 1 - ((int)(gesture.state / 6) * 0.25f); palmCenterFillAmmount.localScale = Vector3.Lerp(palmCenterFillAmmount.localScale, Vector3.one * newFillAmmount, 0.9f); } else { if (palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(false); } } } else { if (palmCenterGizmo.activeInHierarchy) { palmCenterGizmo.SetActive(false); } } }
void ContinuousGesture(GestureInfo gesture, TrackingInfo tracking, Warning warning) { if (warning != Warning.WARNING_HAND_NOT_FOUND) { //found hand if (gesture.mano_gesture_continuous == ManoGestureContinuous.CLOSED_HAND_GESTURE) { openHand = false; if (reloading == false) { reloading = true; Invoke("Reload", 1f); } Vector3 boundingBoxCenter = tracking.bounding_box_center; Vector3 projectileSpawnPoint = boundingBoxCenter; Vector3 holdAnimationPoint = boundingBoxCenter; holdAnimationPoint.z = 0.5f; projectileSpawnPoint.z = 5f; boundingBoxCenter.z = 3f; projectileSpawn.transform.position = Camera.main.ViewportToWorldPoint(projectileSpawnPoint); holdAnimation.transform.position = Camera.main.ViewportToWorldPoint(holdAnimationPoint); } } else { reloading = false; reloaded = false; openHand = false; holdAnimation.SetActive(false); } }
// Start is called before the first frame update void Start() { gestureInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; trackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; session = ManomotionManager.Instance.Manomotion_Session; }
/// <summary> /// Displayes rough estimation of depth /// </summary> /// <param name="boundingBoxCenter">Requires the estimated position of the bounding box center.</param> void DisplayCursor(Vector3 boundingBoxCenter, GestureInfo gesture, Warning warning) { if (Show_cursor) { if (warning != Warning.WARNING_HAND_NOT_FOUND) { if (!cursorGizmo.activeInHierarchy) { cursorGizmo.SetActive(true); } cursorRectTransform.position = Camera.main.ViewportToScreenPoint(boundingBoxCenter); float newFillAmmount = 1 - ((int)(gesture.state / 6) * 0.25f); cursorFillRectTransform.localScale = Vector3.Lerp(cursorFillRectTransform.localScale, Vector3.one * newFillAmmount, 0.9f); } else { if (cursorGizmo.activeInHierarchy) { cursorGizmo.SetActive(false); } } } else { if (cursorGizmo.activeInHierarchy) { cursorGizmo.SetActive(false); } } }
public void Interact(GestureInfo gestureInfo, TrackingInfo trackingInformation) { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit)) { if (hit.transform.tag == interactableTag) { StartCoroutine(closeMouth()); } } } if (gestureInfo.mano_gesture_trigger == triggerGesture) { //Interact with the Big Tooth using a triggerGesture Gesture Ray ray = Camera.main.ScreenPointToRay(cursorRectTransform.transform.position); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit)) { Handheld.Vibrate(); if (hit.transform.tag == interactableTag) { StartCoroutine(closeMouth()); } } } }
/// <summary> /// Drag時に呼び出されます /// </summary> /// <param name="info">Info.</param> public void OnGestureDrag(GestureInfo info) { // 上方向のカメラドラッグは無視します var pt = ScreenToWorld(info.DeltaPosition); DoMove(pt); }
void client_GetGestureDataCompleted(object sender, DataService.GetGestureDataCompletedEventArgs e) { if (e.Error == null) { gestureInfo = SerializationHelper.Desirialize(e.Result); defBuilder.AddGesture(gestureInfo); } }
void OnTriggerStay(Collider trigCol) { TrackingInfo myTrackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; GestureInfo myGestureInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; grabMove(myTrackingInfo, myGestureInfo, trigCol); }
void DetectWhenUserIsHolding(GestureInfo gesture) { if (gesture.mano_gesture_trigger == ManoGestureTrigger.CLICK_GESTURE) { count++; c.text = count % 2 + ""; } }
/// <summary> /// 指定ジェスチャーが処理する必要があるかどうかを取得します /// </summary> /// <returns>処理する必要があるならtrueを返す</returns> /// <param name="info">Info.</param> public bool IsGestureProcess(GestureInfo info) { if (GameSceneManager.Instance.ePlayType == GameSceneManager.PlayType.PAUSE) { return(false); } return(true); // 常に処理する(仮) }
void Update() { GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; TrackingInfo trackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; Interact(gesture, trackingInfo); }
// Update is called once per frame void Update() { GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; TrackingInfo trackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; MoveCursorAt(gesture, trackingInfo, warning); FireAt(gesture); }
/// <summary> /// Handles the information from the processed frame in order to use the gesture information and tracking information in moving the cursor and firing at the blocks. /// </summary> void HandleManoMotionFrameProcessed() { GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; TrackingInfo trackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; MoveCursorAt(gesture, trackingInfo, warning); FireAt(gesture); }
/// <summary> /// Up時に呼び出されます /// </summary> /// <param name="info">Info.</param> public void OnGestureUp(GestureInfo info) { if (GameSceneManager.Instance.ePlayType == GameSceneManager.PlayType.PAUSE) { _isSelected = false; return; } _isSelected = false; }
// Update is called once per frame void Update() { TrackingInfo trackingInfo = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; ManoGestureTrigger someGesture = gesture.mano_gesture_trigger; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; ContinuousGesture(gesture, trackingInfo, warning); ShootProjectiles(someGesture, warning); }
// Update is called once per frame void Update() { GestureInfo gesture = ManomotionManager.Instance.Hand_infos[0].hand_info.gesture_info; TrackingInfo tracking = ManomotionManager.Instance.Hand_infos[0].hand_info.tracking_info; Warning warning = ManomotionManager.Instance.Hand_infos[0].hand_info.warning; AssignSpookeyFace(gesture, warning); MoveAndScaleSpookey(tracking, warning); HighlightSpookeyImage(warning); }
/// <summary> /// Displays information regarding the Trigger Gesture of the detected hand /// </summary> /// <param name="gesture_info"></param> void DisplayTriggerGesture(GestureInfo gesture_info) { triggerGestureGizmo.SetActive(Show_trigger_gesture); if (Show_trigger_gesture) { ManoGestureTrigger trigger = gesture_info.mano_gesture_trigger; switch (trigger) { case ManoGestureTrigger.CLICK: triggerGestureText.text = "Trigger: Click"; break; case ManoGestureTrigger.SWIPE_LEFT: triggerGestureText.text = "Trigger: Swipe Left"; break; case ManoGestureTrigger.SWIPE_RIGHT: triggerGestureText.text = "Trigger: Swipe Right"; break; case ManoGestureTrigger.GRAB: triggerGestureText.text = "Trigger: Grab"; Object.GetComponent <Renderer>().material.color = Color.red; Fire(); break; case ManoGestureTrigger.TAP_POINTING: triggerGestureText.text = "Trigger: Tap"; break; case ManoGestureTrigger.DROP: triggerGestureText.text = "Trigger: Drop"; break; case ManoGestureTrigger.PICK: triggerGestureText.text = "Trigger: Pick"; break; case ManoGestureTrigger.RELEASE: triggerGestureText.text = "Trigger: Release"; Object.GetComponent <Renderer>().material.color = Color.blue; Fire(); break; case ManoGestureTrigger.NO_GESTURE: triggerGestureText.text = "Trigger: "; break; default: triggerGestureText.text = "Trigger: "; break; } } }
void CanStartGame(GestureInfo gesture, Warning warning) { // The hand should be visible and have the open hand gesture before starting if (warning == Warning.NO_WARNING && gesture.mano_gesture_continuous == ManoGestureContinuous.OPEN_HAND_GESTURE) { if (OnCanStartGame != null) { OnCanStartGame.Invoke(); } } }
void ContinuousGesture(GestureInfo gesture, TrackingInfo tracking) { if (gesture.mano_gesture_continuous == ManoGestureContinuous.CLOSED_HAND_GESTURE) { Invoke("Reload", 1f); //Handheld.Vibrate(); Vector3 boundingBoxCenter = tracking.bounding_box_center; boundingBoxCenter.z = 10f; projectileSpawn.transform.position = Camera.main.ViewportToWorldPoint(boundingBoxCenter); holdAnimation.transform.position = Camera.main.ViewportToWorldPoint(boundingBoxCenter); } }
/// <summary> /// Updates the visual information that showcases the hand state (how open/closed) it is /// </summary> /// <param name="gesture_info"></param> void DisplayHandState(GestureInfo gesture_info) { handStatesGizmo.SetActive(Show_hand_states && !ChooseBackgroundBehavior.Instance.backgroundMenuIsOpen); if (Show_hand_states) { HighlightStatesToStateDetection(gesture_info.state); } else { handStatesGizmo.SetActive(false); } }
/// <summary> /// Display the POI cursor /// </summary> /// <param name="gesture">Gesture.</param> /// <param name="warning">Warning.</param> /// <param name="trackingInfo">Tracking info.</param> void DisplayPOI(GestureInfo gesture, Warning warning, TrackingInfo trackingInfo) { bool isPinchWellDetected = currentThumbCounter > maxThumbCounter / 2; if (ShowPOI) { if (gesture.mano_class == ManoClass.PINCH_GESTURE_FAMILY) { if (currentThumbCounter < maxThumbCounter) { currentThumbCounter++; } } else { if (currentThumbCounter > minThumbCounter) { currentThumbCounter--; } } if (warning != Warning.WARNING_HAND_NOT_FOUND && isPinchWellDetected) { if (!POIGizmo.activeInHierarchy) { POIGizmo.SetActive(true); } float smoothing = 1 - ManomotionManager.Instance.Manomotion_Session.smoothing_controller; poiRectTransform.position = Camera.main.ViewportToScreenPoint(trackingInfo.poi); float newFillAmmount = 1 - ((int)(gesture.state / 6) * 0.25f); poiFillAmmount.localScale = Vector3.Lerp(palmCenterFillAmmount.localScale, Vector3.one * newFillAmmount, 0.9f); } else { if (POIGizmo.activeInHierarchy) { POIGizmo.SetActive(false); } } } else { if (POIGizmo.activeInHierarchy) { POIGizmo.SetActive(false); } } }
public void OnGestureUp(GestureInfo info) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); // レイヤーマスク:http://docs.unity3d.com/jp/current/Manual/Layers.html // Bit shift the index of the layer (8) to get a bit mask int layerMask = 1 << 8; //layerMask = ~layerMask; if (Physics.Raycast(ray, out hit, 100f, layerMask)){ agent.SetDestination(hit.point); target.position = hit.point; //character.Move(target.position, false, false); //Debug.Log("agent.desiredVelocity:"+agent.desiredVelocity); //Debug.Log("agent.velocity:"+agent.velocity); //Debug.Log("agent.magnitude:"+agent.desiredVelocity.magnitude); } }
string simpleGesture(GestureInfo gi) { var targetDir = (gi.CurrentScreenPosition - gi.StartScreenPosition).normalized; var forward = Vector3.up; var angle = SignedAngleBetween(targetDir, forward, forward); if (targetDir.y > 0 && angle > 0 && angle <= 20) { return "SimpleUp"; } if (targetDir.y < 0 && angle > 0 && angle > 160) { return "SimpleDown"; } if (targetDir.x > 0 && angle <= 110 && angle >= 70) { return "SimpleRight"; } if (targetDir.x < 0 && angle <= 110 && angle >= 70) { return "SimpleLeft"; } return ""; }
public void OnGestureDrag(GestureInfo info) { // Drag時に呼ばれます }
public void OnGestureUp(GestureInfo info) { // Up時に呼ばれます }
public string getGesture() { if (Input.touchCount == 0) { var nb = getNbInput (); if (nb == 1) { var ret = simpleGesture(gestureInfo[0]); gestureInfo.Clear (); return ret; } else if (nb == 2) { var ret = doubleGesture(); gestureInfo.Clear (); return ret; } else { gestureInfo.Clear (); return ""; } } for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.touches [i]; switch (touch.phase) { case TouchPhase.Began: GestureInfo gi = new GestureInfo (); gi.TouchId = touch.fingerId; gi.CurrentScreenPosition = touch.position; gi.StartScreenPosition = touch.position; gi.DeltaDragDistance = touch.deltaPosition; gi.DeltaDurationTime = touch.deltaTime; gi.IsDown = true; gi.IsUp = false; gi.IsDrag = false; gestureInfo.Add(gi); break; case TouchPhase.Moved: for (int j = 0; j < gestureInfo.Count; j++) { if (touch.fingerId == gestureInfo [j].TouchId) { gestureInfo [j].CurrentScreenPosition = touch.position; gestureInfo [j].DeltaDragDistance = touch.deltaPosition; gestureInfo [j].DeltaDurationTime = touch.deltaTime; gestureInfo [j].IsDrag = true; break; } } break; case TouchPhase.Ended: case TouchPhase.Canceled: for (int j = 0; j < gestureInfo.Count; j++) { if (touch.fingerId == gestureInfo [j].TouchId) { gestureInfo [j].CurrentScreenPosition = touch.position; gestureInfo [j].DeltaDragDistance = touch.deltaPosition; gestureInfo [j].DeltaDurationTime = touch.deltaTime; gestureInfo [j].IsUp = true; break; } } break; } } return ""; }
public bool IsGestureProcess(GestureInfo info) { return true; }
/// <summary> /// Adds the gestureInfo to the end of GestureSamples collection /// </summary> /// <param name="gesureInfo"></param> public void AddGesture(GestureInfo gesureInfo) { _gestureSamples.Add(gesureInfo); }
public void OnGestureDown(GestureInfo info) { }
public void OnGestureDrag(GestureInfo info) { }
public void OnGestureFlick(GestureInfo info) { }