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.AreaTypeNested classes/interfaces inherited from class com.jme3.light.Light
Light.Type -
Field Summary
Fields inherited from class com.jme3.light.LightProbe
FALLBACK_MATRIXFields inherited from class com.jme3.light.Light
color, lastDistance, name -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEnvironmentProbeControl(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.floatGets the maximum distance to render.floatGets the minimum distance to render.booleanReturns true if this light is enabled.booleanReturns true if savable results are required by this control.voidread(JmeImporter im) voidrebake()Schedules a rebake of the environment map.voidrender(RenderManager rm, ViewPort vp) Should be called prior to queuing the spatial by the RenderManager.voidsetAssetManager(AssetManager assetManager) Sets the asset manager used to load the shaders needed for the baking.voidsetEnabled(boolean enabled) Set to false in order to disable a light and have it filtered out from being included in rendering.voidsetFrustumFar(float frustumFar) Sets the maximum distance to render.voidsetFrustumNear(float frustumNear) Sets the minimum distance to render.voidsetRequiredSavableResults(boolean v) Requests savable results from the baking process.voidsetSpatial(Spatial spatial) voidTags the specified spatial as part of the environment for this EnvironmentProbeControl.static voidTags the specified spatial as part of the environment for every EnvironmentProbeControl.voidUntags the specified spatial as part of the environment for this EnvironmentProbeControl.static voidUntags the specified spatial as part of the environment for every EnvironmentProbeControl.voidupdate(float tpf) Updates the control.voidwrite(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, toStringMethods 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:ControlCreates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.- Specified by:
cloneForSpatialin 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:
setSpatialin 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:ControlUpdates the control. This should not be called from user code. -
render
Description copied from interface:ControlShould 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:LightSet to false in order to disable a light and have it filtered out from being included in rendering.- Overrides:
setEnabledin classLight- Parameters:
enabled- true to enable and false to disable the light.
-
isEnabled
public boolean isEnabled()Description copied from class:LightReturns true if this light is enabled. -
getSpatial
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classLightProbe- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classLightProbe- Throws:
IOException
-