PDA

View Full Version : glFrustum Frustrations



Rob
04-23-2000, 07:46 AM
Or should I say “glFrustum-rations?”

Here is my problem (this is going to take a bit to describe, so bear with me):

I have a pair of CrystalEyes shutter glasses and a Logitech ultrasonic head tracking system. I am trying to use this equipment to display a 3D, world-stabilized scene; that is, as the user’s head position changes, the displayed objects appear to be stationary with respect to the real world. This turns out to be kind of an interesting problem because the user’s physical position is in effect supplying some of the viewing transformation for you scene (just thinking out loud there, ignore it if it sounds odd). To picture the desired effect, think of the monitor as a window into a virtual world located behind the glass.

To get the effect that I’m after I eventually decided that I need to use glFrustum to define an asymmetric viewing volume with respect to the viewer. I thought I pretty much had it by doing something like this:
---
// Left eye
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum(-(NOSE_POSITION[0]-EYE_SEPARATION) - MONITOR_WIDTH/2.0, -(NOSE_POSITION[0]-EYE_SEPARATION) + MONITOR_WIDTH/2.0, // left, right
-NOSE_POSITION[1] - MONITOR_HEIGHT/2.0, -NOSE_POSITION[1] + MONITOR_HEIGHT/2.0, // bottom, top
NOSE_POSITION[2], NOSE_POSITION[2] + BOX_DEPTH*2); // front, back (*2 just for good measure)
glTranslatef(-(NOSE_POSITION[0]-EYE_SEPARATION), -NOSE_POSITION[1], -NOSE_POSITION[2]);

glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
---
But as I move the head position around the scene I get some odd distortion in the objects (my spheres become ellipsoids).

I’m going to give up on trying to describe this verbally and instead post some very simple test code and executable. You can download them from:
www.members.home.net/rlblanding/openGLquestion.htm (http://www.members.home.net/rlblanding/openGLquestion.htm)

The program displays a wireframe box that is the same dimensions as the screen and two spheres in the center, directly aligned with each other along the z-axis. Use the number pad to change the head position: 4:–x, 6:+x, 8:+y, 2:-y, 9:-z, 1:+z. For clarity, the right eye image is drawn in red, and the left eye in blue (of course for the actual app, I’d be using left and right stereo buffers).

In the real world a spherical object never appears elliptical, so the distortion seen as you move around is definitely wrong.

Thanks for your time. Any insight into my problem is greatly appreciated.

-Rob


[This message has been edited by Rob (edited 04-23-2000).]

[This message has been edited by Rob (edited 04-23-2000).]

Rob
04-23-2000, 09:30 AM
I'm rather shocked, but the above problem is not actually a problem.

I came into work and ran the above sample using the shutter glasses and the distortion turns out to be correct. When you move to the correct position with the glasses on, the ellipsoids "squash" back into spheres. I suppose what's going on here is that the 2D projections of the spheres onto the screen are indeed ellipsoids and when my brain gets the right stereoscopic cues it sorts things out properly.

A really spooky effect with the glasses on, I have to say. http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks anyway.

-Rob

[This message has been edited by Rob (edited 04-23-2000).]