Package com.jme3.shadow
Class ShadowUtil
java.lang.Object
com.jme3.shadow.ShadowUtil
Includes various useful shadow mapping functions.
See for more info.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
OccludersExtractor is a helper class to collect splitOccluders from scene recursively. -
Method Summary
Modifier and TypeMethodDescriptionstatic BoundingBox
computeBoundForPoints
(Vector3f[] pts, Matrix4f mat) Compute bounds from an array of pointsstatic BoundingBox
computeBoundForPoints
(Vector3f[] pts, Transform transform) Compute bounds from an array of pointsstatic BoundingBox
computeUnionBound
(GeometryList list, Matrix4f mat) Compute bounds of a geomListstatic BoundingBox
computeUnionBound
(GeometryList list, Transform transform) Compute bounds of a geomListstatic BoundingBox
Computes the bounds of multiple bounding volumesstatic void
getGeometriesInCamFrustum
(GeometryList inputGeometryList, Camera camera, GeometryList outputGeometryList) Populates the outputGeometryList with the geometry of the inputGeometryList that are in the frustum of the given camerastatic void
getGeometriesInCamFrustum
(Spatial rootScene, Camera camera, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) Populates the outputGeometryList with the rootScene children geometries that are in the frustum of the given camerastatic void
getGeometriesInLightRadius
(GeometryList inputGeometryList, Camera[] cameras, GeometryList outputGeometryList) Populates the outputGeometryList with the geometry of the inputGeometryList that are in the radius of a light.static void
getLitGeometriesInViewPort
(Spatial rootScene, Camera vpCamera, Camera[] cameras, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) Populates the outputGeometryList with the geometries of the children of OccludersExtractor.rootScene node that are both in the frustum of the given vpCamera and some camera inside cameras array.static void
updateFrustumPoints
(Camera viewCam, float nearOverride, float farOverride, float scale, Vector3f[] points) Updates the points array to contain the frustum corners of the given camera.static void
updateFrustumPoints2
(Camera viewCam, Vector3f[] points) Updates a points arrays with the frustum corners of the provided camera.static void
updateShadowCamera
(Camera shadowCam, Vector3f[] points) Updates the shadow camera to properly contain the given points (which contain the eye camera frustum corners)static void
updateShadowCamera
(ViewPort viewPort, GeometryList receivers, Camera shadowCam, Vector3f[] points, GeometryList splitOccluders, float shadowMapSize) Updates the shadow camera to properly contain the given points (which contain the eye camera frustum corners) and the shadow occluder objects collected through the traverse of the scene hierarchy
-
Method Details
-
updateFrustumPoints2
Updates a points arrays with the frustum corners of the provided camera.- Parameters:
viewCam
- the viewing Camera (not null, unaffected)points
- storage for the corner coordinates (not null, length≥8, modified)
-
updateFrustumPoints
public static void updateFrustumPoints(Camera viewCam, float nearOverride, float farOverride, float scale, Vector3f[] points) Updates the points array to contain the frustum corners of the given camera. The nearOverride and farOverride variables can be used to override the camera's near/far values with own values. TODO: Reduce creation of new vectors- Parameters:
viewCam
- the viewing Camera (not null, unaffected)nearOverride
- distance to the near plane (in world units)farOverride
- distance to the far plane (in world units)scale
- scale factorpoints
- storage for the corner coordinates (not null, length≥8, modified)
-
computeUnionBound
Compute bounds of a geomList- Parameters:
list
- a list of geometries (not null)transform
- a coordinate transform- Returns:
- a new instance
-
computeUnionBound
Compute bounds of a geomList- Parameters:
list
- a list of geometries (not null)mat
- a coordinate-transform matrix- Returns:
- a new instance
-
computeUnionBound
Computes the bounds of multiple bounding volumes- Parameters:
bv
- a list of bounding volumes (not null)- Returns:
- a new instance
-
computeBoundForPoints
Compute bounds from an array of points- Parameters:
pts
- an array of location vectors (not null, unaffected)transform
- a coordinate transform- Returns:
- a new instance
-
computeBoundForPoints
Compute bounds from an array of points- Parameters:
pts
- an array of location vectors (not null, unaffected)mat
- a coordinate-transform matrix (not null, unaffected)- Returns:
- a new BoundingBox
-
updateShadowCamera
Updates the shadow camera to properly contain the given points (which contain the eye camera frustum corners)- Parameters:
shadowCam
- the shadow camera (not null, modified)points
- an array of location vectors (not null, unaffected)
-
updateShadowCamera
public static void updateShadowCamera(ViewPort viewPort, GeometryList receivers, Camera shadowCam, Vector3f[] points, GeometryList splitOccluders, float shadowMapSize) Updates the shadow camera to properly contain the given points (which contain the eye camera frustum corners) and the shadow occluder objects collected through the traverse of the scene hierarchy- Parameters:
viewPort
- the ViewPortreceivers
- a list of receiving geometriesshadowCam
- the shadow camera (not null, modified)points
- an array of location vectors (not null, unaffected)splitOccluders
- a list of occluding geometriesshadowMapSize
- the size of each edge of the shadow map (in pixels)
-
getGeometriesInCamFrustum
public static void getGeometriesInCamFrustum(GeometryList inputGeometryList, Camera camera, GeometryList outputGeometryList) Populates the outputGeometryList with the geometry of the inputGeometryList that are in the frustum of the given camera- Parameters:
inputGeometryList
- The list containing all geometries to check against the camera frustumcamera
- the camera to check geometries againstoutputGeometryList
- the list of all geometries that are in the camera frustum
-
getGeometriesInCamFrustum
public static void getGeometriesInCamFrustum(Spatial rootScene, Camera camera, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) Populates the outputGeometryList with the rootScene children geometries that are in the frustum of the given camera- Parameters:
rootScene
- the rootNode of the scene to traversecamera
- the camera to check geometries againstmode
- the ShadowMode to test foroutputGeometryList
- the list of all geometries that are in the camera frustum
-
getGeometriesInLightRadius
public static void getGeometriesInLightRadius(GeometryList inputGeometryList, Camera[] cameras, GeometryList outputGeometryList) Populates the outputGeometryList with the geometry of the inputGeometryList that are in the radius of a light. The array must contain 6 cameras, initialized to represent the viewspace of a point light.- Parameters:
inputGeometryList
- The list containing all geometries to check against the camera frustumcameras
- the camera array to check geometries againstoutputGeometryList
- the list of all geometries that are in the camera frustum
-
getLitGeometriesInViewPort
public static void getLitGeometriesInViewPort(Spatial rootScene, Camera vpCamera, Camera[] cameras, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) Populates the outputGeometryList with the geometries of the children of OccludersExtractor.rootScene node that are both in the frustum of the given vpCamera and some camera inside cameras array. The array of cameras must be initialized to represent the light viewspace of some light like pointLight or spotLight- Parameters:
rootScene
- the root of the scene to traverse (may be null)vpCamera
- the viewPort cameracameras
- the camera array to check geometries against, representing the light viewspacemode
- the ShadowMode to test foroutputGeometryList
- the output list of all geometries that are in the camera frustum
-