コード例 #1
0
ファイル: CustomInteractible.cs プロジェクト: rav3dev/vrtwix
 public void SetInteractibleVariable(CustomHand hand)
 {
     if (hand.handType == SteamVR_Input_Sources.LeftHand)
     {
         if (leftHand)
         {
             DettachHand(leftHand);
         }
         if (!twoHanded && rightHand)
         {
             DettachHand(rightHand);
         }
         leftMyGrabPoser = ClosePoser(hand.PointByPoint(hand.gripPoint));
         if (leftMyGrabPoser)
         {
             hand.grabPoser = leftMyGrabPoser;
             leftHand       = hand;
             leftHand.SkeletonUpdate();
         }
         //haptic
     }
     if (hand.handType == SteamVR_Input_Sources.RightHand)
     {
         if (rightHand)
         {
             DettachHand(rightHand);
         }
         if (!twoHanded && leftHand)
         {
             DettachHand(leftHand);
         }
         rightMyGrabPoser = ClosePoser(hand.PointByPoint(hand.gripPoint));
         if (rightMyGrabPoser)
         {
             hand.grabPoser = rightMyGrabPoser;
             rightHand      = hand;
             rightHand.SkeletonUpdate();
         }
         //haptic
     }
 }
コード例 #2
0
    public void GrabStartCustom(CustomHand hand)
    {
        Vector3 tempPosHandLocal = transform.InverseTransformPoint(hand.PointByPoint(hand.gripPoint));

        tempPosHandLocal.x             = 0;
        tempPosHandLocal.y             = 0;
        myRigidbody.useGravity         = false;
        myRigidbody.isKinematic        = false;
        myRigidbody.maxAngularVelocity = float.MaxValue;

        if (tempPosHandLocal.z > clampHandlePosZ.x && tempPosHandLocal.z < clampHandlePosZ.y)
        {
            if (hand.handType == SteamVR_Input_Sources.LeftHand)
            {
                SetInteractibleVariable(hand, handleObject [0]);
                handleObject [0].transform.localPosition = tempPosHandLocal;
            }
            else
            {
                if (hand.handType == SteamVR_Input_Sources.RightHand)
                {
                    SetInteractibleVariable(hand, handleObject [1]);
                    handleObject [1].transform.localPosition = tempPosHandLocal;
                }
            }
        }
        else
        {
            SetInteractibleVariable(hand);
        }

        if (leftHand && rightHand)
        {
            leftIsForvard = transform.InverseTransformPoint(leftMyGrabPoser.transform.position).z > transform.InverseTransformPoint(rightMyGrabPoser.transform.position).z;
            LocalDirectionWithPivotLeft  = leftMyGrabPoser.transform.InverseTransformDirection(transform.up);
            LocalDirectionWithPivotRight = rightMyGrabPoser.transform.InverseTransformDirection(transform.up);
        }
        if (pickReleasePlayOnce)
        {
            if (!leftHand || !rightHand)
            {
                onGrab.Invoke();                 //sound
            }
        }
        else
        {
            onGrab.Invoke();
        }
    }