Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class StencilAttributes

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.StencilAttributes
All Implemented Interfaces:
java.lang.Comparable, AppearanceAttributeRenderable, ObjectRenderable, Renderable

public class StencilAttributes
extends NodeComponent
implements AppearanceAttributeRenderable

Describes attributes used when interacting with the stencil buffer.

Including this state class in the global setup automatically enables stencil testing and the stencil buffer.

The default setup for this class is:

Internationalisation Resource Names

Version:
$Revision: 1.5 $
Author:
Justin Couch

Field Summary
static int FUNCTION_ALWAYS
          Comparison function that always passes.
static int FUNCTION_EQUAL
          Comparison function that passes if (ref & mask) == (stencil & mask).
static int FUNCTION_GREATER
          Comparison function that passes if (ref & mask) > (stencil & mask).
static int FUNCTION_GREATER_OR_EQUAL
          Comparison function that passes if (ref & mask) >= (stencil & mask).
static int FUNCTION_LESS
          Comparison function that passes if (ref & mask) < (stencil & mask).
static int FUNCTION_LESS_OR_EQUAL
          Comparison function that passes if (ref & mask) <= (stencil & mask).
static int FUNCTION_NEVER
          Comparison function that always fails.
static int FUNCTION_NOTEQUAL
          Comparison function that passes if (ref & mask) not equal to (stencil & mask).
static short STENCIL_DECREMENT
          When the stencil function matches, decrement the stencil value.
static short STENCIL_INCREMENT
          When the stencil function matches, increment the stencil value.
static short STENCIL_INVERT
          When the stencil function matches, bitwise invert the stencil value.
static short STENCIL_KEEP
          When the stencil function matches, keep the current stencil value.
static short STENCIL_REPLACE
          When the stencil function matches, set the stencil value to the reference value.
static short STENCIL_ZERO
          When the stencil function matches, set the stencil value to zero.
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount, parentList
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.AppearanceAttributeRenderable
ALPHA_ATTRIBUTE, BLEND_ATTRIBUTE, DEPTH_ATTRIBUTE, LINE_ATTRIBUTE, POINT_ATTRIBUTE, POLYGON_ATTRIBUTE, STENCIL_ATTRIBUTE
 
