Forum Discussion
hesham
13 years agoProtege
OpenGL Stereo Camera Setup and Convergence
Edit: I think that my baseline needs to change to get rid of the 0.5 up front, but everything else still broken: float const baselength = near_ * std::tan(M_PI * (fov_/2.0 / 180.0)); I've been stuc...
Lakritze
13 years agoHonored Guest
Thank you so much hesham for bringing this problem up here and actually solving it!
The Oculus Documentation teaches you about shifting the projection center to coincide with the center of the lens, but if you try to do this in the old openGL-style its not that obvious to see what to do.
Whatever here is my codesnippet, showing where to put the translation for the projection center and where to put the IOD-translation:
I hope this helps someone, sometime. For information on how to calculate the values for ProjectionCenterOffset, FOV etc. take a look at the Oculus SDK Documentation.
The Oculus Documentation teaches you about shifting the projection center to coincide with the center of the lens, but if you try to do this in the old openGL-style its not that obvious to see what to do.
Whatever here is my codesnippet, showing where to put the translation for the projection center and where to put the IOD-translation:
void ApplyLeftFrustum()
{
// Set the Projection Matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glTranslatef(ProjectionCenterOffset, 0.0f, 0.0f);
gluPerspective(FOV, AspectRatio, NearClippingDistance, FarClippingDistance);
// Displace the world to right by half of the IOD
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(IOD/2, 0.0f, 0.0f);
}
void ApplyRightFrustum()
{
// Set the Projection Matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glTranslatef(-ProjectionCenterOffset, 0.0f, 0.0f);
gluPerspective(FOV, AspectRatio, NearClippingDistance, FarClippingDistance);
// Displace the world to left by half of the IOD
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-IOD/2, 0.0f, 0.0f);
}
I hope this helps someone, sometime. For information on how to calculate the values for ProjectionCenterOffset, FOV etc. take a look at the Oculus SDK Documentation.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 13 years ago