Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class DepthBufferState

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.BufferState
          extended by org.j3d.aviatrix3d.DepthBufferState
All Implemented Interfaces:
java.lang.Comparable, BufferStateRenderable, Renderable

public class DepthBufferState
extends BufferState
implements BufferStateRenderable

Describes attributes used when interacting with the depth buffer.

Including this state class in the global setup automatically enables depth testing and the depth buffer. If an instance of this state is not included in the scene, the default values, and depth testing are enabled automatically. Use this class to override the defaults, or to deliberately disable depth testing.

The default setup for this class is:

Internationalisation Resource Names

Version:
$Revision: 2.8 $
Author:
Justin Couch

Field Summary
static int FUNCTION_ALWAYS
          Comparison function that always passes.
static int FUNCTION_EQUAL
          Comparison function that passes if current depth == range.
static int FUNCTION_GREATER
          Comparison function that passes if current depth > range.
static int FUNCTION_GREATER_OR_EQUAL
          Comparison function that passes if current depth >= range.
static int FUNCTION_LESS
          Comparison function that passes if current depth < range.
static int FUNCTION_LESS_OR_EQUAL
          Comparison function that passes if current depth <= range.
static int FUNCTION_NEVER
          Comparison function that always fails.
static int FUNCTION_NOTEQUAL
          Comparison function that passes if current depth is not equal range.
 
Fields inherited from class org.j3d.aviatrix3d.BufferState
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.BufferStateRenderable
ACCUMULATION_BUFFER, COLOR_BUFFER, DEPTH_BUFFER, GENERAL_BUFFER, STENCIL_BUFFER
 
Constructor Summary
DepthBufferState()
          Constructs a state set with default values.
 
Method Summary
 boolean checkClearBufferState()
          Check to see if this buffer should be cleared at the start of this run.
 void clearBufferState(javax.media.opengl.GL gl)
          Restore all state to the default values.
 int compareTo(DepthBufferState dbs)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 void enableDepthTest(boolean test)
          Set the flag for whether the depth testing should be enabled or disabled.
 void enableDepthWrite(boolean write)
          Set the flag for whether the depth writing should be enabled or disabled.
 boolean equals(DepthBufferState dbs)
          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 getBufferBitMask()
          Get the GL buffer bit flag that this state class represents.
 int getBufferType()
          Get the type of buffer this state represents.
 float getClearDepth()
          Get the current depth used when clearing the depth buffer.
 int getDepthFunction()
          Get the current operation used when the depth tests pass.
 float getMaxRange()
          Get the current minimum depth range
 float getMinRange()
          Get the current minimum depth range
 boolean isDepthTestEnabled()
          Check to see if depth testing is currently enabled.
 boolean isDepthWriteEnabled()
          Check to see if depth writing is currently enabled.
 void setBufferState(javax.media.opengl.GL gl)
          Issue ogl commands needed for this buffer to set the initial state, including the initial enabling.
 void setClearBufferState(boolean clear)
          Set the flag for whether the buffer state should be cleared when this state object is executed.
 void setClearDepth(float depth)
          Set depth value that the buffer should be cleared to.
 void setDepthFunction(int func)
          Set the operation that should be performed if the depth tests pass.
 void setMaxRange(float depth)
          Set maximum depth value that is acceptable to be rendered.
 void setMinRange(float depth)
          Set minimum depth value that is acceptable to be rendered.
 void updateBufferState(javax.media.opengl.GL gl)
          Issue ogl commands needed for this component to change the state, assuming that it is already enabled.
 
Methods inherited from class org.j3d.aviatrix3d.BufferState
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

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 current depth < range.

See Also:
Constant Field Values

FUNCTION_LESS_OR_EQUAL

public static final int FUNCTION_LESS_OR_EQUAL
Comparison function that passes if current depth <= range.

See Also:
Constant Field Values

FUNCTION_GREATER

public static final int FUNCTION_GREATER
Comparison function that passes if current depth > range.

See Also:
Constant Field Values

FUNCTION_GREATER_OR_EQUAL

public static final int FUNCTION_GREATER_OR_EQUAL
Comparison function that passes if current depth >= range.

See Also:
Constant Field Values

FUNCTION_EQUAL

public static final int FUNCTION_EQUAL
Comparison function that passes if current depth == range.

See Also:
Constant Field Values

