I am trying to access the tracking state (gyroscope, accelerometer, magnetometer) of the Oculus Rift DK2 in C++. The OculusWorldDemo does this by creating an instance of ovrHmd and calling ovrHmd_GetTrackingState. This does not seem to be possible in a UE4 project, because there is no ovrHmd. The only thing I can find is GEngine->HmdDevice which is an interface for any HMD - even those without sensors. So it cannot provide me with a tracking state.
Creating my own instance of ovrHmd cannot be the solution, because UE4 should take care of that.
You can access the class it extends IHeadMountedDisplay using GEngine. If you get this, you can get Orientation. If you want more, you can always add functions to the OculusRift (IHeadMountedDisplay) plugin to do this. It should look like something below.
so, there is no way I can read the sensor values without modifying the engine’s source code? FOculusRiftHMD is in the private part of the plugin, so it’s not visible when I don’t compile the engine myself.
This is not a big problem now, but it might become one in the future
My way of solving the problem now would be the following:
Add the following three lines to IHeadMountedDisplay:
The HMDs implementing IHeadMountedDisplay can then decide to override this function. If not, the default value (0,0,0) is returned.
I would then override the functions in OculusRiftHMD.h and return the sensor readings.
I hope this is what you meant
Is this a clean enough way to do or am I overseeing something?