設備的衝突 一但打開這追蹤器 將會有某一隻VR手柄沒法啓動, 關閉這追蹤器 兩隻VR手柄都能啓動ios
程序中設備的檢測 由於是佔用手柄的位, 因此能夠用手柄的檢測方式, 能檢測到, 設備號是2 沒檢測到則爲-1.net
// 右手手柄的設備號通常是3 左手手柄的設備號通常是4 int rightNumber = m_vrSystem->GetTrackedDeviceIndexForControllerRole(vr::ETrackedControllerRole::TrackedControllerRole_RightHand); int leftNumber = m_vrSystem->GetTrackedDeviceIndexForControllerRole(vr::ETrackedControllerRole::TrackedControllerRole_LeftHand); std::cout << "右手號數:" << rightNumber << std::endl; std::cout << "左手號數:" << leftNumber << std::endl; if (rightNumber != 2 && leftNumber != 2) { continue; }
vr::VRCompositor()->SetTrackingSpace(vr::TrackingUniverseStanding); vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; ++i) poses[i].bPoseIsValid = false; vr::VRCompositor()->WaitGetPoses(poses, vr::k_unMaxTrackedDeviceCount, NULL, 0); //// 0是頭顯, 其它設置是1到64 //for (int i = 1; i < vr::k_unMaxTrackedDeviceCount; ++i) //{ // if (poses[i].bPoseIsValid) // { // //poses[i]. // // } //} std::cout << "#### " << 2 << ":" << poses[2].mDeviceToAbsoluteTracking.m[3][3] << std::endl;
#include "pch.h" #include <iostream> #include <openvr.h> int main() { vr::EVRApplicationType _type = vr::EVRApplicationType::VRApplication_Scene; vr::HmdError *peError = new vr::HmdError; vr::VR_Init(peError, _type); std::cout.precision(4); vr::IVRSystem* m_vrSystem = vr::VR_Init(peError, vr::VRApplication_Scene); while(true) { // 右手手柄的設備號通常是3 左手手柄的設備號通常是4 int rightNumber = m_vrSystem->GetTrackedDeviceIndexForControllerRole(vr::ETrackedControllerRole::TrackedControllerRole_RightHand); int leftNumber = m_vrSystem->GetTrackedDeviceIndexForControllerRole(vr::ETrackedControllerRole::TrackedControllerRole_LeftHand); std::cout << "右手號數:" << rightNumber << std::endl; std::cout << "左手號數:" << leftNumber << std::endl; if (rightNumber != 2 && leftNumber != 2) { continue; } vr::VRCompositor()->SetTrackingSpace(vr::TrackingUniverseStanding); vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount]; for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; ++i) poses[i].bPoseIsValid = false; vr::VRCompositor()->WaitGetPoses(poses, vr::k_unMaxTrackedDeviceCount, NULL, 0); //// 0是頭顯, 其它設置是1到64 //for (int i = 1; i < vr::k_unMaxTrackedDeviceCount; ++i) //{ // if (poses[i].bPoseIsValid) // { // //poses[i]. // // } //} std::cout << "#### " << 2 << ":" << poses[2].mDeviceToAbsoluteTracking.m[3][3] << std::endl; } }
基於我以前的文章: http://www.javashuo.com/article/p-aiufydfs-gp.htmlcode