diff options
author | Anthony Coddington <antcodd@gmail.com> | 2017-04-10 01:08:13 +1200 |
---|---|---|
committer | Anthony Coddington <antcodd@gmail.com> | 2017-04-10 01:08:13 +1200 |
commit | add6823e30e7bdbe61a1eec37be6107b32cc621a (patch) | |
tree | 86913b30b92f2b1ce67eb86fee8b5c1ef80e92fd /tracker-steamvr/steamvr.cpp | |
parent | 0bc78d53028f5ac68b9ab454347b8ad453988c08 (diff) |
tracker/steamvr: Fix rotation issues
Use well known matrix to euler decomposition formula, fixing some incorrect accesses. May need gimbal lock avoidance.
Don't use opentrack centering as ResetSeatedZeroPose preserves calibrated real world up (Y) vector.
Note: controllers are centered to HMD seated position.
fixes most remaining issues in #352
Diffstat (limited to 'tracker-steamvr/steamvr.cpp')
-rw-r--r-- | tracker-steamvr/steamvr.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp index 0fc07afc..5ea62610 100644 --- a/tracker-steamvr/steamvr.cpp +++ b/tracker-steamvr/steamvr.cpp @@ -250,19 +250,24 @@ bool steamvr::center() with_vr_lock([&](vr_t v, error_t) { if (v) + // Reset yaw and position v->ResetSeatedZeroPose(); }); - return false; + // Use chaperone universe real world up instead of OpenTrack's initial pose centering + // Note: Controllers will be centered based on initial headset position. + // TODO: may want to center controller/tracker yaw and position (only) when used alone + return true; } void steamvr::matrix_to_euler(double& yaw, double& pitch, double& roll, const vr::HmdMatrix34_t& result) { using std::atan2; - using std::asin; - yaw = atan2(double(result.m[2][0]), double(result.m[0][0])); - pitch = atan2(double(result.m[1][1]), double(result.m[1][2])); - roll = asin(double(result.m[1][0])); + yaw = atan2((double)-result.m[2][0], sqrt((double)result.m[2][1] * result.m[2][1] + result.m[2][2] * result.m[2][2])); + pitch = atan2((double)result.m[2][1], (double)result.m[2][2]); + roll = atan2((double)result.m[1][0], (double)result.m[0][0]); + + // TODO: gimbal lock avoidance? } steamvr_dialog::steamvr_dialog() |