j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class BlendAttributes

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.NodeComponent
          extended byorg.j3d.aviatrix3d.BlendAttributes
All Implemented Interfaces:
java.lang.Comparable, Renderable, RenderableObject

public class BlendAttributes
extends NodeComponent
implements java.lang.Comparable, RenderableObject

Describes attributes used for blending any drawing primitives.

The default blending mode is set up to mimic the defaults used by OpenGL.

Note: If you have semi-transparent objects that need blending, you do not need to provide an instance of this class. Aviatrix3D will internally handle the correct settings that you need, so there is no need to provide your own. Only use this when you want to blend objects with something different than the standard blending setup for non-transparent and transparent objects as it will remove this object from the normal transparency sorting processing and into a separate state.

Default Values

When intialised, this class follows the default OpenGL values for blending:

 Blend Equation:    EQ_FUNC_ADD
 RGB Source Mode:   BLEND_SRC_COLOR
 RGB Dest Mode:     BLEND_ONE_MINUS_SRC_COLOR
 Alpha Source Mode: BLEND_SRC_ALPHA
 Alpha Dest Mode:   BLEND_ONE_MINUS_SRC_ALPHA
 Separated Blend:   false
 Blend colour not set
 

Version:
$Revision: 1.7 $
Author:
Justin Couch

Field Summary
static int BLEND_CONSTANT_ALPHA
          Set the blend factor to use the provided constant alpha value.The constant colour value is provide through the setBlendColour() method.
static int BLEND_CONSTANT_COLOR
          Set the blend factor to use the provided constant colour.
static int BLEND_DEST_ALPHA
          Set the blend factor to use the destination object's alpha value
static int BLEND_DEST_COLOR
          Set the blend factor to use the destination object colour
static int BLEND_ONE
          Set the blend factor to ones.
static int BLEND_ONE_MINUS_CONSTANT_ALPHA
          Set the blend factor to use one minus the constant colour alpha value (1-c).
static int BLEND_ONE_MINUS_CONSTANT_COLOR
          Set the blend factor to use one minus the constant colour (1-c).
static int BLEND_ONE_MINUS_DEST_ALPHA
          Set the blend factor to use one minus the destination object alpha value (1-dest).
static int BLEND_ONE_MINUS_DEST_COLOR
          Set the blend factor to use one minus the destination object colour (1-dest).
static int BLEND_ONE_MINUS_SRC_ALPHA
          Set the blend factor to use one minus source object alpha value (1-src).
static int BLEND_ONE_MINUS_SRC_COLOR
          Set the blend factor to use one minus source object colour (1-src).
static int BLEND_SRC_ALPHA
          Set the blend factor to use the source object's alpha value
static int BLEND_SRC_ALPHA_SATURATE
          Set the blend function to saturage the colour value using the alpha state.
static int BLEND_SRC_COLOR
          Set the blend factor to use the source object colour
static int BLEND_ZERO
          Set the blend factor to zeros.
static int EQ_FUNC_ADD
          Set the blending equation to be CsS + CdD
static int EQ_FUNC_MAX
          Set the blending equation to be max(CdD, CsS)
static int EQ_FUNC_MIN
          Set the blending equation to be min(CdD, CsS)
static int EQ_FUNC_SUBTRACT
          Set the blending equation to be CsS - CdD
static int EQ_FUNC_SUBTRACT_REVERSE
          Set the blending equation to be CdD - CsS
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
Constructor Summary
BlendAttributes()
          Constructs a attribute set with default values as specified above.
 
