NASA World Wind

gov.nasa.worldwind
Class StereoOptionSceneController

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.AbstractSceneController
              extended by gov.nasa.worldwind.BasicSceneController
                  extended by gov.nasa.worldwind.StereoOptionSceneController
All Implemented Interfaces:
AVList, Disposable, MessageListener, SceneController, StereoSceneController, WWObject, PropertyChangeListener, 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 Summary
protected  GLCapabilitiesImmutable capabilities
          Indicates the GL drawable capabilities.
protected static double DEFAULT_FOCUS_ANGLE
          The default focus angle.
protected  Angle focusAngle
          The angle between eyes.
protected  boolean hardwareStereo
          Indicates whether hardware device stereo is available.
protected  boolean inStereo
          Indicates whether stereo is being applied, either because a stereo device is being used or a stereo mode is in effect.
protected  String stereoMode
          The current stereo mode.
protected  boolean swapEyes
          Indicates whether left and right eye positions are swapped.
 
Fields inherited from class gov.nasa.worldwind.AbstractSceneController
clutterFilter, dc, deepPick, frame, framesPerSecond, frameTime, glRuntimeCaps, gpuResourceCache, lastObjectsInPickRect, lastPickedObjects, model, perFrameStatistics, perFrameStatisticsKeys, pickableObjects, pickPoint, pickPoints, pickRect, pickTime, renderingExceptions, screenCreditController, SURFACE_OBJECT_TILE_COUNT_NAME, surfaceObjectTileBuilder, surfaceObjectTiles, textRendererCache, timebase, verticalExaggeration, view
 
Constructor Summary
StereoOptionSceneController()
          Constructs an instance and initializes its stereo mode to
 
Method Summary
protected  void doDrawStereoNone(DrawContext dc)
          Implement no stereo ("Mono") while using a stereo device.
protected  void doDrawStereoRedBlue(DrawContext dc)
          Implement stereo using the red-blue anaglyph technique.
protected  void doDrawToStereoDevice(DrawContext dc)
          Implement stereo using the stereo-enabled graphics device.
protected  void draw(DrawContext dc)
           
 Angle getFocusAngle()
          Returns this controller's focus angle, the angle difference between the left and right eye direction.
 String getStereoMode()
          Indicates the current stereo mode of this controller.
 boolean isHardwareStereo()
          Indicates whether stereo is being implemented directly by the display device rather than software.
 boolean isInStereo()
          Indicates whether stereo is being applied, either directly by the display device or simulated via software.
 boolean isSwapEyes()
          Indicates whether to switch the left/right stereo images.
 void setFocusAngle(Angle a)
          Specifies the angle difference between the left and right eye direction.
 void setStereoMode(String mode)
          Specifies the technique used to provide a stereo effect.
 void setSwapEyes(boolean swapEyes)
          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.
 
Methods inherited from class gov.nasa.worldwind.BasicSceneController
doRepaint
 
Methods inherited from class gov.nasa.worldwind.AbstractSceneController
applyView, buildCompositeSurfaceObjects, checkGLErrors, clearFrame, createPickFrustum, createSurfaceObjectTileBuilder, createTerrain, dispose, doDeepPick, doNonTerrainPick, doResolveTopPick, doResolveTopPick, drawCompositeSurfaceObjects, drawOrderedSurfaceRenderables, finalizeFrame, getClutterFilter, getDrawContext, getFramesPerSecond, getFrameTime, getGLRuntimeCapabilities, getGpuResourceCache, getModel, getObjectsInPickRectangle, getPerFrameStatistics, getPickedObjectList, getPickPoint, getPickRectangle, getRenderingExceptions, getScreenCreditController, getTerrain, getTextRendererCache, getVerticalExaggeration, getView, getViewportCenter, initializeDrawContext, initializeFrame, isDeepPickEnabled, mergePickedObjectLists, pick, pickLayers, pickOrderedSurfaceRenderables, pickTerrain, preRender, preRenderOrderedSurfaceRenderables, reinitialize, repaint, resolveTopPick, setClutterFilter, setDeepPickEnabled, setGLRuntimeCapabilities, setGpuResourceCache, setModel, setPerFrameStatisticsKeys, setPickedObjectList, setPickPoint, setPickRectangle, setScreenCreditController, setVerticalExaggeration, setView
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.SceneController
getClutterFilter, getDrawContext, getFramesPerSecond, getFrameTime, getGLRuntimeCapabilities, getGpuResourceCache, getModel, getObjectsInPickRectangle, getPerFrameStatistics, getPickedObjectList, getPickPoint, getPickRectangle, getRenderingExceptions, getScreenCreditController, getTerrain, getVerticalExaggeration, getView, isDeepPickEnabled, reinitialize, repaint, setClutterFilter, setDeepPickEnabled, setGLRuntimeCapabilities, setGpuResourceCache, setModel, setPerFrameStatisticsKeys, setPickPoint, setPickRectangle, setScreenCreditController, setVerticalExaggeration, setView
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 
Methods inherited from interface gov.nasa.worldwind.Disposable
dispose
 

Field Detail

capabilities

protected GLCapabilitiesImmutable capabilities
Indicates the GL drawable capabilities. Non-null only after this scene controller draws once.


DEFAULT_FOCUS_ANGLE

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


focusAngle

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


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.


stereoMode

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


swapEyes

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

Constructor Detail

StereoOptionSceneController

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

Method Detail

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.

draw

protected void draw(DrawContext dc)
Overrides:
draw in class AbstractSceneController

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.

getStereoMode

public String getStereoMode()
Description copied from interface: StereoSceneController
Indicates the current stereo mode of this controller.

Specified by:
getStereoMode in interface StereoSceneController
Returns:
the current stereo mode. See this class' description for the possible modes. This method does not return null. If a null mode was passed to StereoSceneController.setStereoMode(String), this instance's mode was set to AVKey.STEREO_MODE_NONE.

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.

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

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.

setStereoMode

public void setStereoMode(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.

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.

NASA World Wind