ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.08k stars 1.28k forks source link

how to get hmd position and rotation data #1043

Open gracekimm opened 5 years ago

gracekimm commented 5 years ago

Hello, I am developing openvr custom driver for my custom controller. I want to get position and rotation data of Vive HMD and use these data in my openvr custom controller driver. I can't find a way to do this. Do I have to develop the monitor application that share position data between different tracking system(SteamVR for HMD, my tracking system for controller) or Is there another solution?

Does anyone have a sample code? Thanks in advance. :)

haljarrett commented 5 years ago

Your driver should be able to access this data through the IVRServerDriverHost interface exposed from openvr_driver.h

Something like VRServerDriverHost()->GetRawTrackedDevicePoses(...); This will provide you with an array of TrackedDevicePose_t structures, which you can iterate through to find the device of interest by class, though iirc the HMD always has id 0.