Beispiel #1
0
    void CompleteRevert(RigidHand myHand)
    {
        revertTime = 0.0f;

        FingoGestureEvent.OnFingoGraspStart       -= OnHandGraspStart;
        FingoGestureEvent.OnFingoGraspingPalmInfo -= OnHandGrasping;
        FingoGestureEvent.OnFingoRelease          -= OnHandRelease;

        canRevertClips = false;
        notePostion    = false;
        isExploded     = false;
        revertEvent    = false;

        GameObject.Destroy(mAudio);

        for (int j = 0; j < clips.Count; j++)
        {
            clips[j].rigidBody.isKinematic = false;
        }
        revertHandType = Fingo.HandType.Invalid;
        Exploder.FragmentPool.Instance.DeactivateFragments();

        //this.mRigidbody.isKinematic = false;
        this.GetComponent <Collider>().enabled = true;

        ShowSelf(this.transform);
        RigidObject rigidObj = this.transform.GetComponent <RigidObject>();

        myHand.GraspGameObjectInHand(rigidObj);
    }
Beispiel #2
0
    void DoRevertClipsAnimation(Fingo.HandType handType, RigidHand myHand)
    {
        //Debug.Log(handType.ToString() + " DoRevertClipsAnimation");
        revertTime += Time.deltaTime * 1.2f;
        for (int i = 0; i < clips.Count; i++)
        {
            Vector3 aminPos = this.transform.TransformPoint(clips[i].explodeMomentlocalPosition);
            Vector3 aminRot = this.transform.TransformVector(clips[i].explodeMomentlocalRotation.eulerAngles);

            if (revertTime > 1.0f)
            {
                clips[i].transform.position    = aminPos;
                clips[i].transform.eulerAngles = aminRot;
            }
            else
            {
                clips[i].transform.eulerAngles = Lerp(clipsOriginAngle[i], aminRot, revertTime);
                clips[i].transform.position    = Lerp(clipsOriginPos[i], aminPos, revertTime);
            }
        }

        if (revertTime > 1.0f)
        {
            CompleteRevert(myHand);
        }
    }
Beispiel #3
0
 void OnHandGraspStart(Fingo.HandType handType)
 {
     // use the first grasp hand
     if (revertHandType == Fingo.HandType.Invalid)
     {
         revertHandType = handType;
     }
 }
Beispiel #4
0
    // Use this for initialization
    void Awake()
    {
        notePostion = false;
        isExploded  = false;
        revertEvent = false;
        framePos    = new Vector3[5];

        originPos      = this.transform.position;
        originRotation = this.transform.rotation;

        mRigidbody  = this.GetComponent <Rigidbody>();
        exploderObj = GameObject.FindObjectOfType <Exploder.ExploderObject>() as Exploder.ExploderObject;

        revertHandType = Fingo.HandType.Invalid;
        canRevertClips = false;
        revertTime     = 0.0f;
    }
Beispiel #5
0
    void StopRevert(Fingo.HandType handType)
    {
        if (revertHandType == handType)
        {
            revertHandType = Fingo.HandType.Invalid;

            if (canRevertClips)
            {
                this.transform.GetComponent <RigidObject>().GraspEnd();
                this.mRigidbody.isKinematic = true;

                for (int j = 0; j < clips.Count; j++)
                {
                    clips[j].rigidBody.isKinematic = false;
                }
                canRevertClips = false;
            }
        }
    }
Beispiel #6
0
    void OnHandGrasping(Fingo.HandType handType, RigidHand myHand)
    {
        //if two hand both grasp, then one hand release, this will use another grasp hand
        if (revertHandType == Fingo.HandType.Invalid)
        {
            revertHandType = handType;
        }

        //exclude another hand's interference
        if (handType == revertHandType && !canRevertClips)
        {
            for (int i = 0; i < clips.Count; i++)
            {
                if (Vector3.Distance(clips[i].transform.position, myHand.transform.position) < 0.2f)
                {
                    canRevertClips = true;
                    this.transform.GetComponent <RigidObject>().GraspStart(myHand);
                }

                if (canRevertClips)
                {
                    for (int j = 0; j < clips.Count; j++)
                    {
                        clipsOriginPos[j]              = clips[j].transform.position;
                        clipsOriginAngle[j]            = clips[j].transform.eulerAngles;
                        clips[j].rigidBody.isKinematic = true;
                    }
                    return;
                }
            }
        }
        else if (handType == revertHandType && canRevertClips)
        {
            DoRevertClipsAnimation(handType, myHand);
        }
    }
Beispiel #7
0
 void OnHandRelease(Fingo.HandType handType)
 {
     StopRevert(handType);
 }