com.jme.scene.state
Class AlphaState

java.lang.Object
  extended bycom.jme.scene.state.RenderState
      extended bycom.jme.scene.state.AlphaState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LWJGLAlphaState

public abstract class AlphaState
extends RenderState

AlphaState maintains the state of the alpha values of a particular node and it's children. The alpha state provides a method for blending a source pixel with a destination pixel. The alpha 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: AlphaState.java,v 1.3 2004/08/02 22:35:00 cep21 Exp $
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
protected  boolean blendEnabled
          The current value of if blend is enabled.
static int DB_DST_ALPHA
          The destination value of the blend function is the destination alpha value.
static int DB_ONE
          The destination value of the blend function is all ones.
static int DB_ONE_MINUS_DST_ALPHA
          The destination value of the blend function is 1 - the destination alpha value.
static int DB_ONE_MINUS_SRC_ALPHA
          The destination value of the blend function is 1 - the source alpha value.
static int DB_ONE_MINUS_SRC_COLOR
          The destination value of the blend function is 1 - the source color.
static int DB_SRC_ALPHA
          The destination value of the blend function is the source alpha value.
static int DB_SRC_COLOR
          The destination value of the blend function is the source color.
static int DB_ZERO
          The destination value of the blend function is all zeros.
protected  int dstBlend
          The current destiantion blend function.
protected  float reference
          The reference value to which incoming alpha values are compared.
static int SB_DST_COLOR
          The source value of the blend function is the distance color.
static int SB_ONE
          The source value of the blend function is all ones.
static int SB_ONE_MINUS_DST_COLOR
          The source value of the blend function is 1 - the distance color.
static int SB_ONE_MINUS_SRC_ALPHA
          The source value of the blend function is 1 - the source alpha value.
static int SB_SRC_ALPHA
          The source value of the blend function is the source alpha value.
static int SB_SRC_ALPHA_SATURATE
          The source value of the blend function is the minimum of alpha or 1 - alpha.
static int SB_ZERO
          The source value of the blend function is all zeros.
protected  int srcBlend
          The current source blend function.
protected  int test
          Alpha test value.
protected  boolean testEnabled
          If enabled, alpha testing done.
static int TF_ALWAYS
          Always passes the depth test.
static int TF_EQUAL
          Pass the test if this alpha is equal to the reference alpha.
static int TF_GEQUAL
          Pass the test if this alpha is greater than or equal to the reference alpha.
static int TF_GREATER
          Pass the test if this alpha is greater than the reference alpha.
static int TF_LEQUAL
          Pass the test if this alpha is less than or equal to the reference alpha.
static int TF_LESS
          Pass the test if this alpha is less than the reference alpha.
static int TF_NEVER
          Never passes the depth test.
static int TF_NOTEQUAL
          Pass the test if this alpha is not equal to the reference alpha.
 
Fields inherited from class com.jme.scene.state.RenderState
RS_ALPHA, RS_ATTRIBUTE, RS_CULL, RS_DITHER, 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
AlphaState()
          Constructor instantiates a new AlphaState object with default values.
 
Method Summary
 int getDstFunction()
          getDstFunction returns the destination function for the blending function.
 float getReference()
          getReference returns the reference value that incoming alpha values are compared to.
 int getSrcFunction()
          getSrcFunction returns the source function for the blending function.
 int getTestFunction()
          getTestFunction returns the testing function used for the alpha testing.
 int getType()
          getType returns the type of render state this is.
 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 setBlendEnabled(boolean value)
          setBlendEnabled sets whether or not blending is enabled.
 void setDstFunction(int dstFunction)
          setDstFunction sets the destination function for the blending function.
 void setReference(float reference)
          setReference sets the reference value that incoming alpha values are compared to.
 void setSrcFunction(int srcFunction)
          setSrcFunction sets the source function for the blending function.
 void setTestEnabled(boolean value)
          setTestEnabled turns alpha testing on and off.
 void setTestFunction(int testFunction)
          setTestFunction sets the testing function used for the alpha testing.
 
Methods inherited from class com.jme.scene.state.RenderState
apply, extract, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SB_ZERO

public static final int SB_ZERO
The source value of the blend function is all zeros.

See Also:
Constant Field Values

SB_ONE

public static final int SB_ONE
The source value of the blend function is all ones.

See Also:
Constant Field Values

SB_DST_COLOR

public static final int SB_DST_COLOR
The source value of the blend function is the distance color.

See Also:
Constant Field Values

SB_ONE_MINUS_DST_COLOR

public static final int SB_ONE_MINUS_DST_COLOR
The source value of the blend function is 1 - the distance color.

