NASA World Wind

gov.nasa.worldwind.layers
Class SkyGradientLayer

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.layers.AbstractLayer
              extended by gov.nasa.worldwind.layers.SkyGradientLayer
All Implemented Interfaces:
AVList, Disposable, MessageListener, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class SkyGradientLayer
extends AbstractLayer

Renders an atmosphere around the globe and a sky dome at low altitude.

Note : based on a spherical globe.
Issue : Ellipsoidal globe doesnt match the spherical atmosphere everywhere.


Field Summary
protected  float[] horizonColor
           
protected static int SLICES
           
protected static int STACKS
           
protected  double thickness
           
protected  float[] zenithColor
           
 
Constructor Summary
SkyGradientLayer()
          Renders an atmosphere around the globe
 
Method Summary
protected  void applyDrawProjection(DrawContext dc, OGLStackHandler ogsh)
           
protected  void applyDrawTransform(DrawContext dc, OGLStackHandler ogsh)
           
protected static Vec4 CartesianToSpherical(double x, double y, double z)
          Converts position in cartesian coordinates (XYZ) to spherical (radius, lat, lon) coordinates.
 void doRender(DrawContext dc)
           
protected  void drawSkyDome(DrawContext dc, float radius, double startLat, double endLat, int slices, int stacks, float zenithOpacity, float gradientBias)
          Draws the sky dome
 double getAtmosphereThickness()
          Get the atmosphere thickness in meter
 Color getHorizonColor()
          Get the horizon color
 Color getZenithColor()
          Get the zenith color
 void setAtmosphereThickness(double thickness)
          Set the atmosphere thickness in meter
 void setHorizonColor(Color color)
          Set the horizon color
 void setZenithColor(Color color)
          Set the zenith color
protected static Vec4 SphericalToCartesian(double latitude, double longitude, double radius)
          Converts position in spherical coordinates (lat/lon/altitude) to cartesian (XYZ) coordinates.
 String toString()
           
protected  void updateSkyDome(DrawContext dc)
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
createLayerConfigElements, dispose, doPick, doPreRender, getDataFileStore, getExpiryTime, getLayerConfigParams, getMaxActiveAltitude, getMaxEffectiveAltitude, getMinActiveAltitude, getMinEffectiveAltitude, getName, getOpacity, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, isLayerConfigDocument, isLayerInView, isMultiResolution, isNetworkRetrievalEnabled, isPickEnabled, pick, preRender, render, restoreState, setDataFileStore, setEnabled, setExpiryTime, setMaxActiveAltitude, setMinActiveAltitude, setName, setNetworkRetrievalEnabled, setOpacity, setPickEnabled, setScreenCredit
 
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, 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 java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

horizonColor

protected float[] horizonColor

SLICES

protected static final int SLICES
See Also:
Constant Field Values

STACKS

protected static final int STACKS
See Also:
Constant Field Values

thickness

protected double thickness

zenithColor

protected float[] zenithColor
Constructor Detail

SkyGradientLayer

public SkyGradientLayer()
Renders an atmosphere around the globe

Method Detail

applyDrawProjection

protected void applyDrawProjection(DrawContext dc,
                                   OGLStackHandler ogsh)

applyDrawTransform

protected void applyDrawTransform(DrawContext dc,
                                  OGLStackHandler ogsh)

CartesianToSpherical

protected static Vec4 CartesianToSpherical(double x,
                                           double y,
                                           double z)
Converts position in cartesian coordinates (XYZ) to spherical (radius, lat, lon) coordinates.

Parameters:
x - X coordinate
y - Y coordinate
z - Z coordinate
Returns:
a Vec4 point for the spherical coordinates {radius, lat, lon}

doRender

public void doRender(DrawContext dc)
Specified by:
doRender in class AbstractLayer

drawSkyDome

protected void drawSkyDome(DrawContext dc,
                           float radius,
                           double startLat,
                           double endLat,
                           int slices,
                           int stacks,
                           float zenithOpacity,
                           float gradientBias)
Draws the sky dome

Parameters:
dc - the current DrawContext
radius - the sky dome radius
startLat - the horizon latitude
endLat - the zenith latitude
slices - the number of slices - vertical divisions
stacks - the nuber os stacks - horizontal divisions
zenithOpacity - the sky opacity at zenith
gradientBias - determines how fast the sky goes from the horizon color to the zenith color. A value of 1 with produce a balanced gradient, a value greater then 1 will have the zenith color dominate and a value less then 1 will have the opposite effect.

getAtmosphereThickness

public double getAtmosphereThickness()
Get the atmosphere thickness in meter

Returns:
the atmosphere thickness in meter

getHorizonColor

public Color getHorizonColor()
Get the horizon color

Returns:
the horizon color

getZenithColor

public Color getZenithColor()
Get the zenith color

Returns:
the zenith color

setAtmosphereThickness

public void setAtmosphereThickness(double thickness)
Set the atmosphere thickness in meter

Parameters:
thickness - the atmosphere thickness in meter

setHorizonColor

public void setHorizonColor(Color color)
Set the horizon color

Parameters:
color - the horizon color

setZenithColor

public void setZenithColor(Color color)
Set the zenith color

Parameters:
color - the zenith color

SphericalToCartesian

protected static Vec4 SphericalToCartesian(double latitude,
                                           double longitude,
                                           double radius)
Converts position in spherical coordinates (lat/lon/altitude) to cartesian (XYZ) coordinates.

Parameters:
latitude - Latitude in decimal degrees
longitude - Longitude in decimal degrees
radius - Radius
Returns:
the corresponding Point

toString

public String toString()
Overrides:
toString in class AbstractLayer

updateSkyDome

protected void updateSkyDome(DrawContext dc)

NASA World Wind