Reading Sensor data with GLM and OpenGL ...
Hello,
So I have my application ported to the rift using the SDK and I can read sensor data fine.
It's calculating the sensor data and converting it over to GLM that is giving me problems.
I looked at some examples but I am not clear how I can incorporated the position and orientation from the device with the world coordinates of where the person is at?
Thank you for your time.
Here is my current wacky code:
So I have my application ported to the rift using the SDK and I can read sensor data fine.
It's calculating the sensor data and converting it over to GLM that is giving me problems.
I looked at some examples but I am not clear how I can incorporated the position and orientation from the device with the world coordinates of where the person is at?
Thank you for your time.
Here is my current wacky code:
ovrEyeType l_Eye = (*MainRiftDeviceDesc).EyeRenderOrder[l_EyeIndex];
ovrPosef l_EyePose = ovrHmd_BeginEyeRender((*MainRiftDevice), l_Eye);
glViewport(MainEyeRenderDesc[l_Eye].Desc.RenderViewport.Pos.x,
MainEyeRenderDesc[l_Eye].Desc.RenderViewport.Pos.y,
MainEyeRenderDesc[l_Eye].Desc.RenderViewport.Size.w,
MainEyeRenderDesc[l_Eye].Desc.RenderViewport.Size.h);
/*
How can I convert this to a GLM::mat4???
*/
OVR::Matrix4f l_ProjectionMatrix = ovrMatrix4f_Projection(
l_EyeRenderDesc[l_Eye].Desc.Fov, 0.3f, 10000.0f, true);
/*
End Question.
*/
glm::quat CurrentOrientation = glm::quat((l_EyePose.Orientation.x * -1.0),
(l_EyePose.Orientation.y * -1.0f), (l_EyePose.Orientation.z * -1.0), l_EyePose.Orientation.w);
glm::vec3 CurrentEulerAngles = glm::eulerAngles(CurrentOrientation);
CurrentEulerAngles.x += CurrentCameraViewingSettings.Pitch;
CurrentEulerAngles.y += CurrentCameraViewingSettings.Yaw;
CurrentEulerAngles.z += CurrentCameraViewingSettings.Roll;
DirectionOfWhereCameraIsFacing = glm::normalize(CurrentEulerAngles);
PositionOfEyesOfPerson += CameraPositionDelta;
CenterOfWhatIsBeingLookedAt = PositionOfEyesOfPerson + DirectionOfWhereCameraIsFacing * 1.0f;
/*
This is to account for the user's mouse
*/
CurrentCameraViewingSettings.Yaw *= 0.5f;
CurrentCameraViewingSettings.Pitch *= 0.5f;
CameraPositionDelta = CameraPositionDelta * 0.8f;
View = glm::lookAt(PositionOfEyesOfPerson, CenterOfWhatIsBeingLookedAt, DirectionOfUpForPerson);
Model = glm::mat4(1.0f);
ModelViewProjectionMatrix = Projection * View * Model;
ProjectionViewMatrix = Projection * View;
