Need help with SDK with opengl c++
Hello. I'm trying to make my own game engine, and trying to implement the oculus. I have rotations and translations being inputted which is awesome, but I'm still having a bit of trouble with a few things, which I will list below: ANY help is greatly appreciated.
1.
I want to create the distorted eye mesh that the image is mapped onto - how do I do this? Like I actually want to write the loop that creates it. I looked through the source code, but couldn't find where the vertices are defined. I saw something which seems to specify the uv coordinates for each rgb value - is this right? each vert will have 3 uv coordinates for each color value? Also, what is the function to generate the vert positions? I assume uv coords will just be 1.0 - (currentVert / vertsAcross), and then shifted for each value. I want to generate this myself because I saw in the source code it looks like it generates the mesh every frame. I could be wrong, but that's what it looked like, and I'm just gonna generate the mesh at the start, and reuse it.
2.
I'm having some trouble with rotations. Like on the x axis, the headset works fine until it hits a certain angle, and then it reverses back? Also y and z seem a bit off, probably because my converter is wrong.
I'm using this to get the angles - might be what's wrong, but it does give some workable results:
void VRDATA::QuaternionToDegrees(const ovrQuatf& q, VECTOR3f& rotData)
{
float radToDegree = 57.2957795;
rotData.y = atan2((float)(2.0f * q.x * q.w + 2.0f * q.y * q.z), (float)(1.0f - 2.0f * (q.z * q.z + q.w * q.w))) * radToDegree;
rotData.x = asin(2.0f * (q.x * q.z - q.w * q.y)) * radToDegree;
rotData.z = atan2((float)(2.0f * q.x * q.y + 2.0f * q.z * q.w), (float)(1.0f - 2.0f * (q.y * q.y + q.z * q.z))) * radToDegree;
}
And I use it like so:
VECTOR3f rotation;
ovrTrackingState trackingState = ovrHmd_GetTrackingState(hmd, ovr_GetTimeInSeconds());
QuaternionToDegrees(trackingState.HeadPose.ThePose.Orientation, rotation);
3.
This is more of a none-rift problem, but I figure I'll ask anyway.
i have rotate and translate functions (not old opengl, i redid them for modern version), wondering what order I should be doing them? I do all the rotations first, and the translations last. is this right?
4.
How Do I get a float value of the Fov? Having trouble with this one for some reason.
Overall, I'm really just wanting to use the sdk as a means of grabbing the positions/rotations, and then having the rest be my own code, for reasons.
Thanks!!!
(Sorry, 'code' button not working?)
1.
I want to create the distorted eye mesh that the image is mapped onto - how do I do this? Like I actually want to write the loop that creates it. I looked through the source code, but couldn't find where the vertices are defined. I saw something which seems to specify the uv coordinates for each rgb value - is this right? each vert will have 3 uv coordinates for each color value? Also, what is the function to generate the vert positions? I assume uv coords will just be 1.0 - (currentVert / vertsAcross), and then shifted for each value. I want to generate this myself because I saw in the source code it looks like it generates the mesh every frame. I could be wrong, but that's what it looked like, and I'm just gonna generate the mesh at the start, and reuse it.
2.
I'm having some trouble with rotations. Like on the x axis, the headset works fine until it hits a certain angle, and then it reverses back? Also y and z seem a bit off, probably because my converter is wrong.
I'm using this to get the angles - might be what's wrong, but it does give some workable results:
void VRDATA::QuaternionToDegrees(const ovrQuatf& q, VECTOR3f& rotData)
{
float radToDegree = 57.2957795;
rotData.y = atan2((float)(2.0f * q.x * q.w + 2.0f * q.y * q.z), (float)(1.0f - 2.0f * (q.z * q.z + q.w * q.w))) * radToDegree;
rotData.x = asin(2.0f * (q.x * q.z - q.w * q.y)) * radToDegree;
rotData.z = atan2((float)(2.0f * q.x * q.y + 2.0f * q.z * q.w), (float)(1.0f - 2.0f * (q.y * q.y + q.z * q.z))) * radToDegree;
}
And I use it like so:
VECTOR3f rotation;
ovrTrackingState trackingState = ovrHmd_GetTrackingState(hmd, ovr_GetTimeInSeconds());
QuaternionToDegrees(trackingState.HeadPose.ThePose.Orientation, rotation);
3.
This is more of a none-rift problem, but I figure I'll ask anyway.
i have rotate and translate functions (not old opengl, i redid them for modern version), wondering what order I should be doing them? I do all the rotations first, and the translations last. is this right?
4.
How Do I get a float value of the Fov? Having trouble with this one for some reason.
Overall, I'm really just wanting to use the sdk as a means of grabbing the positions/rotations, and then having the rest be my own code, for reasons.
Thanks!!!
(Sorry, 'code' button not working?)
