com.jme.scene.state
Class BlendState

java.lang.Object
  extended by com.jme.scene.state.RenderState
      extended by com.jme.scene.state.BlendState
All Implemented Interfaces:
Savable
Direct Known Subclasses:
JOGLBlendState, LWJGLBlendState

public abstract class BlendState
extends RenderState

BlendState maintains the state of the blending values of a particular node and its children. The blend state provides a method for blending a source pixel with a destination pixel. The blend value provides a transparent or translucent surfaces. For example, this would allow for the rendering of green glass. Where you could see all objects behind this green glass but they would be tinted green.

Version:
$Id: BlendState.java 4137 2009-03-20 18:38:24Z christoph.luder $
Author:
Mark Powell, Joshua Slack

Nested Class Summary
static class BlendState.BlendEquation
           
static class BlendState.DestinationFunction
           
static class BlendState.SourceFunction
           
static class BlendState.TestFunction
           
 
Nested classes/interfaces inherited from class com.jme.scene.state.RenderState
RenderState.StateType
 
Field Summary
protected static boolean supportsConstantColor
           
protected static boolean supportsEq
           
protected static boolean supportsMinMax
           
protected static boolean supportsSeparateEq
           
protected static boolean supportsSeparateFunc
           
protected static boolean supportsSubtract
           
 
Fields inherited from class com.jme.scene.state.RenderState
QUICK_COMPARE, RS_BLEND, RS_CLIP, RS_COLORMASK_STATE, RS_CULL, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
BlendState()
          Constructor instantiates a new BlendState object with default values.
 
Method Summary
 BlendState.BlendEquation getBlendEquationAlpha()
           
 BlendState.BlendEquation getBlendEquationRGB()
           
 java.lang.Class<?> getClassTag()
           
 ColorRGBA getConstantColor()
           
 BlendState.DestinationFunction getDestinationFunctionAlpha()
          getDestinationFunction returns the destination function for the blending function.
 BlendState.DestinationFunction getDestinationFunctionRGB()
          getDestinationFunction returns the destination function for the blending function.
 float getReference()
          getReference returns the reference value that incoming alpha values are compared to.
 BlendState.SourceFunction getSourceFunctionAlpha()
          getSourceFunction returns the source function for the blending function.
 BlendState.SourceFunction getSourceFunctionRGB()
          getSourceFunction returns the source function for the blending function.
 RenderState.StateType getStateType()
          getStateType returns the type RenderState.StateType.Blend
 BlendState.TestFunction getTestFunction()
          getTestFunction returns the testing function used for the alpha testing.
 int getType()
          Deprecated. As of 2.0, use RenderState.getStateType() instead.
 boolean isBlendEnabled()
          isBlendEnabled returns true if blending is turned on, otherwise false is returned.
 boolean isTestEnabled()
          isTestEnabled returns true if alpha testing is enabled, false otherwise.
 void read(JMEImporter e)
           
 void setBlendEnabled(boolean value)
          setBlendEnabled sets whether or not blending is enabled.
 void setBlendEquation(BlendState.BlendEquation blendEquation)
           
 void setBlendEquationAlpha(BlendState.BlendEquation blendEquation)
           
 void setBlendEquationRGB(BlendState.BlendEquation blendEquation)
           
 void setConstantColor(ColorRGBA constantColor)
           
 void setDestinationFunction(BlendState.DestinationFunction function)
          setDestinationFunction sets the destination function for the blending equation for both Alpha and RGB values.
 void setDestinationFunctionAlpha(BlendState.DestinationFunction function)
          setDestinationFunctionAlpha sets the destination function for the blending equation.
 void setDestinationFunctionRGB(BlendState.DestinationFunction function)
          setDestinationFunctionRGB sets the destination function for the blending equation.
 void setReference(float reference)
          setReference sets the reference value that incoming alpha values are compared to when doing alpha testing.
 void setSourceFunction(BlendState.SourceFunction function)
          setSrcFunction sets the source function for the blending equation for both rgb and alpha values.
 void setSourceFunctionAlpha(BlendState.SourceFunction function)
          setSourceFunctionAlpha sets the source function for the blending equation used with alpha values.
 void setSourceFunctionRGB(BlendState.SourceFunction function)
          setSrcFunction sets the source function for the blending equation.
 void setTestEnabled(boolean value)
          setTestEnabled turns alpha testing on and off.
 void setTestFunction(BlendState.TestFunction function)
          setTestFunction sets the testing function used for the alpha testing.
