com.jme.renderer.pass
Class ShadowedRenderPass

java.lang.Object
  extended by com.jme.renderer.pass.Pass
      extended by com.jme.renderer.pass.ShadowedRenderPass
All Implemented Interfaces:
java.io.Serializable

public class ShadowedRenderPass
extends Pass

ShadowedRenderPass is a render pass that renders the added spatials along with shadows cast by givens occluders and lights flagged as casting shadows.

Version:
$Id: ShadowedRenderPass.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Mike Talbot (some code for MODULATIVE method written Jan 2005), Joshua Slack
See Also:
Serialized Form

Nested Class Summary
static class ShadowedRenderPass.LightingMethod
           
 
Field Summary
static BlendState alphaBlended
           
static BlendState blended
           
static BlendState blendTex
           
protected static ColorMaskState colorDisabled
           
protected static ColorMaskState colorEnabled
           
protected static CullState cullBackFace
           
protected static CullState cullFrontFace
           
protected static ZBufferState forColorPassTesting
           
protected static ZBufferState forTesting
           
protected  boolean initialised
          whether or not the renderstates for this pass have been init'd yet.
protected  ShadowedRenderPass.LightingMethod lightingMethod
          Sets the type of pass to do to show shadows - ADDITIVE or MODULATIVE
protected static LightState lights
           
protected  java.util.IdentityHashMap<TriMesh,MeshShadows> meshes
          collection of TriMesh to MeshShadows mappings
static BlendState modblended
           
protected static CullState noCull
           
protected static LightState noLights
           
protected static StencilState noStencil
           
protected static TextureState noTexture
           
protected  java.util.ArrayList<TriMesh> occluderMeshes
          list of occluders that will be casting shadows in this pass.
protected  java.util.ArrayList<Spatial> occluders
          list of occluders registered with this pass.
protected  RenderState[] preStates
          a place to internally save previous enforced states setup before rendering this pass
protected  int quadHeight
           
protected  int quadWidth
           
protected  boolean renderShadows
          Whether to render shadows (true) or act like a normal RenderPass (false)
protected  boolean renderVolume
          Whether shadow volumes are visible
static boolean rTexture
           
protected  ColorRGBA shadowColor
          Used with MODULATIVE lightMethod.
protected  java.util.ArrayList<Light> shadowLights
          list of lights that will be used to calculate shadows in this pass.
protected  Quad shadowQuad
          A quad to use with MODULATIVE lightMethod for full screen darkening against the shadow stencil.
protected static StencilState stencilBackFaces
           
protected static StencilState stencilBothFaces
           
protected static StencilState stencilDrawOnlyWhenSet
           
protected static StencilState stencilDrawWhenNotSet
           
protected static StencilState stencilFrontFaces
           
protected  Node volumeNode
          node used to gather and hold shadow volumes for rendering.
protected static ZBufferState zbufferAlways
           
protected static ZBufferState zbufferWriteLE
           
 
Fields inherited from class com.jme.renderer.pass.Pass
context, enabled, passStates, savedStates, spatials, zFactor, zOffset
 
Constructor Summary
ShadowedRenderPass()
           
 
Method Summary
 void addOccluder(Spatial toAdd)
          addOccluder adds an occluder to this pass.
protected  void addShadowVolumes(Light light)
          addShadowVolumes adds the shadow volumes for a given light to volumeNode
protected  void cleanup()
           
 void clearOccluders()
          clearOccluders removes all occluders from this pass.
 boolean containsOccluder(Spatial s)
          containsOccluder
 void doRender(Renderer r)
          doRender renders this pass to the framebuffer
protected  void drawVolumes(Renderer r)
          drawVolumes is a debug method used to draw the shadow volumes currently in use in the pass.
protected  void generateVolumes()
           
 ShadowedRenderPass.LightingMethod getLightingMethod()
           
 boolean getRenderShadows()
           
 boolean getRenderVolume()
           
 ColorRGBA getShadowColor()
           
 ShadowGate getShadowGate()
           
