org.jmol.g3d
Class Shade3D

java.lang.Object
  extended by org.jmol.g3d.Shade3D

final class Shade3D
extends java.lang.Object

Implements the shading of RGB values to support shadow and lighting highlights.

Each RGB value has 64 shades. shade[0] represents ambient lighting. shade[63] is white ... a full specular highlight.

Author:
Miguel, miguel@jmol.org

Field Summary
(package private) static int AMBIENT_FRACTION
           
(package private) static int AMBIENT_PERCENT
           
(package private) static int DIFFUSE_PERCENT
           
(package private) static int INTENSE_FRACTION
           
(package private) static int INTENSITY_DIFFUSE
           
(package private) static int INTENSITY_SPECULAR
           
(package private) static byte intensitySpecularSurfaceLimit
           
(package private) static float[] lighting
           
private static float magnitudeLight
           
private static int seed
           
(package private) static int shadeLast
           
(package private) static int shadeMax
           
(package private) static byte shadeNormal
           
(package private) static int SPECULAR_EXPONENT
           
(package private) static int SPECULAR_ON
           
(package private) static int SPECULAR_PERCENT
           
(package private) static int SPECULAR_POWER
           
(package private) static byte[] sphereIntensities
           
(package private) static boolean sphereShadingCalculated
           
(package private) static float xLight
           
private static float xLightsource
           
(package private) static float yLight
           
private static float yLightsource
           
(package private) static float zLight
           
private static float zLightsource
           
 
Constructor Summary
Shade3D()
           
 
Method Summary
(package private) static byte calcDitheredNoisyIntensity(float x, float y, float z, float r)
           
private static float calcFloatIntensityNormalized(float x, float y, float z)
           
(package private) static int calcFp8Intensity(float x, float y, float z)
           
(package private) static byte calcIntensity(float x, float y, float z)
           
(package private) static byte calcIntensityNormalized(float x, float y, float z)
           
(package private) static void calcSphereShading()
           
(package private) static int[] getShades(int rgb, boolean greyScale)
           
(package private) static int nextRandom8Bit()
           Implements RANDU algorithm for random noise in lighting/shading.
private static int rgb(int red, int grn, int blu)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shadeMax

static final int shadeMax
See Also:
Constant Field Values

shadeLast

static final int shadeLast
See Also:
Constant Field Values

shadeNormal

static byte shadeNormal

xLightsource

private static final float xLightsource
See Also:
Constant Field Values

yLightsource

private static final float yLightsource
See Also:
Constant Field Values

zLightsource

private static final float zLightsource
See Also:
Constant Field Values

magnitudeLight

private static final float magnitudeLight

xLight

static final float xLight

yLight

static final float yLight

zLight

static final float zLight

SPECULAR_ON

static int SPECULAR_ON

SPECULAR_PERCENT

static int SPECULAR_PERCENT

SPECULAR_EXPONENT

static int SPECULAR_EXPONENT

SPECULAR_POWER

static int SPECULAR_POWER

DIFFUSE_PERCENT

static int DIFFUSE_PERCENT

AMBIENT_PERCENT

static int AMBIENT_PERCENT

INTENSITY_SPECULAR

static int INTENSITY_SPECULAR

INTENSE_FRACTION

static int INTENSE_FRACTION

INTENSITY_DIFFUSE

static int INTENSITY_DIFFUSE

AMBIENT_FRACTION

static int AMBIENT_FRACTION

lighting

static final float[] lighting

intensitySpecularSurfaceLimit

static final byte intensitySpecularSurfaceLimit

sphereShadingCalculated

static boolean sphereShadingCalculated

sphereIntensities

static final byte[] sphereIntensities

seed

private static int seed
Constructor Detail

Shade3D

Shade3D()
Method Detail

getShades

static int[] getShades(int rgb,
                       boolean greyScale)

rgb

private static final int rgb(int red,
                             int grn,
                             int blu)

calcIntensity

static byte calcIntensity(float x,
                          float y,
                          float z)

calcIntensityNormalized

static byte calcIntensityNormalized(float x,
                                    float y,
                                    float z)

calcFp8Intensity

static int calcFp8Intensity(float x,
                            float y,
                            float z)

calcFloatIntensityNormalized

private static float calcFloatIntensityNormalized(float x,
                                                  float y,
                                                  float z)

calcDitheredNoisyIntensity

static byte calcDitheredNoisyIntensity(float x,
                                       float y,
                                       float z,
                                       float r)

calcSphereShading

static void calcSphereShading()

nextRandom8Bit

static int nextRandom8Bit()

Implements RANDU algorithm for random noise in lighting/shading.

RANDU is the classic example of a poor random number generator. But it is very cheap to calculate and is good enough for our purposes.

Returns:
Next random