Exemple #1
0
    private void ToggleGestureBools()
    {
        float dis = Vector3.Distance(_activeIndex.transform.position, _activeThumb.transform.position);

        if (!Grab.Instance.IsGrabbing)
        {
            CheckIsGlobalFingerInObj();
            //Debug.Log("FoamUtils.IsGlobalFingerInObject: " + FoamUtils.IsGlobalFingerInObject);
            if (m_activeGC.bufferedGesture() == "pinch" && !FoamUtils.IsGlobalFingerInObject && dis < 0.035f)
            {
                m_stateMachine.SetBool(m_hash_pinchBool, true);
                _JUIGestureAnimator.SetBool(_hash_gesturePinchBool, true);
            }
            else
            {
                m_stateMachine.SetBool(m_hash_pinchBool, false);
                _JUIGestureAnimator.SetBool(_hash_gesturePinchBool, false);
            }


            if (m_activeGC.bufferedGesture() == "palm") // or include more gestures
            {
                m_stateMachine.SetBool(_hash_palmBool, true);
                _JUIGestureAnimator.SetBool(_hash_gesturePalmBool, true);
            }
            else
            {
                m_stateMachine.SetBool(_hash_palmBool, false);
                _JUIGestureAnimator.SetBool(_hash_gesturePalmBool, false);
            }
        }
    }
Exemple #2
0
    // Update the queue, assuming that Left and Right Hand Gesture Control isn't Null
    private void UpdateQueue()
    {
        // Debug.Log ("Updating Queue");

        // pop out obsolete items
        // --------------------- A potentialbug ---------------------------
        // if we use pause or something, since here it's Time.time that isn't affected by the time scale.
        // A short inresponse may happen (because previous items are pop out)
        // ----------------------------------------------------------------
        float currentTime = Time.time;

        while (leftHandList.Count >= 2 && currentTime - leftHandList.First.Value.InsertTime > obsoleteTime)
        {
            leftHandList.RemoveFirst();
        }
        while (rightHandList.Count >= 2 && currentTime - rightHandList.First.Value.InsertTime > obsoleteTime)
        {
            rightHandList.RemoveFirst();
        }

        // insert new gesture
        HandActionItem lhai = new HandActionItem(LeftHandGC.bufferedGesture(), currentTime, LeftHandPalm.forward, LeftHandPalm.position);
        HandActionItem rhai = new HandActionItem(RightHandGC.bufferedGesture(), currentTime, RightHandPalm.forward, RightHandPalm.position);

        if (leftHandList.Count == 0 || HandActionItem.CompareTwoHandActionItem(leftHandList.Last.Value, lhai) > newItemDelta)
        {
            leftHandList.AddLast(lhai);
            //	Debug.Log ("left add news");
        }
        if (rightHandList.Count == 0 || HandActionItem.CompareTwoHandActionItem(rightHandList.Last.Value, rhai) > newItemDelta)
        {
            rightHandList.AddLast(rhai);
            //	Debug.Log ("right add news");
        }
    }
Exemple #3
0
        /// <summary>
        /// Check if the hand is in grab gestures.
        /// </summary>
        /// <returns></returns>
        private bool IsGrabGesture()
        {
            if (m_selectObj == null)
            {
                return(false);
            }

            string gesture;

            if (m_selectObj.IsLeftHanded)
            {
                // check left hand gesture
                gesture = m_gcLeftHand.bufferedGesture();
            }
            else
            {
                gesture = m_gcRightHand.bufferedGesture();
            }
            return(gesture == "pinch" || gesture == "fist");
        }
Exemple #4
0
    void setupPaintPlane()
    {
        paintPlane.SetActive(true);

        if (!is2dPlanePlaced)
        {
            paintPlane.transform.localPosition = new Vector3(0, 0, 0.6f);
            paintPlane.transform.localRotation = Quaternion.Euler(-90, 0, 0);
            paintPlane.transform.parent        = palm.transform;

            if (gestureManager.bufferedGesture() == "palm" || (Input.touchCount > 0 &&
                                                               !(EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) &&
                                                               Input.GetTouch(0).phase == TouchPhase.Began))
            {
                Debug.Log("touch PLANE IS PLACED");
                paintPlane.transform.parent = null;
                is2dPlanePlaced             = true;
            }
        }
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        // Debug.Log(bIsLeftHand + " Gesture:" + gestureManager.bufferedGesture());
        if (HandActionRecog.getInstance() != null && HandActionRecog.getInstance().IsMotion("OpenMenu", bIsLeftHand))
        {
            contextSwitch("menu");
        }

        switch (context)
        {
        case "menu":
            break;

        case "paint":
            break;

        default:
            GameObject interact_obj = getHandObject();
            if (interact_obj != null)
            {
                cleanGuidance();
                //if hand gesture is grabbing
                string cur_gesture = gestureManager.bufferedGesture();
                if (cur_gesture == "pinch" || cur_gesture == "fist")
                {
                    //grab objbect if hand is not grabbing
                    if (!is_grabbing)
                    {
                        grabObject(interact_obj);
                    }
                    else
                    {
                        this.updateObjTransform(interact_obj);
                    }
                    //Debug.Log ("obj isTrigger is " + interact_obj.GetComponent<Collider>().isTrigger + "palm isTrigger is " + palm.GetComponent<Collider>().isTrigger + "palm angular v is " + palm.GetComponent<Rigidbody>().angularVelocity);
                    //if hand gesture is not grabbing
                }
                else
                {
                    //but hand is grabbing
                    Transform indextip        = transform.Find("index").Find("bone3");
                    Transform thumbtip        = transform.Find("thumb").Find("bone3");
                    float     index_thumb_dis = Vector3.Distance(indextip.position, thumbtip.position);

                    if (is_grabbing && (cur_gesture == "palm" || index_thumb_dis > 0.04f))
                    {
                        Debug.Log("Grab:Release Grab, current gesture:" + gestureManager.bufferedGesture());
                        //then tell the object to release itself, Here support two version of interaction objects.
                        InteractionScriptObject iso = interact_obj.GetComponent <InteractionScriptObject> ();
                        if (iso != null && iso.isActiveAndEnabled)
                        {
                            iso.releaseSelf();
                        }
                        else
                        {
                            GrabCollider gc = interact_obj.GetComponentInChildren <GrabCollider> ();
                            if (gc != null)
                            {
                                gc.OnGrabFinished();
                            }
                        }
                        //releaseObject (interact_obj);
                        CancelInvoke();
                    }
                    else if (is_grabbing)
                    {
                        this.updateObjTransform(interact_obj);
                    }
                }

                /* nothing in hand (interactable object is null)*/
            }
            else
            {
                if (gestureManager.bufferedGesture() == "palm")
                {
                    hitObject();
                }
                else
                {
                    cleanGuidance();
                }
            }
            break;
        }
        updateHandSpeed();
    }