protected  void getShadowLights()
           
protected  void getShadowLights(Spatial s)
           
protected  void init()
           
protected  void maskShadowLights(int mask)
           
 int occludersSize()
           
 boolean removeOccluder(Spatial toRemove)
          removeOccluder
protected  void renderScene(Renderer r)
           
protected  void replaceEnforcedStates()
          replaces any states enforced by the user at the end of the pass.
 void resetShadowQuad(Renderer r)
           
protected  void saveEnforcedStates()
          saves any states enforced by the user for replacement at the end of the pass.
 void setLightingMethod(ShadowedRenderPass.LightingMethod method)
          Sets which method to use with the shadow volume stencils in order to generate shadows in the scene.
 void setRenderShadows(boolean renderShadows)
           
 void setRenderVolume(boolean renderVolume)
           
 void setShadowColor(ColorRGBA shadowColor)
           
 void setShadowGate(ShadowGate shadowCheck)
           
protected  void setupOccluderMeshes()
           
protected  void setupOccluderMeshes(Spatial spat)
           
protected  void unmaskShadowLights()
           
 
Methods inherited from class com.jme.renderer.pass.Pass
add, applyPassStates, cleanUp, clearPassState, clearPassState, clearPassStates, contains, doUpdate, get, getRenderState, getRenderState, getZFactor, getZOffset, isEnabled, remove, removeAll, renderPass, resetOldStates, setEnabled, setPassState, setZFactor, setZOffset, size, updatePass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

occluders

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


volumeNode

protected Node volumeNode
node used to gather and hold shadow volumes for rendering.


initialised

protected boolean initialised
whether or not the renderstates for this pass have been init'd yet.


shadowQuad

protected Quad shadowQuad
A quad to use with MODULATIVE lightMethod for full screen darkening against the shadow stencil.


shadowColor

protected ColorRGBA shadowColor
Used with MODULATIVE lightMethod. Defines the base color of the shadow - the alpha value is replaced with 1 - the alpha of the light's alpha.


renderVolume

protected boolean renderVolume
Whether shadow volumes are visible


renderShadows

protected boolean renderShadows
Whether to render shadows (true) or act like a normal RenderPass (false)


lightingMethod

protected ShadowedRenderPass.LightingMethod lightingMethod
Sets the type of pass to do to show shadows - ADDITIVE or MODULATIVE


meshes

protected java.util.IdentityHashMap<TriMesh,MeshShadows> meshes
collection of TriMesh to MeshShadows mappings


occluderMeshes

protected java.util.ArrayList<TriMesh> occluderMeshes
list of occluders that will be casting shadows in this pass. If no occluders set, pass acts like normal RenderPass.


shadowLights

protected java.util.ArrayList<Light> shadowLights
list of lights that will be used to calculate shadows in this pass. Constructed dynamically by searching through the scene for lights with shadowCaster set to true.


preStates

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


quadWidth

protected int quadWidth

quadHeight

protected int quadHeight

rTexture

public static boolean rTexture

zbufferWriteLE

protected static ZBufferState zbufferWriteLE

zbufferAlways

protected static ZBufferState zbufferAlways

forTesting

protected static ZBufferState forTesting

forColorPassTesting

protected static ZBufferState forColorPassTesting

noStencil

protected static StencilState noStencil

stencilFrontFaces

protected static StencilState stencilFrontFaces

stencilBothFaces

protected static StencilState stencilBothFaces

stencilBackFaces

protected static StencilState stencilBackFaces

stencilDrawOnlyWhenSet

protected static StencilState stencilDrawOnlyWhenSet

stencilDrawWhenNotSet

protected static StencilState stencilDrawWhenNotSet

cullFrontFace

protected static CullState cullFrontFace

cullBackFace

protected static CullState cullBackFace

noCull

protected static CullState noCull

noTexture

protected static TextureState noTexture

lights

