Class SkyGradientLayer

  • All Implemented Interfaces:
    AVList, Disposable, MessageListener, 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 Detail

      • thickness

        protected double thickness
      • horizonColor

        protected float[] horizonColor
      • zenithColor

        protected float[] zenithColor
    • Constructor Detail

      • SkyGradientLayer

        public SkyGradientLayer()
        Renders an atmosphere around the globe
    • Method Detail

      • getAtmosphereThickness

        public double getAtmosphereThickness()
        Get the atmosphere thickness in meter
        Returns:
        the atmosphere thickness in meter
      • setAtmosphereThickness

        public void setAtmosphereThickness​(double thickness)
        Set the atmosphere thickness in meter
        Parameters:
        thickness - the atmosphere thickness in meter
      • getHorizonColor

        public java.awt.Color getHorizonColor()
        Get the horizon color
        Returns:
        the horizon color
      • setHorizonColor

        public void setHorizonColor​(java.awt.Color color)
        Set the horizon color
        Parameters:
        color - the horizon color
      • getZenithColor

        public java.awt.Color getZenithColor()
        Get the zenith color
        Returns:
        the zenith color
      • setZenithColor

        public void setZenithColor​(java.awt.Color color)
        Set the zenith color
        Parameters:
        color - the zenith color
      • updateSkyDome

        protected void updateSkyDome​(DrawContext dc)
      • 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.
      • 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
      • 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}