org.jmol.g3d
Class Shade3D

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

final class Shade3D
extends Object

All static functions. 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 float ambientFraction
           
(package private) static int ambientPercent
           
(package private) static float diffuseFactor
           
(package private) static int diffusePercent
           
(package private) static float intenseFraction
           
private static float magnitudeLight
           
(package private) static int phongExponent
           
private static int seed
           
(package private) static int shadeIndexLast
           
(package private) static int shadeIndexMax
           
(package private) static byte shadeIndexNoisyLimit
           
(package private) static byte shadeIndexNormal
           
(package private) static int specularExponent
           
(package private) static float specularFactor
           
(package private) static boolean specularOn
           
(package private) static int specularPercent
           
(package private) static int specularPower
           
(package private) static byte[] sphereShadeIndexes
           
(package private) static boolean sphereShadingCalculated
           
(package private) static boolean usePhongExponent
           
(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
           
static int zPower
           
 
Constructor Summary
Shade3D()
           
 
Method Summary
(package private) static void calcSphereShading()
           
(package private) static byte getDitheredNoisyShadeIndex(float x, float y, float z, float r)
           
private static float getFloatShadeIndexNormalized(float x, float y, float z)
           
(package private) static int getFp8ShadeIndex(float x, float y, float z)
           
(package private) static int getShadeIndex(float x, float y, float z)
           
(package private) static byte getShadeIndexNormalized(float x, float y, float z)
           
(package private) static int[] getShades(int rgb, boolean greyScale)
           
(package private) static int nextRandom8Bit()
           Implements RANDU algorithm for random noise in lighting/shading.
(package 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

shadeIndexMax

static final int shadeIndexMax
See Also:
Constant Field Values

shadeIndexLast

static final int shadeIndexLast
See Also:
Constant Field Values

shadeIndexNormal

static final byte shadeIndexNormal
See Also:
Constant Field Values

shadeIndexNoisyLimit

static final byte shadeIndexNoisyLimit
See Also:
Constant Field Values

zPower

public static int zPower

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

specularOn

static boolean specularOn

usePhongExponent

static boolean usePhongExponent

ambientPercent

static int ambientPercent

diffusePercent

static int diffusePercent

specularExponent

static int specularExponent

specularPercent

static int specularPercent

specularPower

static int specularPower

phongExponent

static int phongExponent

ambientFraction

static float ambientFraction

diffuseFactor

static float diffuseFactor

intenseFraction

static float intenseFraction

specularFactor

static float specularFactor

sphereShadingCalculated

static boolean sphereShadingCalculated

sphereShadeIndexes

static final byte[] sphereShadeIndexes

seed

private static int seed
Constructor Detail

Shade3D

Shade3D()
Method Detail

getShades

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

rgb

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

getShadeIndex

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

getShadeIndexNormalized

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

getFp8ShadeIndex

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

getFloatShadeIndexNormalized

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

getDitheredNoisyShadeIndex

static byte getDitheredNoisyShadeIndex(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