//获取磁场校准水平均值 //! Get current calibration score average value /*! * \param type Data glove hand type. * \return current calibration score average value. */ public int GetReceivedCalScoreMean(HANDTYPE type) { switch (type) { case HANDTYPE.RIGHT_HAND: { return(RH.GetReceivedCalScoreMean()); } case HANDTYPE.LEFT_HAND: { return(LH.GetReceivedCalScoreMean()); } default: return(0); } }
// Update is called once per frame void Update() { if (UIEnabled) { if (m_timeCounter < m_refreshTime) { m_timeCounter += Time.deltaTime; m_frameCounter++; } else { m_lastFramerate = (float)m_frameCounter / m_timeCounter; m_frameCounter = 0; m_timeCounter = 0.0f; } m_FPS.GetComponent <Text>().text = "FRAME RATE: " + m_lastFramerate.ToString() + " fps"; if (RH_Mode) { m_Status.GetComponent <Text>().text = "GLOVE STATUS: CONNECTED"; m_MODE.GetComponent <Text>().text = "MODE: RIGHT ONLY"; m_RHStatus.GetComponent <Text>().text = "RIGHT HAND STATUS: CONNECTED"; m_RHRadio.GetComponent <Text>().text = "Radio Strength: " + RH.GetReceiveRadioStrength().ToString() + " dB"; RadioStrengthGUI(m_RHRadioBar.GetComponent <Image>(), RH.GetReceiveRadioStrength()); m_RHCal.GetComponent <Text>().text = "Cal Score: " + RH.GetReceivedCalScoreMean().ToString(); CalScoreGUI(m_RHCalBar.GetComponent <Image>(), RH.GetReceivedCalScoreMean()); m_RHDataRate.GetComponent <Text>().text = "RIGHT HAND DATA RATE: " + RH.GetReceivedDataRate().ToString() + "/s"; m_RHand.GetComponent <Text>().text = "R_Hand " + RH.GetReceivedRotation(VRTRIXBones.R_Hand).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Hand).ToString(); m_RThumb.GetComponent <Text>().text = "R_Thumb " + RH.GetReceivedRotation(VRTRIXBones.R_Thumb_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Thumb_2).ToString(); m_RIndex.GetComponent <Text>().text = "R_Index " + RH.GetReceivedRotation(VRTRIXBones.R_Index_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Index_2).ToString(); m_RMiddle.GetComponent <Text>().text = "R_Middle " + RH.GetReceivedRotation(VRTRIXBones.R_Middle_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Middle_2).ToString(); m_RRing.GetComponent <Text>().text = "R_Ring " + RH.GetReceivedRotation(VRTRIXBones.R_Ring_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Ring_2).ToString(); m_RPinky.GetComponent <Text>().text = "R_Pinky " + RH.GetReceivedRotation(VRTRIXBones.R_Pinky_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Pinky_2).ToString(); } if (LH_Mode) { m_Status.GetComponent <Text>().text = "GLOVE STATUS: CONNECTED"; m_MODE.GetComponent <Text>().text = "MODE: LEFT ONLY"; m_LHStatus.GetComponent <Text>().text = "LEFT HAND STATUS: CONNECTED"; m_LHRadio.GetComponent <Text>().text = "Radio Strength: " + LH.GetReceiveRadioStrength().ToString() + " dB"; RadioStrengthGUI(m_LHRadioBar.GetComponent <Image>(), LH.GetReceiveRadioStrength()); m_LHCal.GetComponent <Text>().text = "Cal Score: " + LH.GetReceivedCalScoreMean().ToString(); CalScoreGUI(m_LHCalBar.GetComponent <Image>(), LH.GetReceivedCalScoreMean()); m_LHDataRate.GetComponent <Text>().text = "LEFT HAND DATA RATE: " + LH.GetReceivedDataRate().ToString() + "/s"; m_LHand.GetComponent <Text>().text = "L_HAND: " + LH.GetReceivedRotation(VRTRIXBones.L_Hand) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Hand).ToString(); m_LThumb.GetComponent <Text>().text = "L_THUMB: " + LH.GetReceivedRotation(VRTRIXBones.L_Thumb_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Thumb_2).ToString(); m_LIndex.GetComponent <Text>().text = "L_INDEX: " + LH.GetReceivedRotation(VRTRIXBones.L_Index_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Index_2).ToString(); m_LMiddle.GetComponent <Text>().text = "L_MIDDLE: " + LH.GetReceivedRotation(VRTRIXBones.L_Index_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Index_2).ToString(); m_LRing.GetComponent <Text>().text = "L_RING: " + LH.GetReceivedRotation(VRTRIXBones.L_Ring_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Ring_2).ToString(); m_LPinky.GetComponent <Text>().text = "L_PINKY: " + LH.GetReceivedRotation(VRTRIXBones.L_Pinky_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Pinky_2).ToString(); } if (RH_Mode && LH_Mode) { m_MODE.GetComponent <Text>().text = "MODE: PAIR"; } } if (RH_Mode) { Mode = VRTRIXGloveRunningMode.RIGHT; } if (LH_Mode) { Mode = VRTRIXGloveRunningMode.LEFT; } if (RH_Mode && LH_Mode) { Mode = VRTRIXGloveRunningMode.PAIR; } }
// Update is called once per frame void Update() { if (m_timeCounter < m_refreshTime) { m_timeCounter += Time.deltaTime; m_frameCounter++; } else { //This code will break if you set your m_refreshTime to 0, which makes no sense. m_lastFramerate = (float)m_frameCounter / m_timeCounter; m_frameCounter = 0; m_timeCounter = 0.0f; } fps.text = "FRAME RATE: " + m_lastFramerate.ToString() + " fps"; if (RH_Mode && RH.GetReceivedStatus() == VRTRIXGloveStatus.NORMAL) { if (RH.GetReceivedRotation(VRTRIXBones.R_Hand) != Quaternion.identity && !qroffset_cal) { qroffset = GetOffset(objectToAlign, RH, HANDTYPE.RIGHT_HAND); qroffset_cal = true; } rh_radio.text = "Radio Strength: " + RH.GetReceiveRadioStrength().ToString() + " dB"; rh_cal.text = "Cal Score: " + RH.GetReceivedCalScoreMean().ToString(); R_data_rate_text.text = "RIGHT HAND DATA RATE: " + RH.GetReceivedDataRate().ToString() + "/s"; SetRotation(VRTRIXBones.R_Forearm, RH.GetReceivedRotation(VRTRIXBones.R_Forearm), RH.DataValidStatus(VRTRIXBones.R_Forearm), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Hand, RH.GetReceivedRotation(VRTRIXBones.R_Hand), RH.DataValidStatus(VRTRIXBones.R_Hand), HANDTYPE.RIGHT_HAND); R_hand_text.text = "R_Hand " + RH.GetReceivedRotation(VRTRIXBones.R_Hand).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Hand).ToString(); SetRotation(VRTRIXBones.R_Thumb_1, RH.GetReceivedRotation(VRTRIXBones.R_Thumb_1), RH.DataValidStatus(VRTRIXBones.R_Thumb_1), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Thumb_2, RH.GetReceivedRotation(VRTRIXBones.R_Thumb_2), RH.DataValidStatus(VRTRIXBones.R_Thumb_2), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Thumb_3, RH.GetReceivedRotation(VRTRIXBones.R_Thumb_3), RH.DataValidStatus(VRTRIXBones.R_Thumb_3), HANDTYPE.RIGHT_HAND); R_thumb_text.text = "R_Thumb " + RH.GetReceivedRotation(VRTRIXBones.R_Thumb_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Thumb_2).ToString(); SetRotation(VRTRIXBones.R_Index_1, RH.GetReceivedRotation(VRTRIXBones.R_Index_1), RH.DataValidStatus(VRTRIXBones.R_Index_1), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Index_2, RH.GetReceivedRotation(VRTRIXBones.R_Index_2), RH.DataValidStatus(VRTRIXBones.R_Index_2), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Index_3, RH.GetReceivedRotation(VRTRIXBones.R_Index_3), RH.DataValidStatus(VRTRIXBones.R_Index_3), HANDTYPE.RIGHT_HAND); R_index_text.text = "R_Index " + RH.GetReceivedRotation(VRTRIXBones.R_Index_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Index_2).ToString(); SetRotation(VRTRIXBones.R_Middle_1, RH.GetReceivedRotation(VRTRIXBones.R_Middle_1), RH.DataValidStatus(VRTRIXBones.R_Middle_1), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Middle_2, RH.GetReceivedRotation(VRTRIXBones.R_Middle_2), RH.DataValidStatus(VRTRIXBones.R_Middle_2), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Middle_3, RH.GetReceivedRotation(VRTRIXBones.R_Middle_3), RH.DataValidStatus(VRTRIXBones.R_Middle_3), HANDTYPE.RIGHT_HAND); R_middle_text.text = "R_Middle " + RH.GetReceivedRotation(VRTRIXBones.R_Middle_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Middle_2).ToString(); SetRotation(VRTRIXBones.R_Ring_1, RH.GetReceivedRotation(VRTRIXBones.R_Ring_1), RH.DataValidStatus(VRTRIXBones.R_Ring_1), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Ring_2, RH.GetReceivedRotation(VRTRIXBones.R_Ring_2), RH.DataValidStatus(VRTRIXBones.R_Ring_2), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Ring_3, RH.GetReceivedRotation(VRTRIXBones.R_Ring_3), RH.DataValidStatus(VRTRIXBones.R_Ring_3), HANDTYPE.RIGHT_HAND); R_ring_text.text = "R_Ring " + RH.GetReceivedRotation(VRTRIXBones.R_Ring_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Ring_2).ToString(); SetRotation(VRTRIXBones.R_Pinky_1, RH.GetReceivedRotation(VRTRIXBones.R_Pinky_1), RH.DataValidStatus(VRTRIXBones.R_Pinky_1), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Pinky_2, RH.GetReceivedRotation(VRTRIXBones.R_Pinky_2), RH.DataValidStatus(VRTRIXBones.R_Pinky_2), HANDTYPE.RIGHT_HAND); SetRotation(VRTRIXBones.R_Pinky_3, RH.GetReceivedRotation(VRTRIXBones.R_Pinky_3), RH.DataValidStatus(VRTRIXBones.R_Pinky_3), HANDTYPE.RIGHT_HAND); R_pinky_text.text = "R_Pinky " + RH.GetReceivedRotation(VRTRIXBones.R_Pinky_2).ToString() + " " + RH.GetReceivedCalScore(VRTRIXBones.R_Pinky_2).ToString(); } if (LH_Mode && LH.GetReceivedStatus() == VRTRIXGloveStatus.NORMAL) { if (LH.GetReceivedRotation(VRTRIXBones.L_Hand) != Quaternion.identity && !qloffset_cal) { qloffset = GetOffset(objectToAlign, LH, HANDTYPE.LEFT_HAND); qloffset_cal = true; } lh_radio.text = "Radio Strength: " + LH.GetReceiveRadioStrength().ToString() + " dB"; lh_cal.text = "Cal Score: " + LH.GetReceivedCalScoreMean().ToString(); L_data_rate_text.text = "LEFT HAND DATA RATE: " + LH.GetReceivedDataRate().ToString() + "/s"; SetRotation(VRTRIXBones.L_Forearm, LH.GetReceivedRotation(VRTRIXBones.L_Forearm), LH.DataValidStatus(VRTRIXBones.L_Forearm), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Hand, LH.GetReceivedRotation(VRTRIXBones.L_Hand), LH.DataValidStatus(VRTRIXBones.L_Hand), HANDTYPE.LEFT_HAND); L_hand_text.text = "L_HAND: " + LH.GetReceivedRotation(VRTRIXBones.L_Hand) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Hand).ToString(); SetRotation(VRTRIXBones.L_Thumb_1, LH.GetReceivedRotation(VRTRIXBones.L_Thumb_1), LH.DataValidStatus(VRTRIXBones.L_Thumb_1), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Thumb_2, LH.GetReceivedRotation(VRTRIXBones.L_Thumb_2), LH.DataValidStatus(VRTRIXBones.L_Thumb_2), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Thumb_3, LH.GetReceivedRotation(VRTRIXBones.L_Thumb_3), LH.DataValidStatus(VRTRIXBones.L_Thumb_3), HANDTYPE.LEFT_HAND); L_thumb_text.text = "L_THUMB: " + LH.GetReceivedRotation(VRTRIXBones.L_Thumb_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Thumb_2).ToString(); SetRotation(VRTRIXBones.L_Index_1, LH.GetReceivedRotation(VRTRIXBones.L_Index_1), LH.DataValidStatus(VRTRIXBones.L_Index_1), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Index_2, LH.GetReceivedRotation(VRTRIXBones.L_Index_2), LH.DataValidStatus(VRTRIXBones.L_Index_2), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Index_3, LH.GetReceivedRotation(VRTRIXBones.L_Index_3), LH.DataValidStatus(VRTRIXBones.L_Index_3), HANDTYPE.LEFT_HAND); L_index_text.text = "L_INDEX: " + LH.GetReceivedRotation(VRTRIXBones.L_Index_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Index_2).ToString(); SetRotation(VRTRIXBones.L_Middle_1, LH.GetReceivedRotation(VRTRIXBones.L_Middle_1), LH.DataValidStatus(VRTRIXBones.L_Middle_1), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Middle_2, LH.GetReceivedRotation(VRTRIXBones.L_Middle_2), LH.DataValidStatus(VRTRIXBones.L_Middle_2), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Middle_3, LH.GetReceivedRotation(VRTRIXBones.L_Middle_3), LH.DataValidStatus(VRTRIXBones.L_Middle_3), HANDTYPE.LEFT_HAND); L_middle_text.text = "L_MIDDLE: " + LH.GetReceivedRotation(VRTRIXBones.L_Index_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Index_2).ToString(); SetRotation(VRTRIXBones.L_Ring_1, LH.GetReceivedRotation(VRTRIXBones.L_Ring_1), LH.DataValidStatus(VRTRIXBones.L_Ring_1), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Ring_2, LH.GetReceivedRotation(VRTRIXBones.L_Ring_2), LH.DataValidStatus(VRTRIXBones.L_Ring_2), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Ring_3, LH.GetReceivedRotation(VRTRIXBones.L_Ring_3), LH.DataValidStatus(VRTRIXBones.L_Ring_3), HANDTYPE.LEFT_HAND); L_ring_text.text = "L_RING: " + LH.GetReceivedRotation(VRTRIXBones.L_Ring_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Ring_2).ToString(); SetRotation(VRTRIXBones.L_Pinky_1, LH.GetReceivedRotation(VRTRIXBones.L_Pinky_1), LH.DataValidStatus(VRTRIXBones.L_Pinky_1), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Pinky_2, LH.GetReceivedRotation(VRTRIXBones.L_Pinky_2), LH.DataValidStatus(VRTRIXBones.L_Pinky_2), HANDTYPE.LEFT_HAND); SetRotation(VRTRIXBones.L_Pinky_3, LH.GetReceivedRotation(VRTRIXBones.L_Pinky_3), LH.DataValidStatus(VRTRIXBones.L_Pinky_3), HANDTYPE.LEFT_HAND); L_pinky_text.text = "L_PINKY: " + LH.GetReceivedRotation(VRTRIXBones.L_Pinky_2) + " " + LH.GetReceivedCalScore(VRTRIXBones.L_Pinky_2).ToString(); //print(GameObject.Find("L_Thumb_1").transform.rotation * Quaternion.Inverse(LH.GetReceivedRotation(VRTRIXBones.L_Hand))); //print(GameObject.Find("L_Index_2").transform.rotation + " , " + GameObject.Find("L_Hand").transform.rotation + " ," + GameObject.Find("L_Index_2").transform.rotation* Quaternion.Inverse(GameObject.Find("L_Hand").transform.rotation)); //print(LH.DataValidStatus(VRTRIXBones.L_Index_1) + ", " + LH.DataValidStatus(VRTRIXBones.L_Middle_1) + ", " + LH.DataValidStatus(VRTRIXBones.L_Ring_1) + ", " + LH.DataValidStatus(VRTRIXBones.L_Pinky_1) + ", " + LH.DataValidStatus(VRTRIXBones.L_Thumb_1)); } }