MCPcopy Create free account
hub / github.com/LibreVR/Revive / ovr_GetTrackerPose

Function ovr_GetTrackerPose

Revive/REV_CAPI.cpp:414–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414OVR_PUBLIC_FUNCTION(ovrTrackerPose) ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex)
415{
416 REV_TRACE(ovr_GetTrackerPose);
417
418 ovrTrackerPose tracker = { 0 };
419
420 if (!session)
421 return tracker;
422
423 if (session->UseHack(HACK_SPOOF_SENSORS))
424 {
425 if (trackerPoseIndex < ovr_GetTrackerCount(session))
426 {
427 const OVR::Posef poses[] = {
428 OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(90.0f)), OVR::Vector3f(-2.0f, 0.0f, 0.2f)),
429 OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(0.0f)), OVR::Vector3f(-0.2f, 0.0f, -2.0f)),
430 OVR::Posef(OVR::Quatf(OVR::Axis_Y, OVR::DegreeToRad(180.0f)), OVR::Vector3f(0.2f, 0.0f, 2.0f))
431 };
432 OVR::Posef trackerPose = poses[trackerPoseIndex];
433
434 vr::TrackedDevicePose_t pose;
435 vr::VRCompositor()->GetLastPoseForTrackedDeviceIndex(vr::k_unTrackedDeviceIndex_Hmd, &pose, nullptr);
436
437 // Create a leveled head pose
438 if (pose.bPoseIsValid)
439 {
440 float yaw;
441 REV::Matrix4f matrix(pose.mDeviceToAbsoluteTracking);
442 OVR::Quatf headOrientation(matrix);
443 headOrientation.GetYawPitchRoll(&yaw, nullptr, nullptr);
444 headOrientation = OVR::Quatf(OVR::Axis_Y, yaw);
445 trackerPose = OVR::Posef(headOrientation, matrix.GetTranslation()) * trackerPose;
446 }
447
448 tracker.Pose = trackerPose;
449 tracker.LeveledPose = trackerPose;
450 tracker.TrackerFlags = ovrTracker_Connected | ovrTracker_PoseTracked;
451 }
452 return tracker;
453 }
454
455 // Get the index for this tracker.
456 vr::TrackedDeviceIndex_t trackers[vr::k_unMaxTrackedDeviceCount] = { vr::k_unTrackedDeviceIndexInvalid };
457 vr::VRSystem()->GetSortedTrackedDeviceIndicesOfClass(vr::TrackedDeviceClass_TrackingReference, trackers, vr::k_unMaxTrackedDeviceCount);
458 vr::TrackedDeviceIndex_t index = trackers[trackerPoseIndex];
459
460 // Get the device poses.
461 vr::TrackedDevicePose_t pose;
462 vr::VRCompositor()->GetLastPoseForTrackedDeviceIndex(index, &pose, nullptr);
463
464 // TODO: Should the tracker pose always be in the standing universe?
465 //vr::VRSystem()->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding, 0.0, poses, vr::k_unMaxTrackedDeviceCount);
466
467 // Set the flags
468 tracker.TrackerFlags = 0;
469 if (index != vr::k_unTrackedDeviceIndexInvalid)
470 {
471 if (vr::VRSystem()->IsTrackedDeviceConnected(index))

Callers

nothing calls this directly

Calls 6

QuatfClass · 0.85
ovr_GetTrackerCountFunction · 0.70
PosefClass · 0.70
Vector3fClass · 0.70
Matrix4fClass · 0.70
UseHackMethod · 0.45

Tested by

no test coverage detected