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, Layer, Restorable, WWObject, java.beans.PropertyChangeListener, java.util.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  int glListId
           
protected  float[] horizonColor
           
protected  double lastRebuildHorizon
           
protected static int SLICES
           
protected static int STACKS
           
protected  double thickness
           
protected  float[] zenithColor
           
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
SkyGradientLayer()
          Renders an atmosphere around the globe
 
Method Summary
protected  void applyDrawProjection(DrawContext dc)
           
protected  void applyDrawTransform(DrawContext dc)
           
protected static Vec4 CartesianToSpherical(double x, double y, double z)
          Converts position in cartesian coordinates (XYZ) to spherical (radius, lat, lon) coordinates.
 void dispose()
           
 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
 java.awt.Color getHorizonColor()
          Get the horizon color
 java.awt.Color getZenithColor()
          Get the zenith color
protected  boolean isValid(DrawContext dc)
           
protected  void makeSkyDome(DrawContext dc, float radius, double startLat, double endLat, int slices, int stacks, float zenithOpacity, float gradientBias)
          Build sky dome and draw into the glList
 void setAtmosphereThickness(double thickness)
          Set the atmosphere thickness in meter
 void setHorizonColor(java.awt.Color color)
          Set the horizon color
 void setZenithColor(java.awt.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.
 java.lang.String toString()
           
protected  void updateSkyDone(DrawContext dc)
           
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
doPick, doPreRender, getDataFileStore, getExpiryTime, getMaxActiveAltitude, getMinActiveAltitude, getName, getOpacity, getRestorableState, getScale, getScreenCredit, isAtMaxResolution, isEnabled, isLayerActive, 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
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, 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
 

Field Detail

glListId

protected int glListId

horizonColor

protected float[] horizonColor

lastRebuildHorizon

protected double lastRebuildHorizon

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)

applyDrawTransform

protected void applyDrawTransform(DrawContext dc)

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}

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractLayer

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 java.awt.Color getHorizonColor()
Get the horizon color

Returns:
the horizon color

getZenithColor

public java.awt.Color getZenithColor()
Get the zenith color

Returns:
the zenith color

isValid

protected boolean isValid(DrawContext dc)

makeSkyDome

protected void makeSkyDome(DrawContext dc,
                           float radius,
                           double startLat,
                           double endLat,
                           int slices,
                           int stacks,
                           float zenithOpacity,
                           float gradientBias)
Build sky dome and draw into the glList

Parameters:
dc - the current DrawContext
radius - the sky dome radius in meters.
startLat - the horizon latitude in decimal degrees.
endLat - the zenith latitude in decimal degrees.
slices - the number of longitude divisions used for the dome geometry.
stacks - the number of latitude divisions used for the dome geometry.
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.

setAtmosphereThickness

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

Parameters:
thickness - the atmosphere thickness in meter

setHorizonColor

public void setHorizonColor(java.awt.Color color)
Set the horizon color

Parameters:
color - the horizon color

setZenithColor

public void setZenithColor(java.awt.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 java.lang.String toString()
Overrides:
toString in class AbstractLayer

updateSkyDone

protected void updateSkyDone(DrawContext dc)

NASA World Wind