See Also:
Constant Field Values

SB_SRC_ALPHA

public static final int SB_SRC_ALPHA
The source value of the blend function is the source alpha value.

See Also:
Constant Field Values

SB_ONE_MINUS_SRC_ALPHA

public static final int SB_ONE_MINUS_SRC_ALPHA
The source value of the blend function is 1 - the source alpha value.

See Also:
Constant Field Values

SB_SRC_ALPHA_SATURATE

public static final int SB_SRC_ALPHA_SATURATE
The source value of the blend function is the minimum of alpha or 1 - alpha.

See Also:
Constant Field Values

DB_ZERO

public static final int DB_ZERO
The destination value of the blend function is all zeros.

See Also:
Constant Field Values

DB_ONE

public static final int DB_ONE
The destination value of the blend function is all ones.

See Also:
Constant Field Values

DB_SRC_COLOR

public static final int DB_SRC_COLOR
The destination value of the blend function is the source color.

See Also:
Constant Field Values

DB_ONE_MINUS_SRC_COLOR

public static final int DB_ONE_MINUS_SRC_COLOR
The destination value of the blend function is 1 - the source color.

See Also:
Constant Field Values

DB_SRC_ALPHA

public static final int DB_SRC_ALPHA
The destination value of the blend function is the source alpha value.

See Also:
Constant Field Values

DB_ONE_MINUS_SRC_ALPHA

public static final int DB_ONE_MINUS_SRC_ALPHA
The destination value of the blend function is 1 - the source alpha value.

See Also:
Constant Field Values

DB_DST_ALPHA

public static final int DB_DST_ALPHA
The destination value of the blend function is the destination alpha value.

See Also:
Constant Field Values

DB_ONE_MINUS_DST_ALPHA

public static final int DB_ONE_MINUS_DST_ALPHA
The destination value of the blend function is 1 - the destination alpha value.

See Also:
Constant Field Values

TF_NEVER

public static final int TF_NEVER
Never passes the depth test.

See Also:
Constant Field Values

TF_LESS

public static final int TF_LESS
Pass the test if this alpha is less than the reference alpha.

See Also:
Constant Field Values

TF_EQUAL

public static final int TF_EQUAL
Pass the test if this alpha is equal to the reference alpha.

See Also:
Constant Field Values

TF_LEQUAL

public static final int TF_LEQUAL
Pass the test if this alpha is less than or equal to the reference alpha.

See Also:
Constant Field Values

TF_GREATER

public static final int TF_GREATER
Pass the test if this alpha is greater than the reference alpha.

See Also:
Constant Field Values

TF_NOTEQUAL

public static final int TF_NOTEQUAL
Pass the test if this alpha is not equal to the reference alpha.

See Also:
Constant Field Values

TF_GEQUAL

public static final int TF_GEQUAL
Pass the test if this alpha is greater than or equal to the reference alpha.

See Also:
Constant Field Values

TF_ALWAYS

public static final int TF_ALWAYS
Always passes the depth test.

See Also:
Constant Field Values

blendEnabled

protected boolean blendEnabled
The current value of if blend is enabled.


srcBlend

protected int srcBlend
The current source blend function.


dstBlend

protected int dstBlend
The current destiantion blend function.


testEnabled

protected boolean testEnabled
If enabled, alpha testing done.


test

protected int test
Alpha test value.


reference

protected float reference
The reference value to which incoming alpha values are compared.

Constructor Detail

AlphaState

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

Method Detail

getType

public int getType()
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()

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.

setSrcFunction

public void setSrcFunction(int srcFunction)
setSrcFunction sets the source function for the blending function. If an invalid value is passed, the default SB_SRC_ALPHA is used.

Parameters:
srcFunction - the source function for the blending equation.

getSrcFunction

public int getSrcFunction()
getSrcFunction returns the source function for the blending function.

Returns:
the source function for the blending function.

setDstFunction

public void setDstFunction(int dstFunction)
setDstFunction sets the destination function for the blending function. If an invalid value is passed, the default DB_ONE_MINUS_SRC_ALPHA is used.

Parameters:
dstFunction - the destination function for the blending equation.

getDstFunction

public int getDstFunction()
getDstFunction returns the destination function for the blending function.

Returns:
the destination function for the blending function.

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(int testFunction)
setTestFunction sets the testing function used for the alpha testing. If an invalid value is passed, the default TF_ALWAYS is used.

Parameters:
testFunction - the testing function used for the alpha testing.

getTestFunction

public int 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. This is clamped to [0, 1].

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

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.