Class StereoOptionSceneController
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.AbstractSceneController
-
- gov.nasa.worldwind.BasicSceneController
-
- gov.nasa.worldwind.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.htmlThis 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.modeto "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
WorldWindowinstance must support stereo in order to use device-supported stereo. A stereoWorldWindowis selected by specifying the Java VM property described above prior to creating it. SeeWorldWindowGLCanvasfor further details.Note: The logic and much of the code here was contributed by Xander Enzmann of Mitre Corporation.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.jogamp.opengl.GLCapabilitiesImmutablecapabilitiesIndicates the GL drawable capabilities.protected static doubleDEFAULT_FOCUS_ANGLEThe default focus angle.protected AnglefocusAngleThe angle between eyes.protected booleanhardwareStereoIndicates whether hardware device stereo is available.protected booleaninStereoIndicates whether stereo is being applied, either because a stereo device is being used or a stereo mode is in effect.protected java.lang.StringstereoModeThe current stereo mode.protected booleanswapEyesIndicates whether left and right eye positions are swapped.-
Fields inherited from class gov.nasa.worldwind.AbstractSceneController
clutterFilter, dc, deepPick, deferOrderedRendering, frame, framesPerSecond, frameTime, glRuntimeCaps, gpuResourceCache, lastObjectsInPickRect, lastPickedObjects, model, perFrameStatistics, perFrameStatisticsKeys, pickableObjects, pickPoint, pickPoints, pickRect, pickTime, renderingExceptions, screenCreditController, SURFACE_OBJECT_TILE_COUNT_NAME, surfaceObjectTileBuilder, textRendererCache, timebase, verticalExaggeration, view
-
-
Constructor Summary
Constructors Constructor Description StereoOptionSceneController()Constructs an instance and initializes its stereo mode to
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoDrawStereoNone(DrawContext dc)Implement no stereo ("Mono") while using a stereo device.protected voiddoDrawStereoRedBlue(DrawContext dc)Implement stereo using the red-blue anaglyph technique.protected voiddoDrawToStereoDevice(DrawContext dc)Implement stereo using the stereo-enabled graphics device.protected voiddraw(DrawContext dc)AnglegetFocusAngle()Returns this controller's focus angle, the angle difference between the left and right eye direction.java.lang.StringgetStereoMode()Indicates the current stereo mode of this controller.booleanisHardwareStereo()Indicates whether stereo is being implemented directly by the display device rather than software.booleanisInStereo()Indicates whether stereo is being applied, either directly by the display device or simulated via software.booleanisSwapEyes()Indicates whether to switch the left/right stereo images.voidsetFocusAngle(Angle a)Specifies the angle difference between the left and right eye direction.voidsetStereoMode(java.lang.String mode)Specifies the technique used to provide a stereo effect.voidsetSwapEyes(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
createTerrain2DContinuous, do2DContiguousRepaint, doNormalRepaint, doRepaint, draw2DContiguous, makeCurrent, pick2DContiguous, preRender2DContiguous
-
Methods inherited from class gov.nasa.worldwind.AbstractSceneController
applyView, buildCompositeSurfaceObjects, checkGLErrors, clearFrame, createPickFrustum, 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, isDeferOrderedRendering, mergePickedObjectLists, pick, pickLayers, pickOrderedSurfaceRenderables, pickTerrain, preRender, preRenderOrderedSurfaceRenderables, reinitialize, repaint, resolveTopPick, setClutterFilter, setDeepPickEnabled, setDeferOrderedRendering, 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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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 gov.nasa.worldwind.Disposable
dispose
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
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
-
-
-
-
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 thegov.nasa.worldwind.StereoFocusAngleproperty. 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; useAVKey.STEREO_MODE_NONEinstead.
-
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.
-
-
Method Detail
-
setStereoMode
public void setStereoMode(java.lang.String mode)
Description copied from interface:StereoSceneControllerSpecifies the technique used to provide a stereo effect. Defined options areAVKey.STEREO_MODE_DEVICEto request device supported stereo,AVKey.STEREO_MODE_RED_BLUEto request red-blue anaglyph stereo implemented in software, orAVKey.STEREO_MODE_NONE(the default) to request no stereo effect.If
STEREO_MODE_DEVICEis 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:
setStereoModein interfaceStereoSceneController- Parameters:
mode- the technique used to provide the stereo effect. If null, the mode is set toAVKey.STEREO_MODE_NONE.
-
getStereoMode
public java.lang.String getStereoMode()
Description copied from interface:StereoSceneControllerIndicates the current stereo mode of this controller.- Specified by:
getStereoModein interfaceStereoSceneController- 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 toAVKey.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:
setFocusAnglein interfaceStereoSceneController- Parameters:
a- the left-right eye direction difference. If null, the angle is set to 0.
-
getFocusAngle
public Angle getFocusAngle()
Description copied from interface:StereoSceneControllerReturns this controller's focus angle, the angle difference between the left and right eye direction.- Specified by:
getFocusAnglein interfaceStereoSceneController- Returns:
- this controller's focus angle.
-
setSwapEyes
public void setSwapEyes(boolean swapEyes)
Description copied from interface:StereoSceneControllerSpecifies 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:
setSwapEyesin interfaceStereoSceneController- Parameters:
swapEyes- true to switch the left/right stereo images, otherwise false.
-
isSwapEyes
public boolean isSwapEyes()
Description copied from interface:StereoSceneControllerIndicates whether to switch the left/right stereo images.- Specified by:
isSwapEyesin interfaceStereoSceneController- Returns:
- true to switch the images, otherwise false
-
isHardwareStereo
public boolean isHardwareStereo()
Description copied from interface:StereoSceneControllerIndicates whether stereo is being implemented directly by the display device rather than software.- Specified by:
isHardwareStereoin interfaceStereoSceneController- 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()istrue-- this method returns true even if the stereo mode isAVKey.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:
isInStereoin interfaceStereoSceneController- Returns:
- true if stereo is being applied.
-
draw
protected void draw(DrawContext dc)
- Overrides:
drawin classAbstractSceneController
-
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.
-
-