MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / GetPose

Method GetPose

samples/drivers/drivers/tutorial/src/controller_device.cpp:90–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90vr::DriverPose_t ControllerDevice::GetPose() {
91 vr::DriverPose_t pose = { 0 };
92
93 pose.poseIsValid = true;
94 pose.result = vr::TrackingResult_Running_OK;
95 pose.deviceIsConnected = true;
96
97 pose.qWorldFromDriverRotation.w = 1.f;
98 pose.qDriverFromHeadRotation.w = 1.f;
99
100 pose.qRotation.w = 1.f;
101
102 vr::TrackedDevicePose_t hmd_pose{};
103 vr::VRServerDriverHost()->GetRawTrackedDevicePoses(0.f, &hmd_pose, 1);
104
105 const vr::HmdQuaternion_t hmd_orientation = HmdQuaternion_FromMatrix(hmd_pose.mDeviceToAbsoluteTracking);
106 pose.qRotation = hmd_orientation;
107
108 pose.vecPosition[0] = role_ == vr::TrackedControllerRole_LeftHand
109 ? hmd_pose.mDeviceToAbsoluteTracking.m[0][3] - 0.2f
110 : hmd_pose.mDeviceToAbsoluteTracking.m[0][3] + 0.2f;
111
112 pose.vecPosition[1] = hmd_pose.mDeviceToAbsoluteTracking.m[1][3];
113 pose.vecPosition[2] = hmd_pose.mDeviceToAbsoluteTracking.m[2][3] - 0.5f;
114
115 return pose;
116}

Callers

nothing calls this directly

Calls 1

HmdQuaternion_FromMatrixFunction · 0.70

Tested by

no test coverage detected