jme.lighting
Class SlopeLighting

java.lang.Object
  extended byjme.lighting.AbstractLightMap
      extended byjme.lighting.SlopeLighting

public class SlopeLighting
extends AbstractLightMap

SlopeLighting creates a light map based on a given heightmap. This is based on Charlie Van Noland's algorithm. Slope lighting simply takes the difference between two vertices (heighthwise) and determines a lighting value. Direction for comparision is important and direction can only be an increment of 45 degrees. Thus, the direction parameters can be combinations of 1 and -2. I.e. 1,1 1,-1 -1,-1 -1,1.

Version:
$Id: SlopeLighting.java,v 1.3 2003/09/03 18:05:36 mojomonkey Exp $
Author:
Mark Powell

Field Summary
 
Fields inherited from class jme.lighting.AbstractLightMap
color, lightMap
 
Constructor Summary
SlopeLighting(AbstractHeightMap heightMap, int dirX, int dirZ, float minBright, float maxBright, int softness)
          Constructor sets the lighting attributes and calls createLighting initializing the light map.
 
Method Summary
 void createLighting()
          createLighting generates the latest lightmap from the available data set.
 void setDirX(int dirX)
          setDirX sets the direction of the light on the X axis.
 void setDirZ(int dirZ)
          setDirZ sets the direction of the light on the Z axis.
 void setHeightMap(AbstractHeightMap map)
          setHeightMap sets the heightmap for the slope calculations.
 void setMaxBright(float maxBright)
          setMaxBright sets the maximum brightness value for any given point.
 void setMinBright(float minBright)
          setMinBright sets the minimum brightness value for any given point.
 void setSoftness(int softness)
          setSoftness sets the amount to blend shadows.
 
Methods inherited from class jme.lighting.AbstractLightMap
getColor, getShade, setColor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlopeLighting

public SlopeLighting(AbstractHeightMap heightMap,
                     int dirX,
                     int dirZ,
                     float minBright,
                     float maxBright,
                     int softness)
Constructor sets the lighting attributes and calls createLighting initializing the light map.

Parameters:
heightMap - the height map to use for the slopes.
dirX - the x direction of the light source, 1 or -1
dirZ - the z direction of the light source, 1 or -1
minBright - the minimum brightness 0 to 1.
maxBright - the maximum brightness 0 to 1
softness - how much to blend light values, higher value more soft.
Throws:
MonkeyRuntimeException - if either direction is anything other than 1 or -1, either brightness is not between 0 and 1, or heightmap is null.
Method Detail

createLighting

public void createLighting()
createLighting generates the latest lightmap from the available data set. A call to createLighting is required to generate lighting for any changes of attributes, during construction this is called to insure a valid lightmap is available.


setDirX

public void setDirX(int dirX)
setDirX sets the direction of the light on the X axis. This value must be either 1 or -1.

Parameters:
dirX - direction of the light on the x axis.
Throws:
MonkeyRuntimeException - if dirX is not 1 or -1.

setDirZ

public void setDirZ(int dirZ)
setDirZ sets the direction of the light on the Z axis. This value must be either 1 or -1.

Parameters:
dirZ - direction of the light on the z axis.
Throws:
MonkeyRuntimeException - if dirZ is not 1 or -1.

setMaxBright

public void setMaxBright(float maxBright)
setMaxBright sets the maximum brightness value for any given point.

Parameters:
maxBright - the maximum brightness for a point.
Throws:
MonkeyRuntimeException - if maxBright is not between 0 and 1.

setMinBright

public void setMinBright(float minBright)
setMinBright sets the minimum brightness value for any given point.

Parameters:
minBright - the minimum brightness for a point.
Throws:
MonkeyRuntimeException - if minBright is not between 0 and 1.

setSoftness

public void setSoftness(int softness)
setSoftness sets the amount to blend shadows. The higher the number the more blending will be done. It is recommend to keep the number between 10 and 40.

Parameters:
softness - the amount to blend shadows.

setHeightMap

public void setHeightMap(AbstractHeightMap map)
setHeightMap sets the heightmap for the slope calculations.

Parameters:
map - the heightmap for slope calculations.
Throws:
MonkeyRuntimeException - if map is null.