Class StereoOptionSceneController

  • All Implemented Interfaces:
    AVList, Disposable, MessageListener, SceneController, StereoSceneController, WWObject, java.beans.PropertyChangeListener, java.util.EventListener

    public class StereoOptionSceneController
    extends BasicSceneController
    implements StereoSceneController
    TODO: This file needs to be updated to implement "correct" stereo, as described at: http://www.orthostereo.com/geometryopengl.html

    This scene controller draws in stereo, either red-blue anaglyph or device supported if the display device provides stereo directly. It can also draw without applying stereo. To select stereo, prior to calling this class' constructor set the Java VM property gov.nasa.worldwind.stereo.mode to "device" for device supported stereo (if provided by the device) or "redblue" for red-blue anaglyph stereo. If the property is not set or is any other value, this class does not draw in stereo.

    The WorldWindow instance must support stereo in order to use device-supported stereo. A stereo WorldWindow is selected by specifying the Java VM property described above prior to creating it. See WorldWindowGLCanvas for further details.

    Note: The logic and much of the code here was contributed by Xander Enzmann of Mitre Corporation.

    • Field Detail

      • DEFAULT_FOCUS_ANGLE

        protected static final double DEFAULT_FOCUS_ANGLE
        The default focus angle. May be specified in the WorldWind configuration file as the gov.nasa.worldwind.StereoFocusAngle property. The default if not specified in the configuration is 1.6 degrees.
      • stereoMode

        protected java.lang.String stereoMode
        The current stereo mode. May not be set to null; use AVKey.STEREO_MODE_NONE instead.
      • focusAngle

        protected Angle focusAngle
        The angle between eyes. Larger angles give increased 3D effect.
      • swapEyes

        protected boolean swapEyes
        Indicates whether left and right eye positions are swapped.
      • capabilities

        protected com.jogamp.opengl.GLCapabilitiesImmutable capabilities
        Indicates the GL drawable capabilities. Non-null only after this scene controller draws once.
      • hardwareStereo

        protected boolean hardwareStereo
        Indicates whether hardware device stereo is available. Valid only after this scene controller draws once.
      • inStereo

        protected boolean inStereo
        Indicates whether stereo is being applied, either because a stereo device is being used or a stereo mode is in effect. This field is included because the question is asked every frame, and tracking the answer via a boolean avoids the overhead of more complicated logic that determines the stereo-drawing implementation to call.
    • Constructor Detail

      • StereoOptionSceneController

        public StereoOptionSceneController()
        Constructs an instance and initializes its stereo mode to
    • Method Detail

      • setStereoMode

        public void setStereoMode​(java.lang.String mode)
        Description copied from interface: StereoSceneController
        Specifies the technique used to provide a stereo effect. Defined options are AVKey.STEREO_MODE_DEVICE to request device supported stereo, AVKey.STEREO_MODE_RED_BLUE to request red-blue anaglyph stereo implemented in software, or AVKey.STEREO_MODE_NONE (the default) to request no stereo effect.

        If STEREO_MODE_DEVICE is requested but the display device does not support stereo, stereo is not applied.

        See the implementing class to determine how it detects the initial stereo mode.

        Specified by:
        setStereoMode in interface StereoSceneController
        Parameters:
        mode - the technique used to provide the stereo effect. If null, the mode is set to AVKey.STEREO_MODE_NONE.
      • setFocusAngle

        public void setFocusAngle​(Angle a)
        Specifies the angle difference between the left and right eye direction. Larger angles increase the stereo effect. The default focus angle is 1.6 degrees.
        Specified by:
        setFocusAngle in interface StereoSceneController
        Parameters:
        a - the left-right eye direction difference. If null, the angle is set to 0.
      • getFocusAngle

        public Angle getFocusAngle()
        Description copied from interface: StereoSceneController
        Returns this controller's focus angle, the angle difference between the left and right eye direction.
        Specified by:
        getFocusAngle in interface StereoSceneController
        Returns:
        this controller's focus angle.
      • setSwapEyes

        public void setSwapEyes​(boolean swapEyes)
        Description copied from interface: StereoSceneController
        Specifies whether to draw the right eye image in the left eye's position and the left eye's image in the right eye's position.
        Specified by:
        setSwapEyes in interface StereoSceneController
        Parameters:
        swapEyes - true to switch the left/right stereo images, otherwise false.
      • isSwapEyes

        public boolean isSwapEyes()
        Description copied from interface: StereoSceneController
        Indicates whether to switch the left/right stereo images.
        Specified by:
        isSwapEyes in interface StereoSceneController
        Returns:
        true to switch the images, otherwise false
      • isHardwareStereo

        public boolean isHardwareStereo()
        Description copied from interface: StereoSceneController
        Indicates whether stereo is being implemented directly by the display device rather than software.
        Specified by:
        isHardwareStereo in interface StereoSceneController
        Returns:
        true if if stereo is being implemented by the display device, otherwise false.
      • isInStereo

        public boolean isInStereo()
        Indicates whether stereo is being applied, either directly by the display device or simulated via software.

        If the display device is providing stereo -- isHardwareStereo() is true -- this method returns true even if the stereo mode is AVKey.STEREO_MODE_NONE. In this case, individual stereo images are drawn for left and right eyes in order to prevent a blurred scene.

        Specified by:
        isInStereo in interface StereoSceneController
        Returns:
        true if stereo is being applied.
      • doDrawStereoNone

        protected void doDrawStereoNone​(DrawContext dc)
        Implement no stereo ("Mono") while using a stereo device.

        Note that this method draws the image twice, once to each of the left and right eye buffers, even when stereo is not in effect. This is to prevent the stereo device from drawing blurred scenes.

        Parameters:
        dc - the current draw context.
      • doDrawStereoRedBlue

        protected void doDrawStereoRedBlue​(DrawContext dc)
        Implement stereo using the red-blue anaglyph technique.
        Parameters:
        dc - the current draw context.
      • doDrawToStereoDevice

        protected void doDrawToStereoDevice​(DrawContext dc)
        Implement stereo using the stereo-enabled graphics device. The mode has an effect only if the display device implements stereo.
        Parameters:
        dc - the current draw context.