static boolean supportsConstantColor()
           
static boolean supportsEquation()
           
static boolean supportsMinMaxEquations()
           
static boolean supportsSeparateEquations()
           
static boolean supportsSeparateFunctions()
           
static boolean supportsSubtractEquations()
           
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.state.RenderState
apply, createStateRecord, extract, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportsConstantColor

protected static boolean supportsConstantColor

supportsEq

protected static boolean supportsEq

supportsSeparateEq

protected static boolean supportsSeparateEq

supportsSeparateFunc

protected static boolean supportsSeparateFunc

supportsMinMax

protected static boolean supportsMinMax

supportsSubtract

protected static boolean supportsSubtract
Constructor Detail

BlendState

public BlendState()
Constructor instantiates a new BlendState object with default values.

Method Detail

getType

public int getType()
Deprecated. As of 2.0, use RenderState.getStateType() instead.

getType returns the type of render state this is. (RS_ALPHA).

Specified by:
getType in class RenderState
Returns:
An int identifying this render state.
See Also:
RenderState.getType()

getStateType

public RenderState.StateType getStateType()
getStateType returns the type RenderState.StateType.Blend

Specified by:
getStateType in class RenderState
Returns:
RenderState.StateType.Blend
See Also:
RenderState.getStateType()

isBlendEnabled

public boolean isBlendEnabled()
isBlendEnabled returns true if blending is turned on, otherwise false is returned.

Returns:
true if blending is enabled, false otherwise.

setBlendEnabled

public void setBlendEnabled(boolean value)
setBlendEnabled sets whether or not blending is enabled.

Parameters:
value - true to enable the blending, false to disable it.

setSourceFunction

public void setSourceFunction(BlendState.SourceFunction function)
setSrcFunction sets the source function for the blending equation for both rgb and alpha values.

Parameters:
function - the source function for the blending equation.
Throws:
java.lang.IllegalArgumentException - if function is null

setSourceFunctionRGB

public void setSourceFunctionRGB(BlendState.SourceFunction function)
setSrcFunction sets the source function for the blending equation. If supportsSeparateFunc is false, this value will be used for RGB and Alpha.

Parameters:
function - the source function for the blending equation.
Throws:
java.lang.IllegalArgumentException - if function is null

setSourceFunctionAlpha

public void setSourceFunctionAlpha(BlendState.SourceFunction function)
setSourceFunctionAlpha sets the source function for the blending equation used with alpha values.

Parameters:
function - the source function for the blending equation for alpha values.
Throws:
java.lang.IllegalArgumentException - if function is null

getSourceFunctionRGB

public BlendState.SourceFunction getSourceFunctionRGB()
getSourceFunction returns the source function for the blending function.

Returns:
the source function for the blending function.

getSourceFunctionAlpha

public BlendState.SourceFunction getSourceFunctionAlpha()
getSourceFunction returns the source function for the blending function.

Returns:
the source function for the blending function.

setDestinationFunction

public void setDestinationFunction(BlendState.DestinationFunction function)
setDestinationFunction sets the destination function for the blending equation for both Alpha and RGB values.

Parameters:
function - the destination function for the blending equation.
Throws:
java.lang.IllegalArgumentException - if function is null

setDestinationFunctionRGB