FUNCTION_NOTEQUAL

public static final int FUNCTION_NOTEQUAL
Comparison function that passes if current depth is not equal range.

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

DepthBufferState

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

Method Detail

getBufferType

public int getBufferType()
Get the type of buffer this state represents.

Specified by:
getBufferType in interface BufferStateRenderable
Returns:
One of the _BUFFER constants

getBufferBitMask

public int getBufferBitMask()
Get the GL buffer bit flag that this state class represents. Used for bulk clearing all the states at once.

Specified by:
getBufferBitMask in interface BufferStateRenderable
Returns:
The bit state constant for Stencil Buffers

checkClearBufferState

public boolean checkClearBufferState()
Check to see if this buffer should be cleared at the start of this run. If it should be, add the bit mask from this state to the global list.

Specified by:
checkClearBufferState in interface BufferStateRenderable
Returns:
true if the state should be cleared

setBufferState

public void setBufferState(javax.media.opengl.GL gl)
Issue ogl commands needed for this buffer to set the initial state, including the initial enabling.

Specified by:
setBufferState in interface BufferStateRenderable
Parameters:
gl - The gl context to draw with

updateBufferState

public void updateBufferState(javax.media.opengl.GL gl)
Issue ogl commands needed for this component to change the state, assuming that it is already enabled.

Specified by:
updateBufferState in interface BufferStateRenderable
Parameters:
gl - The gl context to draw with

clearBufferState

public void clearBufferState(javax.media.opengl.GL gl)
Restore all state to the default values.

Specified by:
clearBufferState in interface BufferStateRenderable
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

setClearBufferState

public void setClearBufferState(boolean clear)
                         throws InvalidWriteTimingException
Set the flag for whether the buffer state should be cleared when this state object is executed.

Parameters:
clear - True if the buffer should be cleared when this is the first state to be used in the current operation
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

enableDepthTest

public void enableDepthTest(boolean test)
                     throws InvalidWriteTimingException
Set the flag for whether the depth testing should be enabled or disabled.

Parameters:
test - True if testing should be enabled state to be used in the current operation
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isDepthTestEnabled

public boolean isDepthTestEnabled()
Check to see if depth testing is currently enabled.

Returns:
true when testing is enabled

enableDepthWrite

public void enableDepthWrite(boolean write)
                      throws InvalidWriteTimingException
Set the flag for whether the depth writing should be enabled or disabled.

Parameters:
write - True if writing should be enabled state to be used in the current operation
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isDepthWriteEnabled

public boolean isDepthWriteEnabled()
Check to see if depth writing is currently enabled.

Returns:
true when writing is enabled

setMinRange

public void setMinRange(float depth)
                 throws java.lang.IllegalArgumentException,
                        InvalidWriteTimingException
Set minimum depth value that is acceptable to be rendered. The values must be between zero and one. It is not required that the minimum range be less than the max range.

Parameters:
depth - A distance between 0 and 1
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The value provided was out of range

getMinRange

public float getMinRange()
Get the current minimum depth range

Returns:
A value between 0 and 1

setMaxRange

public void setMaxRange(float depth)
                 throws java.lang.IllegalArgumentException,
                        InvalidWriteTimingException
Set maximum depth value that is acceptable to be rendered. The values must be between zero and one. It is not required that the minimum range be less than the max range.

Parameters:
depth - A distance between 0 and 1
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The value provided was out of range

getMaxRange

public float getMaxRange()
Get the current minimum depth range

Returns:
A value between 0 and 1

setClearDepth

public void setClearDepth(float depth)
                   throws java.lang.IllegalArgumentException,
                          InvalidWriteTimingException
Set depth value that the buffer should be cleared to. The default value is 1.

Parameters:
depth - A distance between 0 and 1
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method
java.lang.IllegalArgumentException - The value provided was out of range

getClearDepth

public float getClearDepth()
Get the current depth used when clearing the depth buffer.

Returns:
A value between 0 and 1

setDepthFunction

public void setDepthFunction(int func)
                      throws java.lang.IllegalArgumentException,
                             InvalidWriteTimingException
Set the operation that should be performed if the 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.

getDepthFunction

public int getDepthFunction()
Get the current operation used when the depth tests pass.

Returns:
One of the FUNCTION_ constants

compareTo

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

equals

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

Parameters:
dbs - 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