protected static LightState lights

noLights

protected static LightState noLights

blended

public static BlendState blended

alphaBlended

public static BlendState alphaBlended

modblended

public static BlendState modblended

blendTex

public static BlendState blendTex

colorEnabled

protected static ColorMaskState colorEnabled

colorDisabled

protected static ColorMaskState colorDisabled
Constructor Detail

ShadowedRenderPass

public ShadowedRenderPass()
Method Detail

addOccluder

public void addOccluder(Spatial toAdd)
addOccluder adds an occluder to this pass.

Parameters:
toAdd - Occluder Spatial to add to this pass.

clearOccluders

public void clearOccluders()
clearOccluders removes all occluders from this pass.


containsOccluder

public boolean containsOccluder(Spatial s)
containsOccluder

Parameters:
s -
Returns:

removeOccluder

public boolean removeOccluder(Spatial toRemove)
removeOccluder

Parameters:
toRemove - the Occluder Spatial to remove from this pass.
Returns:
true if the Spatial was found and removed.

occludersSize

public int occludersSize()
Returns:
the number of occluders registered with this pass

getRenderVolume

public boolean getRenderVolume()
Returns:
Returns whether shadow volumes will be rendered to the display.

setRenderVolume

public void setRenderVolume(boolean renderVolume)
Parameters:
renderVolume - sets whether shadow volumes will be rendered to the display

getRenderShadows

public boolean getRenderShadows()
Returns:
whether shadow volumes will be rendered to the display.

setRenderShadows

public void setRenderShadows(boolean renderShadows)
Parameters:
renderShadows - whether shadows will be rendered by this pass.

getShadowColor

public ColorRGBA getShadowColor()
Returns:
the shadowColor used by MODULATIVE lightMethod.

setShadowColor

public void setShadowColor(ColorRGBA shadowColor)
Parameters:
shadowColor - the shadowColor used by MODULATIVE lightMethod.

getLightingMethod

public ShadowedRenderPass.LightingMethod getLightingMethod()
Returns:
the lightingMethod currently in use.

setLightingMethod

public void setLightingMethod(ShadowedRenderPass.LightingMethod method)
Sets which method to use with the shadow volume stencils in order to generate shadows in the scene. See javadoc descriptions in the enum LightingMethod for more info.

Parameters:
method - method to use
Throws:
java.lang.IllegalArgumentException - if method is null

doRender

public void doRender(Renderer r)
doRender renders this pass to the framebuffer

Specified by:
doRender in class Pass
Parameters:
r - Renderer to use for drawing.
See Also:
Pass.doRender(com.jme.renderer.Renderer)

cleanup

protected void cleanup()

maskShadowLights

protected void maskShadowLights(int mask)

unmaskShadowLights

protected void unmaskShadowLights()

renderScene

protected void renderScene(Renderer r)

getShadowLights

protected void getShadowLights()

getShadowLights

protected void getShadowLights(Spatial s)

setupOccluderMeshes

protected void setupOccluderMeshes()

setupOccluderMeshes

protected void setupOccluderMeshes(Spatial spat)

saveEnforcedStates

protected void saveEnforcedStates()
saves any states enforced by the user for replacement at the end of the pass.


replaceEnforcedStates

protected void replaceEnforcedStates()
replaces any states enforced by the user at the end of the pass.


generateVolumes

protected void generateVolumes()

addShadowVolumes

protected void addShadowVolumes(Light light)
addShadowVolumes adds the shadow volumes for a given light to volumeNode

Parameters:
light - the light whose volumes should be added

drawVolumes

protected void drawVolumes(Renderer r)
drawVolumes is a debug method used to draw the shadow volumes currently in use in the pass.

Parameters:
r - Renderer to draw with.

init

protected void init()

resetShadowQuad

public void resetShadowQuad(Renderer r)

getShadowGate

public ShadowGate getShadowGate()

setShadowGate

public void setShadowGate(ShadowGate shadowCheck)