public void setDestinationFunctionRGB(BlendState.DestinationFunction function)
setDestinationFunctionRGB sets the destination function for the blending equation. If supportsSeparateFunc is false, this value will be used for RGB and Alpha.

Parameters:
function - the destination function for the blending equation for RGB values.
Throws:
java.lang.IllegalArgumentException - if function is null

setDestinationFunctionAlpha

public void setDestinationFunctionAlpha(BlendState.DestinationFunction function)
setDestinationFunctionAlpha sets the destination function for the blending equation.

Parameters:
function - the destination function for the blending equation for Alpha values.
Throws:
java.lang.IllegalArgumentException - if function is null

getDestinationFunctionRGB

public BlendState.DestinationFunction getDestinationFunctionRGB()
getDestinationFunction returns the destination function for the blending function.

Returns:
the destination function for the blending function.

getDestinationFunctionAlpha

public BlendState.DestinationFunction getDestinationFunctionAlpha()
getDestinationFunction returns the destination function for the blending function.

Returns:
the destination function for the blending function.

setBlendEquation

public void setBlendEquation(BlendState.BlendEquation blendEquation)

setBlendEquationRGB

public void setBlendEquationRGB(BlendState.BlendEquation blendEquation)

setBlendEquationAlpha

public void setBlendEquationAlpha(BlendState.BlendEquation blendEquation)

getBlendEquationRGB

public BlendState.BlendEquation getBlendEquationRGB()

getBlendEquationAlpha

public BlendState.BlendEquation getBlendEquationAlpha()

isTestEnabled

public boolean isTestEnabled()
isTestEnabled returns true if alpha testing is enabled, false otherwise.

Returns:
true if alpha testing is enabled, false otherwise.

setTestEnabled

public void setTestEnabled(boolean value)
setTestEnabled turns alpha testing on and off. True turns on the testing, while false diables it.

Parameters:
value - true to enabled alpha testing, false to disable it.

setTestFunction

public void setTestFunction(BlendState.TestFunction function)
setTestFunction sets the testing function used for the alpha testing. If an invalid value is passed, the default TF_ALWAYS is used.

Parameters:
function - the testing function used for the alpha testing.
Throws:
java.lang.IllegalArgumentException - if function is null

getTestFunction

public BlendState.TestFunction getTestFunction()
getTestFunction returns the testing function used for the alpha testing.

Returns:
the testing function used for the alpha testing.

setReference

public void setReference(float reference)
setReference sets the reference value that incoming alpha values are compared to when doing alpha testing. This is clamped to [0, 1].

Parameters:
reference - the reference value that alpha values are compared to.

supportsConstantColor

public static boolean supportsConstantColor()
Returns:
true if we support setting a constant color for use with *Constant* type BlendFunctions.

supportsSeparateFunctions

public static boolean supportsSeparateFunctions()
Returns:
true if we support setting rgb and alpha functions separately for source and destination.

supportsEquation

public static boolean supportsEquation()
Returns:
true if we support setting the blend equation

supportsSeparateEquations

public static boolean supportsSeparateEquations()
Returns:
true if we support setting the blend equation for alpha and rgb separately

supportsMinMaxEquations

public static boolean supportsMinMaxEquations()
Returns:
true if we support using min and max blend equations

supportsSubtractEquations

public static boolean supportsSubtractEquations()
Returns:
true if we support using subtract blend equations

getReference

public float getReference()
getReference returns the reference value that incoming alpha values are compared to.

Returns:
the reference value that alpha values are compared to.

getConstantColor

public ColorRGBA getConstantColor()
Returns:
the color used in constant blending functions. If null and a *Constant* function is set, (0,0,0,0) is used.

setConstantColor

public void setConstantColor(ColorRGBA constantColor)

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class RenderState
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class RenderState
Throws:
java.io.IOException

getClassTag

public java.lang.Class<?> getClassTag()
Specified by:
getClassTag in interface Savable
Overrides:
getClassTag in class RenderState