What is the best way to determine whether a SteamVR_TrackedObject
is a Vive Controller and a Vive Tracker?
When 0 Controllers and 1 Tacker is paired:
The Tracker is taken as Controller (right)
of the CameraRig
.
When 1 Controller and 1 Tacker is paired:
The Tracker is set to Device 2.
When 2 Controllers and 1 Tacker is paired:
Creating a third SteamVR_TrackedObject
and placing it in the CameraRig
's objects
array. Also when a controller looses tracking so does the tracker.
In each scenario the Tracker ends up being a different SteamVR_TrackedObject.index
. What is the best way to check if a SteamVR_TrackedObject
is a Tracker, or to find which index
the Tracker is?
The only method of checking a SteamVR_TrackedObject
that I have found yet is to check the ETrackedDevicePoperty.Prop_RenderModelName_String
:
uint index = 0;
var error = ETrackedPropertyError.TrackedProp_Success;
for (uint i = 0; i < 16; i++)
{
var result = new System.Text.StringBuilder((int)64);
OpenVR.System.GetStringTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_RenderModelName_String, result, 64, ref error);
if (result.ToString().Contains("tracker"))
{
index = i;
break;
}
}
Then you can set SteamVR_TrackedObject.index
to index:
GetComponent<SteamVR_TrackedObject>().index = (SteamVR_TrackedObject.EIndex)index;
Finding any documentation on this has been pretty difficult so far but here's some sources:
Just stumbled upon this old question and I guess accepted answer was strictly correct when it was asked - there's a direct way to do it now, though: you can use GetTrackedDeviceClass.
It will return value of an enum ETrackedDeviceClass
. Possible values are:
Invalid
- if there's no tracked device under this index,HMD
- if the device is a headset,Controller
- if the device is, well, controller - this is one of your cases,GenericTracker
- this is another one of your casesTrackingReference
- for base stations, supporting cameras etc,DisplayRedirect
- by documentation - "Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices"
Max
- this one is undocumented and I haven't stumbled upon it yetIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With