# 19.3. Left and Right Eye Projections

The stereo model in Open Inventor takes advantage of the characteristics of the asymmetric frustum in order to obtain a high quality geometric stereo effect. Two parameters are adjusted to create the stereo effect: the view frustum orientation and the camera translation.

### Depth of the Stereo Effect

The depth of stereo – how deep the scene appears to be when the stereo is activated – is adjusted via the offset, that is, the separation between the left and the right cameras representing the separation between the viewer’s eyes. The wider the offset, the deeper the scene appears to be. This is a simple adjustment done by translating the camera along the horizontal axis (meaning the axis along which are the eyes of the actual person looking at the screen). The offset is calculated as a percentage of the view volume itself.

### Parallax

Not only do the cameras need to be separated to the “left” and to the “right,” but we also need to represent the fact that the eyes are looking at the same object at the same time. There are two ways to do this:

• Rotate the cameras and point at the center of the object.

• Or “skew” each camera’s view frustum so that the view volume contains the object.

The first approach has the problem of losing geometric coherence: once the cameras are rotated, their axes of projection become different. Two things then occur: the z-order is slightly different from one view to the other and the orientation of a shape in one view will no longer be consistent with the orientation in the other view. This approach also requires the stereo “point of focus” to be constantly adjusted if the viewer is moving through the scene.

The second approach solves this. It also allows an interesting effect to be applied without distortion: by increasing or decreasing the frustum asymmetry, the scene will appear to be moved with respect to the screen plane. This is the parallax balance. By default, the zero parallax plane is set at the middle of the view volume. Therefore, by default, a scene will appear with its center positioned at the screen level, some parts will appear in front of the screen, other parts will appear behind the screen. Increasing the frustum asymmetry will produce a positive parallax, with the scene being pushed behind the screen, whereas decreasing the asymmetry will produce a negative parallax, the scene being pulled in front of the screen.

### Adjusting the Parameters

Both the frustum asymmetry and the camera offset are computed according to the default view volume. This means that there is no external intervention to set the stereo. However, it is possible to adjust the two parameters if one wants to change the parallax plane or to deepen or flatten the scene. Adjustment values are given as a factor of the default parameter. Therefore, the neutral value for both parameters is 1 and the null value is 0. For the offset, the domain of values is zero and higher, though above 3 the view might begin to be uncomfortable. For the parallax, any value can be provided, though below -2 and above 4 the view might begin to be uncomfortable too.

### Programming Interface: Setting and Adjusting the Stereo

This section does not refer to the activation of the stereo in general, but specifically to setting the camera in stereo mode, meaning adapting the projection matrix to fit the view volume requirements for stereo. For stereo activation, see Section 19.4, “ Displaying in Stereo”. Note that in most cases it is more convenient to use the viewer methods.

The node SoCamera SoCamera SoCamera provides some methods that allow the projection matrix to be set in stereo mode, as well as to adjust the stereo settings:

```enum StereoMode
{
MONOSCOPIC, LEFT_VIEW, RIGHT_VIEW
};
void setStereoMode(StereoMode mode);
StereoMode getStereoMode() const;
```
```enum class StereoModes {
MONOSCOPIC,
LEFT_VIEW,
RIGHT_VIEW
};
public void SetStereoMode(SoCamera.StereoModes mode);
public SoCamera.StereoModes GetStereoMode();
```

When rendering in stereo, first set the stereo mode to left (or right) view, render the scene, set the stereo mode to right (or left) view, render the scene again, then put the camera back into monoscopic mode:

```camera->setStereoMode(SoCamera::LEFT_VIEW);
scene->render();
camera->setStereoMode(SoCamera::RIGHT_VIEW);
scene->render();
camera->setStereoMode(SoCamera::MONOSCOPIC);
```
```camera.SetStereoMode(SoCamera.StereoModes.LEFT_VIEW);
scene.Render();
camera.SetStereoMode(SoCamera.StereoModes.RIGHT_VIEW);
scene.Render();
camera.SetStereoMode(SoCamera.StereoModes.MONOSCOPIC);
```

The adjustment of the parameters must be applied before the first render operation. The available methods are:

```//Factor on the stereo offset
//Factor on the parallax balance
```
```//Factor on the stereo offset
//Factor on the parallax balance
```

Remember that all this applies to the projection matrix. This really means that, at that point, only the camera is set in stereo mode. Note also that convenience methods for stereo adjustment are available for all viewers. On a viewer object, you can call these methods:

```void setStereoOffset(float offsetAdjustment);
float getStereoOffset();
```public virtual void SetStereoOffset(float dist);