com.jme.renderer.pass
Class DirectionalShadowMapPass

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

public class DirectionalShadowMapPass
extends Pass

A pass providing a shadow mapping layer across the top of an existing scene. Based on code by Robert Larsson and Joshua Slack

Author:
kevglass
See Also:
Serialized Form

Field Summary
protected  Vector3f direction
          The direction shadows are being cast from - directional light?
protected  float dis
          The distance we're modelling the direction light source as being away from the focal point, again the higher the number the more of the scene is covered but at lower resolution
protected  boolean initialised
          True once the pass has been initialised
protected  float shadowMapScale
          The scaling applied to the shadow map when rendered to - lower number means higher res but less ara covered by the shadow map
 
Fields inherited from class com.jme.renderer.pass.Pass
context, enabled, passStates, savedStates, spatials, zFactor, zOffset
 
Constructor Summary
DirectionalShadowMapPass(Vector3f direction)
          Create a shadow map pass casting shadows from a light with the direction given.
DirectionalShadowMapPass(Vector3f direction, int shadowMapSize)
          Create a shadow map pass casting shadows from a light with the direction given.
 
Method Summary
 void addOccluder(Spatial occluder)
          Add a spatial that will occlude light and hence cast a shadow
 void cleanUp()
           
 void clear()
          Remove the contents of the pass
 void doRender(Renderer r)
           
 GLSLShaderObjectsState getShader()
           
 void init(Renderer r)
          Initialise the pass render states
protected  void renderShadowedScene(Renderer r)
          Render the scene with shadows
protected  void replaceEnforcedStates()
          replaces any states enforced by the user at the end of the pass.
protected  void saveEnforcedStates()
          saves any states enforced by the user for replacement at the end of the pass.
 void setCullOccluders(boolean cullOccluders)
          Indicate whether occluders should be culled against shadow map frustrum
 void setShadowAlpha(float alpha)
          Set the colour of the shadows to be cast
 void setShadowMapScale(float scale)
          Set the scale factor thats used to stretch the shadow map texture across the scene.
 void setViewDistance(float dis)
          Set the distance of the camera representing the directional light.
 void setViewTarget(Vector3f target)
          Set the target of the view.
protected  void updateShadowCamera()
          Update the direction from which the shadows are cast
protected  void updateShadowMap(Renderer r)
          Update the shadow map
 
Methods inherited from class com.jme.renderer.pass.Pass
add, applyPassStates, 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

initialised

protected boolean initialised
True once the pass has been initialised


direction

protected Vector3f direction
The direction shadows are being cast from - directional light?


shadowMapScale

protected float shadowMapScale
The scaling applied to the shadow map when rendered to - lower number means higher res but less ara covered by the shadow map


dis

protected float dis
The distance we're modelling the direction light source as being away from the focal point, again the higher the number the more of the scene is covered but at lower resolution

Constructor Detail

DirectionalShadowMapPass

public DirectionalShadowMapPass(Vector3f direction)
Create a shadow map pass casting shadows from a light with the direction given.

Parameters:
direction - The direction of the light casting the shadows

DirectionalShadowMapPass

public DirectionalShadowMapPass(Vector3f direction,
                                int shadowMapSize)
Create a shadow map pass casting shadows from a light with the direction given.

Parameters:
shadowMapSize - The size of the shadow map texture
direction - The direction of the light casting the shadows
Method Detail

setShadowAlpha

public void setShadowAlpha(float alpha)
Set the colour of the shadows to be cast

Parameters:
col - The colour of the shadows to be cast

setViewDistance

public void setViewDistance(float dis)
Set the distance of the camera representing the directional light. The further away the more of the scene will be shadowed but at a lower resolution

Parameters:
dis - The distance to be used for the shadow map camera (default = 500)

setCullOccluders

public void setCullOccluders(boolean cullOccluders)
Indicate whether occluders should be culled against shadow map frustrum

Parameters:
cullOccluders - True if occluders should be culled against shadow map frustrum

setShadowMapScale

public void setShadowMapScale(float scale)
Set the scale factor thats used to stretch the shadow map texture across the scene. Higher the number the more of the scene will be convered but at a lower resolution.

Parameters:
scale - The scale used to stretch the shadow map across the scene.

setViewTarget

public void setViewTarget(Vector3f target)
Set the target of the view. This will be where the camera points when generating the shadow map and should be the centre of the scene

Parameters:
target - The target of the view

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.


addOccluder

public void addOccluder(Spatial occluder)
Add a spatial that will occlude light and hence cast a shadow

Parameters:
occluder - The spatial to add as an occluder

init

public void init(Renderer r)
Initialise the pass render states


getShader

public GLSLShaderObjectsState getShader()

doRender

public void doRender(Renderer r)
Specified by:
doRender in class Pass
See Also:
Pass.doRender(com.jme.renderer.Renderer)

renderShadowedScene

protected void renderShadowedScene(Renderer r)
Render the scene with shadows

Parameters:
r - The renderer to use

updateShadowMap

protected void updateShadowMap(Renderer r)
Update the shadow map

Parameters:
r - The renderer to being use to display this map

updateShadowCamera

protected void updateShadowCamera()
Update the direction from which the shadows are cast


cleanUp

public void cleanUp()
Overrides:
cleanUp in class Pass
See Also:
Pass.cleanUp()

clear

public void clear()
Remove the contents of the pass