#include <openvr.h>
+#include <msp/vr/stereoview.h>
#include "openvrdevice.h"
using namespace std;
+namespace {
+
+Msp::GL::Matrix convert_matrix(const vr::HmdMatrix34_t &m)
+{
+ Msp::GL::Matrix result;
+ for(unsigned i=0; i<3; ++i)
+ for(unsigned j=0; j<4; ++j)
+ result(i, j) = m.m[i][j];
+ return result;
+}
+
+}
+
+
namespace Msp {
namespace VR {
vr::VR_Shutdown();
}
+void OpenVRDevice::configure_view(StereoView &view) const
+{
+ vr::IVRSystem *vr_sys = vr::VRSystem();
+ vr::HmdMatrix34_t left = vr_sys->GetEyeToHeadTransform(vr::Eye_Left);
+ vr::HmdMatrix34_t right = vr_sys->GetEyeToHeadTransform(vr::Eye_Right);
+ view.set_eye_matrices(convert_matrix(left), convert_matrix(right));
+}
+
OpenVRCamera *OpenVRDevice::create_camera(const GL::Camera &bc)
{
return new OpenVRCamera(*this, bc);
vr::TrackedDevicePose_t &hmd_pose = poses[vr::k_unTrackedDeviceIndex_Hmd];
if(hmd_pose.bPoseIsValid)
- {
- for(unsigned i=0; i<3; ++i)
- for(unsigned j=0; j<4; ++j)
- hmd_matrix(i, j) = hmd_pose.mDeviceToAbsoluteTracking.m[i][j];
- }
+ hmd_matrix = convert_matrix(hmd_pose.mDeviceToAbsoluteTracking);
}
} // namespace VR
~OpenVRDevice();
virtual void configure_window(Graphics::Window &) const { }
- virtual void configure_view(StereoView &) const { }
+ virtual void configure_view(StereoView &) const;
virtual OpenVRCamera *create_camera(const GL::Camera &);
virtual OpenVRCombiner *create_combiner(GL::View &);