j3d.org Code

org.j3d.geom.terrain
Class ColorRampGenerator

java.lang.Object
  extended by org.j3d.geom.terrain.ColorRampGenerator

public class ColorRampGenerator
extends java.lang.Object

Utility class to create colors per vertex for a terrain model where the colour model is based on a ramp value.

This class is designed as a complement to the normal geometry generator classes. The input is an existing, already created piece of geometry and this adds the colour array to the GeometryData. Colour interpolation is based on using the ColorInterpolator running in RGB mode.

The alpha channel is optional and the caller has to know if they are supplying values with alpha or not. If alpha is used, the output array is in RGBA format in the array.

Values outside the range provided are clamped.

Internationalisation Resource Names

Version:
$Revision: 1.3 $
Author:
Justin Couch

Constructor Summary
ColorRampGenerator()
          Construct a ramp generator with no color information set.
ColorRampGenerator(float[] heights, javax.vecmath.Color3f[] ramp)
          Create a new colour ramp generator that uses the given heights and 3 component colour values for that height for the interpolation.
ColorRampGenerator(float[] heights, javax.vecmath.Color4f[] ramp)
          Create a new colour ramp generator that uses the given heights and 4 component colour values for that height for the interpolation.
ColorRampGenerator(float[] heights, float[][] ramp)
          Create a new colour ramp generator that uses the given heights and colour values for that height for the interpolation.
ColorRampGenerator(float[] heights, float[] ramp, boolean hasAlpha)
          Create a new colour ramp generator that uses the given heights and colour values for that height for the interpolation.
 
Method Summary
 void generate(GeometryData data)
          Generate a new set of colors based on the passed data.
 void setColorRamp(float[] heights, javax.vecmath.Color3f[] ramp)
          Set the color data for the ramp to the new 3 component values.
 void setColorRamp(float[] heights, javax.vecmath.Color4f[] ramp)
          Set the color data for the ramp to the new 4 component values.
 void setColorRamp(float[] heights, float[][] ramp)
          Set the color data for the ramp to the new 3 or 4 component values.
 void setColorRamp(float[] heights, float[][] ramp, int size)
          Set the color data for the ramp to the new 3 or 4 component values.
 void setColorRamp(float[] heights, float[] ramp, boolean hasAlpha)
          Set the color data for the ramp to the new 3 or 4 component values.
 void setColorRamp(float[] heights, float[] ramp, int size, boolean hasAlpha)
          Set the color data for the ramp to the new 3 or 4 component values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorRampGenerator

public ColorRampGenerator()
Construct a ramp generator with no color information set. The defaults are:
Sea Level: 0
Sea Color: 0, 0, 1
Ground color: 1, 0, 0


ColorRampGenerator

public ColorRampGenerator(float[] heights,
                          javax.vecmath.Color3f[] ramp)
Create a new colour ramp generator that uses the given heights and 3 component colour values for that height for the interpolation.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

ColorRampGenerator

public ColorRampGenerator(float[] heights,
                          javax.vecmath.Color4f[] ramp)
Create a new colour ramp generator that uses the given heights and 4 component colour values for that height for the interpolation.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

ColorRampGenerator

public ColorRampGenerator(float[] heights,
                          float[][] ramp)
Create a new colour ramp generator that uses the given heights and colour values for that height for the interpolation. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

ColorRampGenerator

public ColorRampGenerator(float[] heights,
                          float[] ramp,
                          boolean hasAlpha)
Create a new colour ramp generator that uses the given heights and colour values for that height for the interpolation. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length
Method Detail

setColorRamp

public void setColorRamp(float[] heights,
                         javax.vecmath.Color3f[] ramp)
Set the color data for the ramp to the new 3 component values.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] heights,
                         javax.vecmath.Color4f[] ramp)
Set the color data for the ramp to the new 4 component values.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] heights,
                         float[][] ramp)
Set the color data for the ramp to the new 3 or 4 component values. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] heights,
                         float[][] ramp,
                         int size)
Set the color data for the ramp to the new 3 or 4 component values. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
size - The number of values to read from the two inputs
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] heights,
                         float[] ramp,
                         boolean hasAlpha)
Set the color data for the ramp to the new 3 or 4 component values. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] heights,
                         float[] ramp,
                         int size,
                         boolean hasAlpha)
Set the color data for the ramp to the new 3 or 4 component values. To determine if an alpha channel is used, the first index of the array's length is checked. If length is 3 then no alpha channel is used, otherwise it is assumed.

Parameters:
heights - The array of heights for each color
ramp - The color values at each height
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

generate

public void generate(GeometryData data)
              throws InvalidArraySizeException
Generate a new set of colors based on the passed data. If the data does not contain the right minimum array lengths an exception will be generated. If the array reference is null, this will create arrays of the correct length and assign them to the return value.

Parameters:
data - The data to base the calculations on
Throws:
InvalidArraySizeException - The array is not big enough to contain the requested colours
java.lang.IllegalArgumentException - The vertex array is not defined

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org