com.jme.renderer.pass
Class Pass

java.lang.Object
  extended by com.jme.renderer.pass.Pass
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BloomRenderPass, DepthOfFieldRenderPass, DirectionalShadowMapPass, DynamicGammaPass, LightMaskedRenderPass, MotionBlurRenderPass, RenderPass, ShadowedRenderPass, SketchRenderPass, WaterRenderPass

public abstract class Pass
extends java.lang.Object
implements java.io.Serializable

Pass encapsulates logic necessary for rendering one or more steps in a multipass technique. Rendering: When renderPass is called, a check is first made to see if the pass isEnabled(). Then any states set on this pass are enforced via Spatial.enforceState(RenderState). This is useful for doing things such as causing this pass to be blended to a previous pass via enforcing an BlendState, etc. Next, doRender(Renderer) is called to do the actual rendering work. Finally, any enforced states set before this pass was run are restored.

Version:
$Id: Pass.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Joshua Slack
See Also:
Serialized Form

Field Summary
protected  RenderContext<?> context
           
protected  boolean enabled
          if false, pass will not be updated or rendered.
protected  RenderState[] passStates
          RenderStates registered with this pass - if a given state is not null it overrides the corresponding state set during rendering.
protected  RenderState[] savedStates
          a place to internally save previous states setup before rendering this pass
protected  java.util.ArrayList<Spatial> spatials
          list of spatials registered with this pass.
protected  float zFactor
          offset params to use to differentiate multiple passes of the same scene in the zbuffer.
protected  float zOffset
           
 
Constructor Summary
Pass()
           
 
Method Summary
 void add(Spatial toAdd)
           
protected  void applyPassStates()
           
 void cleanUp()
           
 void clearPassState(int renderStateType)
          Deprecated. As of 2.0, use clearPassState(com.jme.scene.state.RenderState.StateType) instead.
 void clearPassState(RenderState.StateType type)
          Clears an enforced render state by setting it to null.
 void clearPassStates()
          sets all enforced states to null.
 boolean contains(Spatial s)
           
protected abstract  void doRender(Renderer r)
           
protected  void doUpdate(float tpf)
           
 Spatial get(int index)
           
 RenderState getRenderState(int type)
          Deprecated. As of 2.0, use getRenderState(com.jme.scene.state.RenderState.StateType) instead.
 RenderState getRenderState(RenderState.StateType type)
          Returns the requested RenderState that this Pass currently has set or null if none is set.
 float getZFactor()
           
 float getZOffset()
           
 boolean isEnabled()
           
 boolean remove(Spatial toRemove)
           
 void removeAll()
           
 void renderPass(Renderer r)
          if enabled, set the states for this pass and then render.
protected  void resetOldStates()
           
 void setEnabled(boolean enabled)
           
 void setPassState(RenderState state)
          Enforce a particular state.
 void setZFactor(float factor)
          Sets the polygon offset param - factor - for this Pass.
 void setZOffset(float offset)
          Sets the polygon offset param - offset - for this Pass.
 int size()
           
 void updatePass(float tpf)
          if enabled, call doUpdate to update information for this pass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spatials

protected java.util.ArrayList<Spatial> spatials
list of spatials registered with this pass.


enabled

protected boolean enabled
if false, pass will not be updated or rendered.


zFactor

protected float zFactor
offset params to use to differentiate multiple passes of the same scene in the zbuffer.


zOffset

protected float zOffset

passStates

protected RenderState[] passStates
RenderStates registered with this pass - if a given state is not null it overrides the corresponding state set during rendering.


savedStates

protected RenderState[] savedStates
a place to internally save previous states setup before rendering this pass


context

protected RenderContext<?> context
Constructor Detail

Pass

public Pass()
Method Detail

renderPass

public final void renderPass(Renderer r)
if enabled, set the states for this pass and then render.


setPassState

public void setPassState(RenderState state)
Enforce a particular state. In other words, the given state will override any state of the same type set on a scene object. Remember to clear the state when done enforcing. Very useful for multipass techniques where multiple sets of states need to be applied to a scenegraph drawn multiple times.

Parameters:
state - state to enforce

getRenderState

public RenderState getRenderState(int type)
Deprecated. As of 2.0, use getRenderState(com.jme.scene.state.RenderState.StateType) instead.

Returns the requested RenderState that this Pass currently has set or null if none is set.

Parameters:
type - the renderstate type to retrieve
Returns:
a renderstate at the given position or null

getRenderState

public RenderState getRenderState(RenderState.StateType type)
Returns the requested RenderState that this Pass currently has set or null if none is set.

Parameters:
type - the renderstate type to retrieve
Returns:
a renderstate at the given position or null

clearPassState

public void clearPassState(int renderStateType)
Deprecated. As of 2.0, use clearPassState(com.jme.scene.state.RenderState.StateType) instead.

Clears an enforced render state index by setting it to null. This allows object specific states to be used.

Parameters:
renderStateType - The type of RenderState to clear enforcement on.

clearPassState

public void clearPassState(RenderState.StateType type)
Clears an enforced render state by setting it to null. This allows object specific states to be used.

Parameters:
type - The type of RenderState to clear enforcement on.

clearPassStates

public void clearPassStates()
sets all enforced states to null.

See Also:
RenderContext.clearEnforcedState(int)

applyPassStates

protected void applyPassStates()

doRender

protected abstract void doRender(Renderer r)

resetOldStates

protected void resetOldStates()

updatePass

public final void updatePass(float tpf)
if enabled, call doUpdate to update information for this pass.


doUpdate

protected void doUpdate(float tpf)

add

public void add(Spatial toAdd)

get

public Spatial get(int index)

contains

public boolean contains(Spatial s)

remove

public boolean remove(Spatial toRemove)

removeAll

public void removeAll()

size

public int size()

isEnabled

public boolean isEnabled()
Returns:
Returns the enabled.

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - The enabled to set.

getZFactor

public float getZFactor()
Returns:
Returns the zFactor.

setZFactor

public void setZFactor(float factor)
Sets the polygon offset param - factor - for this Pass.

Parameters:
factor - The zFactor to set.

getZOffset

public float getZOffset()
Returns:
Returns the zOffset.

setZOffset

public void setZOffset(float offset)
Sets the polygon offset param - offset - for this Pass.

Parameters:
offset - The zOffset to set.

cleanUp

public void cleanUp()