Class BlendState

java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.BlendState
All Implemented Interfaces:
Savable

public 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.
  • Constructor Details

    • BlendState

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

    • getType

      public RenderState.StateType getType()
      Specified by:
      getType in class RenderState
      Returns:
      An statetype enum value for the subclass.
      See Also:
    • 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:
      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:
      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:
      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:
      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:
      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:
      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:
      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.
    • 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 ReadOnlyColorRGBA getConstantColor()
      Returns:
      the color used in constant blending functions. (0,0,0,0) is the default.
    • setConstantColor

      public void setConstantColor(ReadOnlyColorRGBA constantColor)
    • isSampleAlphaToCoverageEnabled

      public boolean isSampleAlphaToCoverageEnabled()
    • setSampleAlphaToCoverageEnabled

      public void setSampleAlphaToCoverageEnabled(boolean sampleAlphaToCoverageEnabled)
    • isSampleAlphaToOneEnabled

      public boolean isSampleAlphaToOneEnabled()
    • setSampleAlphaToOneEnabled

      public void setSampleAlphaToOneEnabled(boolean sampleAlphaToOneEnabled)
    • isSampleCoverageEnabled

      public boolean isSampleCoverageEnabled()
    • setSampleCoverageEnabled

      public void setSampleCoverageEnabled(boolean sampleCoverageEnabled)
    • getSampleCoverage

      public float getSampleCoverage()
    • setSampleCoverage

      public void setSampleCoverage(float value)
      Parameters:
      value - new sample coverage value - must be in range [0f, 1f]
      Throws:
      IllegalArgumentException - if value is not in correct range.
    • isSampleCoverageInverted

      public boolean isSampleCoverageInverted()
    • setSampleCoverageInverted

      public void setSampleCoverageInverted(boolean sampleCoverageInverted)
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class RenderState
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class RenderState
      Throws:
      IOException
    • createStateRecord

      public StateRecord createStateRecord(ContextCapabilities caps)
      Specified by:
      createStateRecord in class RenderState