com.jme.scene.state
Class StencilState

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

public abstract class StencilState
extends RenderState

The StencilState RenderState allows the user to set the attributes of the stencil buffer of the renderer. The Stenciling is similar to Z-Buffering in that it allows enabling and disabling drawing on a per pixel basis. You can use the stencil plane to mask out portions of the rendering to create special effects, such as outlining or planar shadows.

Version:
$id$
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
static int SF_ALWAYS
          A stencil function that always passes.
static int SF_EQUAL
          A stencil function that passes if (ref & max) == (stencil & mask).
static int SF_GEQUAL
          A stencil function that passes if (ref & max) >= (stencil & mask).
static int SF_GREATER
          A stencil function that passes if (ref & max) > (stencil & mask).
static int SF_LEQUAL
          A stencil function that passes if (ref & max) <= (stencil & mask).
static int SF_LESS
          A stencil function that passes if (ref & mask) < (stencil & mask).
static int SF_NEVER
          A stencil function that never passes.
static int SF_NOTEQUAL
          A stencil function that passes if (ref & max) != (stencil & mask).
static int SO_DECR
          A stencil function result that decrements the current stencil buffer value.
static int SO_INCR
          A stencil function result that increments the current stencil buffer value.
static int SO_INVERT
          A stencil function result that bitwise inverts the current stencil buffer value.
static int SO_KEEP
          A stencil function result that keeps the current value.
static int SO_REPLACE
          A stencil function result that sets the stencil buffer value to ref, as specified by stencil function.
static int SO_ZERO
          A stencil function result that sets the stencil buffer value to 0.
 
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
StencilState()
           
 
Method Summary
 int getStencilFunc()
          Returns the currently set stencil function.
 int getStencilMask()
          Returns the currently set stencil mask.
 int getStencilOpFail()
          Returns the current stencil operation.
 int getStencilOpZFail()
          Returns the current Z op fail function.
 int getStencilOpZPass()
          Returns the current Z op pass function.
 int getStencilRef()
          Returns the currently set stencil reference.
 int getType()
          Returns RS_STENCIL
 void setStencilFunc(int func)
          Sets the function that defines if a stencil test passes or not.
 void setStencilMask(int mask)
          Sets the stencil mask to be used during the stencil function.
 void setStencilOpFail(int op)
          Specifies the aciton to take when the stencil test fails.
 void setStencilOpZFail(int op)
          Specifies stencil action when the stencil test passes, but the depth test fails.
 void setStencilOpZPass(int op)
          Specifies stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled.
 void setStencilRef(int ref)
          Sets the stencil reference to be used during the stencil function.
 
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

SF_NEVER

public static final int SF_NEVER
A stencil function that never passes.

See Also:
Constant Field Values

SF_LESS

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

See Also:
Constant Field Values

SF_LEQUAL

public static final int SF_LEQUAL
A stencil function that passes if (ref & max) <= (stencil & mask).

See Also:
Constant Field Values

SF_GREATER

public static final int SF_GREATER
A stencil function that passes if (ref & max) > (stencil & mask).

See Also:
Constant Field Values

SF_GEQUAL

public static final int SF_GEQUAL
A stencil function that passes if (ref & max) >= (stencil & mask).

See Also:
Constant Field Values

SF_EQUAL

public static final int SF_EQUAL
A stencil function that passes if (ref & max) == (stencil & mask).

See Also:
Constant Field Values

SF_NOTEQUAL

public static final int SF_NOTEQUAL
A stencil function that passes if (ref & max) != (stencil & mask).

See Also:
Constant Field Values

SF_ALWAYS

public static final int SF_ALWAYS
A stencil function that always passes.

See Also:
Constant Field Values

SO_KEEP

public static final int SO_KEEP
A stencil function result that keeps the current value.

See Also:
Constant Field Values

SO_ZERO

public static final int SO_ZERO
A stencil function result that sets the stencil buffer value to 0.

See Also:
Constant Field Values

SO_REPLACE

public static final int SO_REPLACE
A stencil function result that sets the stencil buffer value to ref, as specified by stencil function.

See Also:
Constant Field Values

SO_INCR

public static final int SO_INCR
A stencil function result that increments the current stencil buffer value.

See Also:
Constant Field Values

SO_DECR

public static final int SO_DECR
A stencil function result that decrements the current stencil buffer value.

See Also:
Constant Field Values

SO_INVERT

public static final int SO_INVERT
A stencil function result that bitwise inverts the current stencil buffer value.

See Also:
Constant Field Values
Constructor Detail

StencilState

public StencilState()
Method Detail

getType

public int getType()
Returns RS_STENCIL

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

setStencilFunc

public void setStencilFunc(int func)
Sets the function that defines if a stencil test passes or not.

Parameters:
func - The new stencil function.

getStencilFunc

public int getStencilFunc()
Returns the currently set stencil function.

Returns:
The current stencil function.

setStencilRef

public void setStencilRef(int ref)
Sets the stencil reference to be used during the stencil function.

Parameters:
ref - The new stencil reference.

getStencilRef

public int getStencilRef()
Returns the currently set stencil reference.

Returns:
The current stencil reference.

setStencilMask

public void setStencilMask(int mask)
Sets the stencil mask to be used during the stencil function.

Parameters:
mask - The new stencil mask.

getStencilMask

public int getStencilMask()
Returns the currently set stencil mask.

Returns:
The current stencil mask.

setStencilOpFail

public void setStencilOpFail(int op)
Specifies the aciton to take when the stencil test fails. One of SO_KEEP, SO_ZERO, and so on.

Parameters:
op - The new stencil operation.

getStencilOpFail

public int getStencilOpFail()
Returns the current stencil operation.

Returns:
The current stencil operation.

setStencilOpZFail

public void setStencilOpZFail(int op)
Specifies stencil action when the stencil test passes, but the depth test fails. One of SO_KEEP, SO_ZERO, and so on.

Parameters:
op - The Z test operation to set.

getStencilOpZFail

public int getStencilOpZFail()
Returns the current Z op fail function.

Returns:
The current Z op fail function.

setStencilOpZPass

public void setStencilOpZPass(int op)
Specifies stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled. One of SO_KEEP, SO_ZERO, and so on.

Parameters:
op - The new Z test pass operation to set.

getStencilOpZPass

public int getStencilOpZPass()
Returns the current Z op pass function.

Returns:
The current Z op pass function.