Method Summary
 int compareTo(BlendAttributes ba)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(BlendAttributes ba)
          Compares this object with the specified object to check for equivalence.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 int getAlphaDestinationBlendFactor()
          Request the currently set destination blend factor for the alpha component.
 int getAlphaSourceBlendFactor()
          Request the currently set source blend factor for the alpha component.
 void getBlendColor(float[] col)
          Get the current blend colour.
 int getDestinationBlendFactor()
          Request the currently set destination blend factor.
 boolean getSeparatedBlendFactors()
          Check to see the current state of whether separated blending is used or not.
 int getSourceBlendFactor()
          Request the currently set source blend factor.
 void postRender(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Restore all openGL state to the given drawable.
 void render(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Issue ogl commands needed for this component
 void setAlphaDestinationBlendFactor(int factor)
          Set the destination blend factor to use.
 void setAlphaSourceBlendFactor(int factor)
          Set the source blend factor to use.
 void setBlendColor(float r, float g, float b, float a)
          Set the blend colour to use for this texture.
 void setDestinationBlendFactor(int factor)
          Set the destination blend factor to use.
 void setSeparatedBlendFactors(boolean state)
          Instruct the system whether to use separated RGB and Alpha blending functions.
 void setSourceBlendFactor(int factor)
          Set the source blend factor to use.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, hasChanged, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLEND_ZERO

public static final int BLEND_ZERO
Set the blend factor to zeros.

See Also:
Constant Field Values

BLEND_ONE

public static final int BLEND_ONE
Set the blend factor to ones.

See Also:
Constant Field Values

BLEND_SRC_COLOR

public static final int BLEND_SRC_COLOR
Set the blend factor to use the source object colour

See Also:
Constant Field Values

BLEND_ONE_MINUS_SRC_COLOR

public static final int BLEND_ONE_MINUS_SRC_COLOR
Set the blend factor to use one minus source object colour (1-src).

See Also:
Constant Field Values

BLEND_DEST_COLOR

public static final int BLEND_DEST_COLOR
Set the blend factor to use the destination object colour

See Also:
Constant Field Values

BLEND_ONE_MINUS_DEST_COLOR

public static final int BLEND_ONE_MINUS_DEST_COLOR
Set the blend factor to use one minus the destination object colour (1-dest).

See Also:
Constant Field Values

BLEND_SRC_ALPHA

public static final int BLEND_SRC_ALPHA
Set the blend factor to use the source object's alpha value

See Also:
Constant Field Values

BLEND_ONE_MINUS_SRC_ALPHA

public static final int BLEND_ONE_MINUS_SRC_ALPHA
Set the blend factor to use one minus source object alpha value (1-src).

See Also:
Constant Field Values

BLEND_DEST_ALPHA

public static final int BLEND_DEST_ALPHA
Set the blend factor to use the destination object's alpha value

See Also:
Constant Field Values

BLEND_ONE_MINUS_DEST_ALPHA

public static final int BLEND_ONE_MINUS_DEST_ALPHA
Set the blend factor to use one minus the destination object alpha value (1-dest).

See Also:
Constant Field Values

BLEND_CONSTANT_COLOR

public static final int BLEND_CONSTANT_COLOR
Set the blend factor to use the provided constant colour. The constant colour value is provide through the setBlendColour() method.

See Also:
Constant Field Values

BLEND_ONE_MINUS_CONSTANT_COLOR

public static final int BLEND_ONE_MINUS_CONSTANT_COLOR
Set the blend factor to use one minus the constant colour (1-c). The constant colour value is provide through the setBlendColour() method.

See Also:
Constant Field Values

BLEND_CONSTANT_ALPHA

public static final int BLEND_CONSTANT_ALPHA
Set the blend factor to use the provided constant alpha value.The constant colour value is provide through the setBlendColour() method.

See Also:
Constant Field Values

BLEND_ONE_MINUS_CONSTANT_ALPHA

public static final int BLEND_ONE_MINUS_CONSTANT_ALPHA
Set the blend factor to use one minus the constant colour alpha value (1-c). The constant colour value is provide through the setBlendColour() method.

See Also:
Constant Field Values

BLEND_SRC_ALPHA_SATURATE

public static final int BLEND_SRC_ALPHA_SATURATE
Set the blend function to saturage the colour value using the alpha state. The RGB value is calculated using the min(Asrc, 1 - Adest). The alpha value is treated as equivalent to GL_ONE. Can only be used as the source blend factor. An error will be generated if you try to use this for the destination factor.

See Also:
Constant Field Values

EQ_FUNC_ADD

public static final int EQ_FUNC_ADD
Set the blending equation to be CsS + CdD

See Also:
Constant Field Values

EQ_FUNC_SUBTRACT

public static final int EQ_FUNC_SUBTRACT
Set the blending equation to be CsS - CdD

See Also:
Constant Field Values

EQ_FUNC_SUBTRACT_REVERSE

public static final int EQ_FUNC_SUBTRACT_REVERSE
Set the blending equation to be CdD - CsS

See Also:
Constant Field Values

EQ_FUNC_MIN

public static final int EQ_FUNC_MIN
Set the blending equation to be min(CdD, CsS)

See Also:
Constant Field Values

EQ_FUNC_MAX

public static final int EQ_FUNC_MAX
Set the blending equation to be max(CdD, CsS)

See Also:
Constant Field Values
Constructor Detail

BlendAttributes

public BlendAttributes()
Constructs a attribute set with default values as specified above.

Method Detail

render

public void render(net.java.games.jogl.GL gl,
                   net.java.games.jogl.GLU glu)
Issue ogl commands needed for this component

Specified by:
render in interface RenderableObject
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

postRender

public void postRender(net.java.games.jogl.GL gl,
                       net.java.games.jogl.GLU glu)
Restore all openGL state to the given drawable. Does nothing as it assumes the system will disable blending outside of this class.

Specified by:
postRender in interface RenderableObject
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objec to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setSourceBlendFactor

public void setSourceBlendFactor(int factor)
                          throws InvalidWriteTimingException
Set the source blend factor to use. Used for both non-separated blending and the RGB component when separated.

Parameters:
factor - The value to set for the factor
Throws:
java.lang.IllegalArgumentException - The blend factor is not one of the permitted types
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getSourceBlendFactor

public int getSourceBlendFactor()
Request the currently set source blend factor.

Returns:
One of the BLEND_* constant values

setDestinationBlendFactor

public void setDestinationBlendFactor(int factor)
                               throws InvalidWriteTimingException
Set the destination blend factor to use. Used for both non-separated blending and the RGB component when separated.

Parameters:
factor - The value to set for the factor
Throws:
java.lang.IllegalArgumentException - The blend factor is not one of the permitted types or is SRC_ALPHA_SATURATED
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getDestinationBlendFactor

public int getDestinationBlendFactor()
Request the currently set destination blend factor.

Returns:
One of the BLEND_* constant values

setAlphaSourceBlendFactor

public void setAlphaSourceBlendFactor(int factor)
                               throws InvalidWriteTimingException
Set the source blend factor to use. Only used for seperated blending mode's alpha component. If non-separated mode is used, this setting is ignored.

Parameters:
factor - The value to set for the factor
Throws:
java.lang.IllegalArgumentException - The blend factor is not one of the permitted types
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getAlphaSourceBlendFactor

public int getAlphaSourceBlendFactor()
Request the currently set source blend factor for the alpha component.

Returns:
One of the BLEND_* constant values

setAlphaDestinationBlendFactor

public void setAlphaDestinationBlendFactor(int factor)
                                    throws InvalidWriteTimingException
Set the destination blend factor to use. Only used for seperated blending mode's alpha component. If non-separated mode is used, this setting is ignored.

Parameters:
factor - The value to set for the factor
Throws:
java.lang.IllegalArgumentException - The blend factor is not one of the permitted types or is SRC_ALPHA_SATURATED
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getAlphaDestinationBlendFactor

public int getAlphaDestinationBlendFactor()
Request the currently set destination blend factor for the alpha component.

Returns:
One of the BLEND_* constant values

setSeparatedBlendFactors

public void setSeparatedBlendFactors(boolean state)
                              throws InvalidWriteTimingException
Instruct the system whether to use separated RGB and Alpha blending functions. By default this is not enabled, but may be turned on or off using this method.

Parameters:
state - True to enable the use of separate RGB and alpha blending
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getSeparatedBlendFactors

public boolean getSeparatedBlendFactors()
Check to see the current state of whether separated blending is used or not.

Returns:
true if separated RGB and Alpha blending is used

setBlendColor

public void setBlendColor(float r,
                          float g,
                          float b,
                          float a)
                   throws InvalidWriteTimingException
Set the blend colour to use for this texture. Blend is a 4-component colour value.

Parameters:
r - The red component of the blend colour
g - The green component of the blend colour
b - The blue component of the blend colour
a - The alpha component of the blend colour
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getBlendColor

public void getBlendColor(float[] col)
Get the current blend colour. If it hasn't been set previously, the call is ignored.

Parameters:
col - An array to copy the colour in, in RGBA format

compareTo

public int compareTo(BlendAttributes ba)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
ba - The attributes instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(BlendAttributes ba)
Compares this object with the specified object to check for equivalence.

Parameters:
ba - The attributes instance to be compared
Returns:
true if the objects represent identical values

j3d.org Aviatrix3D

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - j3d.org