Example #1
0
    void GiveObjToHand(int id, RigidHand myHand)
    {
        if (cheatObj[id] == null)
        {
            return;
        }

        RigidObject temp = cheatObj[id].GetComponent <RigidObject>();

        if (temp != null)
        {
            if (temp.GetComponent <ExplodeObj>() != null)
            {
                if (temp.GetComponent <ExplodeObj>().ResetToHand(myHand))
                {
                    return;
                }
            }

            myHand.GraspGameObjectInHand(temp);
        }
    }
Example #2
0
    void Update()
    {
        //show or hide hand by hand's detect
        UpdateHideOrShowHand();



        if (graspObj != null && graspObj.GetComponent <MusicBoxCtrl> () != null)
        {
            if (!meshHand.isDetected)
            {
                isGraspObj           = false;
                handRenderer.enabled = true;
                graspObj.gameObject.SetActive(true);
                graspObj.HandRelease();
                graspObj   = null;
                GraspFrame = 0;
            }
        }

        if (!meshHand.isDetected)
        {
            if (isPostGraspEvent)
            {
                isPostGraspEvent = false;
                if (FingoGestureEvent.OnFingoRelease != null)
                {
                    FingoGestureEvent.OnFingoRelease(meshHand.handType);
                }
            }
        }

        if (graspFingersNum < 1 && meshHand.isDetected)
        {
            //Where's my hand?
            if (Vector3.Distance(this.transform.position, Camera.main.transform.position) > 2.0f)
            {
                return;
            }
            //post release event
            if (isPostGraspEvent)
            {
                isPostGraspEvent = false;
                if (FingoGestureEvent.OnFingoRelease != null)
                {
                    FingoGestureEvent.OnFingoRelease(meshHand.handType);
                }
            }

            //grasp release
            if (isGraspObj)
            {
                GraspFrame++;
                if (GraspFrame % graspDelayFrame == 0)
                {
                    isGraspObj           = false;
                    handRenderer.enabled = true;
                    graspObj.gameObject.SetActive(true);
                    graspObj.HandRelease();
                    graspObj   = null;
                    GraspFrame = 0;
                }
            }

            return;
        }

        if (graspFingersNum > 2 && meshHand.isDetected)
        {
            //post grasp start event
            if (!isPostGraspEvent)
            {
                isPostGraspEvent = true;
                if (FingoGestureEvent.OnFingoGraspStart != null)
                {
                    FingoGestureEvent.OnFingoGraspStart(meshHand.handType);
                }
            }

            if (!isGraspObj && interactionThing != null)
            {
                GraspFrame++;

                if (GraspFrame % graspDelayFrame == 0)
                {
                    //if obj is in another hand, this hand will be ignored
                    graspObj = interactionThing.GetComponent <RigidObject>();
                    if (!graspObj.isGrasped)
                    {
                        //grasp start
                        isGraspObj = true;
                        graspObj.gameObject.SetActive(true);
                        graspObj.HandGrasp(this);
                        GraspFrame = 0;
                    }
                }
            }
        }

        if (isPostGraspEvent)
        {
            if (FingoGestureEvent.OnFingoGraspingPalmInfo != null)
            {
                FingoGestureEvent.OnFingoGraspingPalmInfo(meshHand.handType, this);
            }
        }
    }