net.jinx.video.model
Class GradientColoration

java.lang.Object
  extended by net.jinx.video.model.GradientColoration
All Implemented Interfaces:
Coloration

public class GradientColoration
extends java.lang.Object
implements Coloration

Coloration implementation that smoothly interpolates between two or more different Materials, giving a nice shaded appearance.
GradientColoration is composed of three optional gradients that operate along the three axes: X, Y, and Z. Each has a high limit, a low limit, a high Material and a low Material. The limits are coordinates on the axis. At any point greater than or equal to the high limit, the color is the high material. At any point greater than or equal to the lower limit, it is the low Material. At any point inbetween, the Material is interpolated, giving a smooth gradation between the two colors.
Gradients along all three axes can be enabled at the same time, but the appearance of such is usually not so interesting. It is usually best to only enable one.

API Stability: Stable.


Constructor Summary
GradientColoration()
          Constructs a GradientColoration.
 
Method Summary
 void draw(Context options, int number, float[] vertex)
          Causes the Coloration to be drawn.
 boolean isXEnabled()
          Provides the means to determine if the X gradient is enabled.
 boolean isYEnabled()
          Provides the means to determine if the Y gradient is enabled.
 boolean isZEnabled()
          Provides the means to determine if the Z gradient is enabled.
 void load(net.jinx.db.Hierarchy h)
          Configures this Coloration from the given Hierarchy.
 void setXElements(float xHigh, float xLow, Material xHighMat, Material xLowMat)
          Sets the X elements of the coloration and also enables the X shading.
 void setXEnabled(boolean enable)
          Enables or disables the X gradient.
 void setYElements(float yHigh, float yLow, Material yHighMat, Material yLowMat)
          Sets the Y elements of the coloration and also enables the Y shading.
 void setYEnabled(boolean enable)
          Enables or disables the Y gradient.
 void setZElements(float zHigh, float zLow, Material zHighMat, Material zLowMat)
          Sets the Z elements of the coloration and also enables the Z shading.
 void setZEnabled(boolean enable)
          Enables or disables the Z gradient.
 void store(net.jinx.db.Hierarchy h)
          Stores this Coloration to the given Hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GradientColoration

public GradientColoration()
Constructs a GradientColoration.

Method Detail

setXElements

public void setXElements(float xHigh,
                         float xLow,
                         Material xHighMat,
                         Material xLowMat)
Sets the X elements of the coloration and also enables the X shading.

Parameters:
xHigh - the upper limit of the X gradations.
xLow - the lower limit of the X gradations.
xHighMat - the Material associated with the upper limit.
xLowMat - the Material associated with the lower limit.

setYElements

public void setYElements(float yHigh,
                         float yLow,
                         Material yHighMat,
                         Material yLowMat)
Sets the Y elements of the coloration and also enables the Y shading.

Parameters:
yHigh - the upper limit of the Y gradations.
yLow - the lower limit of the Y gradations.
yHighMat - the Material associated with the upper limit.
yLowMat - the Material associated with the lower limit.

setZElements

public void setZElements(float zHigh,
                         float zLow,
                         Material zHighMat,
                         Material zLowMat)
Sets the Z elements of the coloration and also enables the Z shading.

Parameters:
zHigh - the upper limit of the Z gradations.
zLow - the lower limit of the Z gradations.
zHighMat - the Material associated with the upper limit.
zLowMat - the Material associated with the lower limit.

setXEnabled

public void setXEnabled(boolean enable)
Enables or disables the X gradient.

Parameters:
enable - if true, the gradient is enabled. If false, it is disabled.

isXEnabled

public boolean isXEnabled()
Provides the means to determine if the X gradient is enabled.

Returns:
true if it's enabled.

setYEnabled

public void setYEnabled(boolean enable)
Enables or disables the Y gradient.

Parameters:
enable - if true, the gradient is enabled. If false, it is disabled.

isYEnabled

public boolean isYEnabled()
Provides the means to determine if the Y gradient is enabled.

Returns:
true if it's enabled.

setZEnabled

public void setZEnabled(boolean enable)
Enables or disables the Z gradient.

Parameters:
enable - if true, the gradient is enabled. If false, it is disabled.

isZEnabled

public boolean isZEnabled()
Provides the means to determine if the Z gradient is enabled.

Returns:
true if it's enabled.

draw

public void draw(Context options,
                 int number,
                 float[] vertex)
Description copied from interface: Coloration
Causes the Coloration to be drawn. This should simply setup the OpenGL state according to the color that should be used.

Specified by:
draw in interface Coloration
Parameters:
options - the rendering options that are being used. Implementatons of this interface should pay attention to the color related flags.
number - the current vertex number.
vertex - the current vertex position (x, y, and z coordinates).

load

public void load(net.jinx.db.Hierarchy h)
Description copied from interface: Coloration
Configures this Coloration from the given Hierarchy. This is not meant to be called directly, unless you intend to configure a specific Coloration object.
This method is actually designed to be called by the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil, which will construct and return an instance of any Coloration class. This is the reason that all Coloration classes must have a no argument constructor. ModelUtil.loadColoration(net.jinx.db.Hierarchy) needs that to do it's job. By the time this method is called, the type of the coloration has already been determined and constructed and is now ready to be configured.

Specified by:
load in interface Coloration
Parameters:
h - the Hierarchy to configure this Coloration from.

store

public void store(net.jinx.db.Hierarchy h)
Description copied from interface: Coloration
Stores this Coloration to the given Hierarchy. This is not meant to be called directly, unless you know you're going to be using a specific Coloration implementation.
This method is actually designed to be called by the store(net.jinx.db.Hierarchy, Coloration) method of ModelUtil, which stores the name of the class to use, so that when the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil is used, the class can be instantiated and used.

Specified by:
store in interface Coloration
Parameters:
h - the Hierarchy to store this Coloration to.