Class SoStereoCamera

  • All Implemented Interfaces:
    SafeDisposable

    public class SoStereoCamera
    extends SoPerspectiveCamera
    Stereo camera node. A stereo camera defines a specific perspective camera for stereo support.

    This class defines fields to store the stereo settings related to the camera:

    • Stereo offset: the distance of each eye from the camera position.
    • Stereo balance: the position of the zero parallax plane.

    See the base class SoPerspectiveCamera for more information about the inherited fields.

    File format/default:

    StereoCamera {

      offset 0.7
      balance 1.0
      balanceNearFrac false
      absoluteAdjustments false
    }

    Action behavior:

    Sets: SoStereoElement

    See Also:
    SbViewVolume, SoPerspectiveCamera, SoCameraInteractor
    • Field Detail

      • offset

        public final SoSFFloat offset
        The stereo offset (the distance of each eye from the camera position). The right eye is moved plus offset and the left eye is moved minus offset. Default is 0.7.
      • balance

        public final SoSFFloat balance
        The stereo balance (the position of the zero parallax plane). Default balance is 1.0.
      • balanceNearFrac

        public final SoSFBool balanceNearFrac
        Specifies whether the balance value is defined as a fraction of the camera near distance. Note: Since the projection matrix always depends on the camera's near plane, in some cases it may be necessary to detect changes to the camera near plane and adjust by setting a new stereo balance value. Open Inventor will make these adjustments automatically if the balanceNearFrac field is set to true. In this case the stereo balance value is defined as a fraction of the camera near distance.

        Default nearFrac is false.

      • absoluteAdjustments

        public final SoSFBool absoluteAdjustments
        Specifies if stereo adjustments are absolute. false by default.

        The default non-absolute mode allows the stereo settings to be valid over a range of different view volume settings. If you chose absolute mode, you are responsible for modifying the stereo settings (if necessary) when the view volume changes.

        When absolute mode is true, stereo offset and balance are used as shown in the following pseudo-code for the right eye view:

         StereoCameraOffset = offset.getValue();
         FrustumAsymmetry   = balance.getValue();
         
         glTranslated (-StereoCameraOffset, 0, 0);
         glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry,
                    FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);
        The left eye view is symmetric.

        When absolute mode is false, stereo offset and balance are used as shown in the following pseudo-code for the right eye view:

        Xrange is right minus left (i.e., first two arguments of glFrustum) and multiply that difference by the ratio of the distance to the desired plane of zero parallax to the near clipping plane distance.

         StereoCameraOffset   = Xrange * 0.035 * offset.getValue();
         FrustumAsymmetry     = -StereoCameraOffset * balance.getValue();
         ZeroParallaxDistance = (NearClipDistance + FarClipDistance)/0.5;
         
         FrustumAsymmetry *= NearClipDistance / ZeroParallaxDistance;
         
         glTranslated (-StereoCameraOffset, 0, 0);
         glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry,
                    FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);
        The left eye view is symmetric.
    • Constructor Detail

      • SoStereoCamera

        public SoStereoCamera()
        Creates a stereo camera node with default settings.