Example #1
0
        void Update()
        {
            if (RH_Mode && RH.GetReceivedStatus() == VRTRIXGloveStatus.NORMAL)
            {
                if (RH.GetReceivedRotation(VRTRIXBones.R_Hand) != Quaternion.identity && !qroffset_cal)
                {
                    qroffset     = CalculateStaticOffset(RH, HANDTYPE.RIGHT_HAND);
                    qroffset_cal = true;
                }

                if (IsVREnabled && RH_tracker != null)
                {
                    SetPosition(VRTRIXBones.R_Arm, RH_tracker.transform.position, RH_tracker.transform.rotation, RHTrackerOffset);
                }
                //以下是设置右手每个骨骼节点全局旋转(global rotation);
                for (int i = 0; i < (int)VRTRIXBones.L_Hand; ++i)
                {
                    SetRotation((VRTRIXBones)i, RH.GetReceivedRotation((VRTRIXBones)i), HANDTYPE.RIGHT_HAND);
                }

                RH.SetThumbOffset(thumb_offset_R[0], VRTRIXBones.R_Thumb_1);
                RH.SetThumbOffset(thumb_offset_R[1], VRTRIXBones.R_Thumb_2);
                RH.SetThumbOffset(thumb_offset_R[2], VRTRIXBones.R_Thumb_3);
                RH.SetThumbSlerpRate(thumb_proximal_slerp, thumb_middle_slerp);
                RH.SetFinalFingerSpacing(final_finger_spacing);
                RH.SetFingerSpacing(finger_spacing);
                RH_Gesture = GloveGesture.GestureDetection(RH, HANDTYPE.RIGHT_HAND);
            }



            if (LH_Mode && LH.GetReceivedStatus() == VRTRIXGloveStatus.NORMAL)
            {
                if (LH.GetReceivedRotation(VRTRIXBones.L_Hand) != Quaternion.identity && !qloffset_cal)
                {
                    qloffset     = CalculateStaticOffset(LH, HANDTYPE.LEFT_HAND);
                    qloffset_cal = true;
                }

                if (IsVREnabled && LH_tracker != null)
                {
                    SetPosition(VRTRIXBones.L_Arm, LH_tracker.transform.position, LH_tracker.transform.rotation, LHTrackerOffset);
                }

                //以下是设置左手每个骨骼节点全局旋转(global rotation);
                for (int i = (int)VRTRIXBones.L_Hand; i < (int)VRTRIXBones.R_Arm; ++i)
                {
                    SetRotation((VRTRIXBones)i, LH.GetReceivedRotation((VRTRIXBones)i), HANDTYPE.LEFT_HAND);
                }

                LH.SetThumbOffset(thumb_offset_L[0], VRTRIXBones.L_Thumb_1);
                LH.SetThumbOffset(thumb_offset_L[1], VRTRIXBones.L_Thumb_2);
                LH.SetThumbOffset(thumb_offset_L[2], VRTRIXBones.L_Thumb_3);
                LH.SetThumbSlerpRate(thumb_proximal_slerp, thumb_middle_slerp);
                LH.SetFinalFingerSpacing(final_finger_spacing);
                LH.SetFingerSpacing(finger_spacing);
                LH_Gesture = GloveGesture.GestureDetection(LH, HANDTYPE.LEFT_HAND);
            }
        }
Example #2
0
 //数据手套初始化,硬件连接
 //! Connect data glove and initialization.
 public void OnConnectGlove()
 {
     if (IsVREnabled && LH_tracker == null && RH_tracker == null)
     {
         return;
     }
     try
     {
         LH_Mode = LH.Init(HANDTYPE.LEFT_HAND);
         if (LH_Mode)
         {
             print("Left hand glove connected!");
             LH.SetThumbOffset(thumb_offset_L[0], VRTRIXBones.L_Thumb_1);
             LH.SetThumbOffset(thumb_offset_L[1], VRTRIXBones.L_Thumb_2);
             LH.SetThumbOffset(thumb_offset_L[2], VRTRIXBones.L_Thumb_3);
             LH.SetThumbSlerpRate(thumb_proximal_slerp, thumb_middle_slerp);
             LH.RegisterCallBack();
             LH.StartStreaming();
         }
         RH_Mode = RH.Init(HANDTYPE.RIGHT_HAND);
         if (RH_Mode)
         {
             print("Right hand glove connected!");
             RH.SetThumbOffset(thumb_offset_R[0], VRTRIXBones.R_Thumb_1);
             RH.SetThumbOffset(thumb_offset_R[1], VRTRIXBones.R_Thumb_2);
             RH.SetThumbOffset(thumb_offset_R[2], VRTRIXBones.R_Thumb_3);
             RH.SetThumbSlerpRate(thumb_proximal_slerp, thumb_middle_slerp);
             RH.RegisterCallBack();
             RH.StartStreaming();
         }
     }
     catch (Exception e)
     {
         print("Exception caught: " + e);
     }
 }