next up previous contents
Next: 4.1.3 Rotate vs. Shear Up: 4.1 Stereo Viewing Previous: 4.1.1 Fusion Distance

4.1.2 Computing the Transforms

The transformations needed for stereo viewing are simple rotations and translations. Computationally, the stereo viewing transforms happen last, after the viewing transform has been applied to put the viewer at the origin. Since the matrix order is the reverse of the order of operations, the viewing matricies should be applied to the modelview matrix stack first.

The order of matrix operations should be:

  1. Transform from viewer position to left eye view.
  2. Apply viewing operation to get to viewer position (gluLookAt() or equivalent).
  3. Apply modeling operations.
  4. Change buffers, repeat for right eye.
Assuming that the identity matrix is on the modelview stack:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); /* the default matrix */
glPushMatrix()
glDrawBuffer(GL_BACK_LEFT)
glTranslatef(-IOD/2.f, 0, 0)
glRotatef(-angle, 0.f, 1.f, 0.f)
<viewing transforms>
<modeling transforms>
draw()
glPopMatrix();
glPushMatrix()
glDrawBuffer(GL_BACK_RIGHT)
glTranslatef(IOD/2, 0., 0.)
glRotatef(angle, 0.f, 1.f, 0.f)
<viewing transforms>
<modeling transforms>
draw()
glPopMatrix()

Where angle is the inverse tangent of the ratio between the fusion distance and half of the interocular distance. tex2html_wrap_inline7499 Each viewpoint is rotated towards the centerline halfway between the two viewpoints.

Another approach to implementing stereo transforms is to change the viewing tranform directly. Instead of adding an extra rotation and translation, use a separate call to gluLookAt() for each eye view. Move fusion distance along the viewing direction from the viewer position, and use that point for the center of interest of both eyes. Translate the eye position to the appropriate eye, then render the stereo view for the corresponding buffer.

The difficulty with this technique is finding the left/right eye axis to translate along from the viewer position to find the left and right eye viewpoints. Since your now computing the left/right eye axis in object space, it is no longer constrained to be the X axis. Find the left/right eye axis in object space by taking the cross product of the direction of view and the up vector.



David Blythe
Thu Jul 17 21:24:28 PDT 1997