Package com.jme3.environment
Class EnvironmentProbeControl
java.lang.Object
com.jme3.light.Light
com.jme3.light.LightProbe
com.jme3.environment.EnvironmentProbeControl
A control that automatically handles environment bake and rebake including
only tagged spatials.
Simple usage example:
1. Load a scene
Node scene=(Node)assetManager.loadModel("Scenes/MyScene.j3o");
2. Add one or more EnvironmentProbeControl to the root of the scene
EnvironmentProbeControl ec1=new EnvironmentProbeControl(assetManager, 512);
// EnvironmentProbeControl ec2=new EnvironmentProbeControl(assetManager, 512);
2b. (optional) Set the position of the probes
ec1.setPosition(new Vector3f(0,0,0));
// ec2.setPosition(new Vector3f(0,0,10));
3. Tag the spatials that are part of the environment
scene.deepFirstTraversal(s->{
if(s.getUserData("isEnvNode")!=null){
EnvironmentProbeControl.tagGlobal(s);
// or ec1.tag(s);
// ec2.tag(s);
}
});
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.light.LightProbe
LightProbe.AreaType
Nested classes/interfaces inherited from class com.jme3.light.Light
Light.Type
-
Field Summary
Fields inherited from class com.jme3.light.LightProbe
FALLBACK_MATRIX
Fields inherited from class com.jme3.light.Light
color, lastDistance, name
-
Constructor Summary
ModifierConstructorDescriptionprotected
EnvironmentProbeControl
(AssetManager assetManager, int size) Creates a new environment probe control. -
Method Summary
Modifier and TypeMethodDescriptioncloneForSpatial
(Spatial spatial) Creates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.float
Gets the maximum distance to render.float
Gets the minimum distance to render.boolean
Returns true if this light is enabled.boolean
Returns true if savable results are required by this control.void
read
(JmeImporter im) void
rebake()
Schedules a rebake of the environment map.void
render
(RenderManager rm, ViewPort vp) Should be called prior to queuing the spatial by the RenderManager.void
setAssetManager
(AssetManager assetManager) Sets the asset manager used to load the shaders needed for the baking.void
setEnabled
(boolean enabled) Set to false in order to disable a light and have it filtered out from being included in rendering.void
setFrustumFar
(float frustumFar) Sets the maximum distance to render.void
setFrustumNear
(float frustumNear) Sets the minimum distance to render.void
setRequiredSavableResults
(boolean v) Requests savable results from the baking process.void
setSpatial
(Spatial spatial) void
Tags the specified spatial as part of the environment for this EnvironmentProbeControl.static void
Tags the specified spatial as part of the environment for every EnvironmentProbeControl.void
Untags the specified spatial as part of the environment for this EnvironmentProbeControl.static void
Untags the specified spatial as part of the environment for every EnvironmentProbeControl.void
update
(float tpf) Updates the control.void
write
(JmeExporter ex) Methods inherited from class com.jme3.light.LightProbe
computeLastDistance, getArea, getAreaType, getBounds, getNbMipMaps, getPosition, getPrefilteredEnvMap, getShCoeffs, getType, getUniformMatrix, intersectsBox, intersectsFrustum, intersectsSphere, isReady, setAreaType, setNbMipMaps, setPosition, setPrefilteredMap, setReady, setShCoeffs, toString
Methods inherited from class com.jme3.light.Light
clone, getColor, getName, isFrustumCheckNeeded, isIntersectsFrustum, setColor, setFrustumCheckNeeded, setIntersectsFrustum, setName
-
Constructor Details
-
EnvironmentProbeControl
protected EnvironmentProbeControl() -
EnvironmentProbeControl
Creates a new environment probe control.- Parameters:
assetManager
- the asset manager used to load the shaders needed for the bakingsize
- the size of side of the resulting cube map (eg. 1024)
-
-
Method Details
-
tag
Tags the specified spatial as part of the environment for this EnvironmentProbeControl. Only tagged spatials will be rendered in the environment map.- Parameters:
s
- the spatial
-
untag
Untags the specified spatial as part of the environment for this EnvironmentProbeControl.- Parameters:
s
- the spatial
-
tagGlobal
Tags the specified spatial as part of the environment for every EnvironmentProbeControl. Only tagged spatials will be rendered in the environment map.- Parameters:
s
- the spatial
-
untagGlobal
Untags the specified spatial as part of the environment for every EnvironmentProbeControl.- Parameters:
s
- the spatial
-
cloneForSpatial
Description copied from interface:Control
Creates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.- Specified by:
cloneForSpatial
in interfaceControl
- Parameters:
spatial
- the Spatial to be controlled by the clone- Returns:
- A clone of this control for the spatial
-
setRequiredSavableResults
public void setRequiredSavableResults(boolean v) Requests savable results from the baking process. This will make the baking process slower and more memory intensive but will allow to serialize the results with the control.- Parameters:
v
- true to enable (default: false)
-
isRequiredSavableResults
public boolean isRequiredSavableResults()Returns true if savable results are required by this control.- Returns:
- true if savable results are required.
-
setSpatial
- Specified by:
setSpatial
in interfaceControl
- Parameters:
spatial
- the spatial to be controlled. This should not be called from user code.
-
update
public void update(float tpf) Description copied from interface:Control
Updates the control. This should not be called from user code. -
render
Description copied from interface:Control
Should be called prior to queuing the spatial by the RenderManager. This should not be called from user code. -
rebake
public void rebake()Schedules a rebake of the environment map. -
setFrustumNear
public void setFrustumNear(float frustumNear) Sets the minimum distance to render.- Parameters:
frustumNear
- the minimum distance to render
-
setFrustumFar
public void setFrustumFar(float frustumFar) Sets the maximum distance to render.- Parameters:
frustumFar
- the maximum distance to render
-
getFrustumNear
public float getFrustumNear()Gets the minimum distance to render.- Returns:
- frustum near
-
getFrustumFar
public float getFrustumFar()Gets the maximum distance to render.- Returns:
- frustum far
-
setAssetManager
Sets the asset manager used to load the shaders needed for the baking.- Parameters:
assetManager
- the asset manager
-
setEnabled
public void setEnabled(boolean enabled) Description copied from class:Light
Set to false in order to disable a light and have it filtered out from being included in rendering.- Overrides:
setEnabled
in classLight
- Parameters:
enabled
- true to enable and false to disable the light.
-
isEnabled
public boolean isEnabled()Description copied from class:Light
Returns true if this light is enabled. -
getSpatial
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classLightProbe
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classLightProbe
- Throws:
IOException
-