org.jmol.g3d

Class Shade3D

final class Shade3D extends 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
static intAMBIENT_FRACTION
static intAMBIENT_PERCENT
static intDIFFUSE_PERCENT
static byteintensitySpecularSurfaceLimit
static intINTENSE_FRACTION
static intINTENSITY_DIFFUSE
static intINTENSITY_SPECULAR
static float[]lighting
static floatmagnitudeLight
static intseed
static intshadeLast
static intshadeMax
static byteshadeNormal
static byte[]sphereIntensities
static booleansphereShadingCalculated
static intSPECULAR_EXPONENT
static intSPECULAR_ON
static intSPECULAR_PERCENT
static intSPECULAR_POWER
static floatxLight
static floatxLightsource
static floatyLight
static floatyLightsource
static floatzLight
static floatzLightsource
Method Summary
static bytecalcDitheredNoisyIntensity(float x, float y, float z, float r)
static floatcalcFloatIntensityNormalized(float x, float y, float z)
static intcalcFp8Intensity(float x, float y, float z)
static bytecalcIntensity(float x, float y, float z)
static bytecalcIntensityNormalized(float x, float y, float z)
static voidcalcSphereShading()
static int[]getShades(int rgb, boolean greyScale)
static intnextRandom8Bit()

Implements RANDU algorithm for random noise in lighting/shading.

static intrgb(int red, int grn, int blu)

Field Detail

AMBIENT_FRACTION

static int AMBIENT_FRACTION

AMBIENT_PERCENT

static int AMBIENT_PERCENT

DIFFUSE_PERCENT

static int DIFFUSE_PERCENT

intensitySpecularSurfaceLimit

static final byte intensitySpecularSurfaceLimit

INTENSE_FRACTION

static int INTENSE_FRACTION

INTENSITY_DIFFUSE

static int INTENSITY_DIFFUSE

INTENSITY_SPECULAR

static int INTENSITY_SPECULAR

lighting

static final float[] lighting

magnitudeLight

private static final float magnitudeLight

seed

private static int seed

shadeLast

static final int shadeLast

shadeMax

static final int shadeMax

shadeNormal

static byte shadeNormal

sphereIntensities

static final byte[] sphereIntensities

sphereShadingCalculated

static boolean sphereShadingCalculated

SPECULAR_EXPONENT

static int SPECULAR_EXPONENT

SPECULAR_ON

static int SPECULAR_ON

SPECULAR_PERCENT

static int SPECULAR_PERCENT

SPECULAR_POWER

static int SPECULAR_POWER

xLight

static final float xLight

xLightsource

private static final float xLightsource

yLight

static final float yLight

yLightsource

private static final float yLightsource

zLight

static final float zLight

zLightsource

private static final float zLightsource

Method Detail

calcDitheredNoisyIntensity

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

calcFloatIntensityNormalized

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

calcFp8Intensity

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

calcIntensity

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

calcIntensityNormalized

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

calcSphereShading

static void calcSphereShading()

getShades

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

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

rgb

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