Constructor Summary
StencilAttributes()
          Constructs a state set with default values.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(StencilAttributes sbs)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 boolean equals(StencilAttributes sbs)
          Compares this object with the specified object to check for equivalence.
 int getAttributeType()
          Get the type this visual attribute represents.
 int getDepthFailOperation()
          Get the current operation used when the stencil test passes, but depth test fails.
 int getDepthPassOperation()
          Get the current operation used when the stencil and depth tests pass.
 int getFunctionCompareMask()
          Get the current function comparison mask.
 int getFunctionReferenceValue()
          Get the current stencil reference value for use in the stencil function setup.
 int getStencilFailOperation()
          Get the current function comparison mask.
 int getStencilFunction()
          Get the function type used when the stencil and depth tests pass.
 int getStencilWriteMask()
          Get the current write mask.
 void postRender(javax.media.opengl.GL gl)
          Restore all openGL state to the given drawable.
 void render(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component
 void setDepthFailOperation(int op)
          Set the operation that should be performed if the stencil test passes but the depth test fails.
 void setDepthPassOperation(int op)
          Set the operation that should be performed if the stencil and depth tests pass.
 void setFunctionCompareMask(int mask)
          Set the bitmask used for the stencil comparison operation.
 void setFunctionReferenceValue(int value)
          Set the reference value used for the stencil comparison operation.
 void setStencilFailOperation(int op)
          Set the operation that should be performed if the stencil test fails.
 void setStencilFunction(int func)
          Set the operation that should be performed if the stencil and depth tests pass.
 void setStencilWriteMask(int mask)
          Set the bitmask used for the stencil write operation.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STENCIL_INCREMENT

public static final short STENCIL_INCREMENT
When the stencil function matches, increment the stencil value.

See Also:
Constant Field Values

STENCIL_DECREMENT

public static final short STENCIL_DECREMENT
When the stencil function matches, decrement the stencil value.

See Also:
Constant Field Values

STENCIL_KEEP

public static final short STENCIL_KEEP
When the stencil function matches, keep the current stencil value.

See Also:
Constant Field Values

STENCIL_INVERT

public static final short STENCIL_INVERT
When the stencil function matches, bitwise invert the stencil value.

See Also:
Constant Field Values

STENCIL_ZERO

public static final short STENCIL_ZERO
When the stencil function matches, set the stencil value to zero.

See Also:
Constant Field Values

STENCIL_REPLACE

public static final short STENCIL_REPLACE
When the stencil function matches, set the stencil value to the reference value.

See Also:
Constant Field Values

FUNCTION_NEVER

public static final int FUNCTION_NEVER
Comparison function that always fails.

See Also:
Constant Field Values

FUNCTION_LESS

public static final int FUNCTION_LESS
Comparison function that passes if (ref & mask) < (stencil & mask).

See Also:
Constant Field Values

FUNCTION_LESS_OR_EQUAL

public static final int FUNCTION_LESS_OR_EQUAL
Comparison function that passes if (ref & mask) <= (stencil & mask).

See Also:
Constant Field Values

FUNCTION_GREATER

public static final int FUNCTION_GREATER
Comparison function that passes if (ref & mask) > (stencil & mask).

See Also:
Constant Field Values

FUNCTION_GREATER_OR_EQUAL

public static final int FUNCTION_GREATER_OR_EQUAL
Comparison function that passes if (ref & mask) >= (stencil & mask).

See Also:
Constant Field Values

FUNCTION_EQUAL

public static final int FUNCTION_EQUAL
Comparison function that passes if (ref & mask) == (stencil & mask).

See Also:
Constant Field Values

FUNCTION_NOTEQUAL

public static final int FUNCTION_NOTEQUAL
Comparison function that passes if (ref & mask) not equal to (stencil & mask).

See Also:
Constant Field Values

FUNCTION_ALWAYS

public static final int FUNCTION_ALWAYS
Comparison function that always passes.

See Also:
Constant Field Values
Constructor Detail

StencilAttributes

public StencilAttributes()
Constructs a state set with default values.

Method Detail

getAttributeType

public int getAttributeType()
Get the type this visual attribute represents.

Specified by:
getAttributeType in interface AppearanceAttributeRenderable
Returns:
One of the _ATTRIBUTE constants

render

public void render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component

Specified by:
render in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
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 ObjectRenderable
Parameters:
gl - The gl 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.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setFunctionCompareMask

public void setFunctionCompareMask(int mask)
                            throws InvalidWriteTimingException
Set the bitmask used for the stencil comparison operation. Note that the the mask will only support the number of bits defined by the current hardware. Flags above the number of supported bit planes are ignored.

Parameters:
mask - The bit mask of planes to compare
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getFunctionCompareMask

public int getFunctionCompareMask()
Get the current function comparison mask.

Returns:
An integer bit flag.

setStencilWriteMask

public void setStencilWriteMask(int mask)
                         throws InvalidWriteTimingException
Set the bitmask used for the stencil write operation. Note that the the mask will only support the number of bits defined by the current hardware. Flags above the number of supported bit planes are ignored.

Parameters:
mask - The bit mask of planes to write when operations succeed
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getStencilWriteMask

public int getStencilWriteMask()
Get the current write mask.

Returns:
An integer bit flag.

setFunctionReferenceValue

public void setFunctionReferenceValue(int value)
                               throws InvalidWriteTimingException
Set the reference value used for the stencil comparison operation.

Parameters:
value - A value to compare for the depth testing
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getFunctionReferenceValue

public int getFunctionReferenceValue()
Get the current stencil reference value for use in the stencil function setup.

Returns:
An integer bit flag.

setStencilFailOperation

public void setStencilFailOperation(int op)
                             throws java.lang.IllegalArgumentException,
                                    InvalidWriteTimingException
Set the operation that should be performed if the stencil test fails. This should be one of the STENCIL_ constants at the top of this class.

Parameters:
op - One of the STENCIL_ constants
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The operation value was not one of the valid types.

getStencilFailOperation

public int getStencilFailOperation()
Get the current function comparison mask.

Returns:
An integer bit flag.

setDepthFailOperation

public void setDepthFailOperation(int op)
                           throws java.lang.IllegalArgumentException,
                                  InvalidWriteTimingException
Set the operation that should be performed if the stencil test passes but the depth test fails. This should be one of the STENCIL_ constants at the top of this class.

Parameters:
op - One of the STENCIL_ constants
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The operation value was not one of the valid types.

getDepthFailOperation

public int getDepthFailOperation()
Get the current operation used when the stencil test passes, but depth test fails.

Returns:
One of the STENCIL_ constants

setDepthPassOperation

public void setDepthPassOperation(int op)
                           throws java.lang.IllegalArgumentException,
                                  InvalidWriteTimingException
Set the operation that should be performed if the stencil and depth tests pass. This should be one of the STENCIL_ constants at the top of this class.

Parameters:
op - One of the STENCIL_ constants
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The operation value was not one of the valid types.

getDepthPassOperation

public int getDepthPassOperation()
Get the current operation used when the stencil and depth tests pass.

Returns:
One of the STENCIL_ constants

setStencilFunction

public void setStencilFunction(int func)
                        throws java.lang.IllegalArgumentException,
                               InvalidWriteTimingException
Set the operation that should be performed if the stencil and depth tests pass. This should be one of the FUNCTION_ constants at the top of this class.

Parameters:
func - One of the FUNCTION_ constants
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The operation value was not one of the valid types.

getStencilFunction

public int getStencilFunction()
Get the function type used when the stencil and depth tests pass.

Returns:
One of the FUNCTION constants

compareTo

public int compareTo(StencilAttributes sbs)
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:
sbs - The attributes instance to be comsbsred
Returns:
-1, 0 or 1 depending on order

equals

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

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

Aviatrix3D
2.1.0

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