org.dolben.iiid
Class Lighting

java.lang.Object
  extended by org.dolben.iiid.Lighting

public class Lighting
extends java.lang.Object

A representation of the lighting of a scene, with a method for finding the shading of a surface depending on its angle to the light.


Constructor Summary
Lighting()
          Creates new Lighting.
 
Method Summary
 java.awt.Color getShade(double[] normal, java.awt.Color color)
          Gets the shade for a color produced by the lighting.
 void setLight(double[] l, float bg)
          Sets the location of the light source and the background light level as a fraction of the source light.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lighting

public Lighting()
Creates new Lighting.

Method Detail

setLight

public void setLight(double[] l,
                     float bg)
Sets the location of the light source and the background light level as a fraction of the source light. The light is presumed to be very far away so that only direction is used to effect shading.

Parameters:
l - the 3D vector location of the light source
bg - the background light level (0,1)

getShade

public java.awt.Color getShade(double[] normal,
                               java.awt.Color color)
Gets the shade for a color produced by the lighting.

Parameters:
normal - the vector normal to the plane to be shaded
color - base color to be shaded
Returns:
the shaded color