Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class AccumulationBufferState

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

public class AccumulationBufferState
extends BufferState
implements BufferStateRenderable

Describes attributes used when interacting with the accumulation buffer.

Including this state class in the global setup automatically enables the accumulation buffer. It also has a slightly special status in that, unlike the other buffer types, the state is executed at the end of the rendering pass rather than at the beginning. That is because accumulation buffers are used to take the current colour buffer and copy it into the accumulation buffer using one of a set of functions (or copy the accumulation buffer back to the colour buffer in the case of GL_RETURN).

The default setup for this class is:

Internationalisation Resource Names

Version:
$Revision: 2.5 $
Author:
Justin Couch

Field Summary
static int FUNCTION_ACCUMULATE
          Take the current buffer colours multiply them by value and then add with the accumulation buffer.
static int FUNCTION_ADD
          Add the value to the current accumulation buffer values.
static int FUNCTION_LOAD
          Replace the values in the accumulation buffer with the current colours
static int FUNCTION_MULTIPLY
          Multiply the contents of the current buffer by the value.
 
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
AccumulationBufferState()
          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 and copy the buffer to the colour buffer.
 int compareTo(AccumulationBufferState abs)
          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(AccumulationBufferState abs)
          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 getAccumFunction()
          Get the current operation used when accumulating colour values.
 float getAlpha()
          Get the current alpha channel clear value
 float getBlue()
          Get the current blue channel clear value
 int getBufferBitMask()
          Get the GL buffer bit flag that this state class represents.
 int getBufferType()
          Get the type of buffer this state represents.
 float getGreen()
          Get the current green channel clear value
 float getRed()
          Get the current red channel clear value
 float getValue()
          Get the value operand used with some of the function types.
 void setAccumFunction(int func)
          Set the operation that should be performed when accumulating colour values into the accumulation buffer.
 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 setClearColor(float red, float green, float blue, float alpha)
          Set the value that each of the colour channels should be cleared to.
 void setValue(float val)
          Set the value that accompanies some of the operation types.
 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_ACCUMULATE

public static final int FUNCTION_ACCUMULATE
Take the current buffer colours multiply them by value and then add with the accumulation buffer.

See Also:
Constant Field Values

FUNCTION_LOAD

public static final int FUNCTION_LOAD
Replace the values in the accumulation buffer with the current colours

See Also:
Constant Field Values

FUNCTION_ADD

public static final int FUNCTION_ADD
Add the value to the current accumulation buffer values.

See Also:
Constant Field Values

FUNCTION_MULTIPLY

public static final int FUNCTION_MULTIPLY
Multiply the contents of the current buffer by the value. Note that for this function, the value is clamped to [-1, 1] by OpenGL.

See Also:
Constant Field Values
Constructor Detail

AccumulationBufferState

public AccumulationBufferState()
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 and copy the buffer to the colour buffer.

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 update callback method

setAccumFunction

public void setAccumFunction(int func)
                      throws java.lang.IllegalArgumentException,
                             InvalidWriteTimingException
Set the operation that should be performed when accumulating colour values into the accumulation buffer. 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 update callback method
java.lang.IllegalArgumentException - The operation value was not one of the valid types.

getAccumFunction

public int getAccumFunction()
Get the current operation used when accumulating colour values.

Returns:
One of the FUNCTION_ constants

setValue

public void setValue(float val)
              throws java.lang.IllegalArgumentException,
                     InvalidWriteTimingException
Set the value that accompanies some of the operation types. Consult the docs for individual functions for how the value may be used.

Parameters:
val - An arbitrary value defined by the user
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data update callback method
java.lang.IllegalArgumentException

getValue

public float getValue()
Get the value operand used with some of the function types.

Returns:
Any arbitrary value set by the user

setClearColor

public void setClearColor(float red,
                          float green,
                          float blue,
                          float alpha)
                   throws InvalidWriteTimingException
Set the value that each of the colour channels should be cleared to. The values are automatically clamped by OpenGL to the range [-1,1].

Parameters:
red - The red channel clear value
green - The green channel clear value
blue - The blue channel clear value
alpha - The alpha channel clear value
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data update callback method

getRed

public float getRed()
Get the current red channel clear value

Returns:
The current red channel clear value [-1,1]

getGreen

public float getGreen()
Get the current green channel clear value

Returns:
The current green channel clear value [-1,1]

getBlue

public float getBlue()
Get the current blue channel clear value

Returns:
The current blue channel clear value [-1,1]

getAlpha

public float getAlpha()
Get the current alpha channel clear value

Returns:
The current alpha channel clear value [-1,1]

compareTo

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

equals

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

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