Class EnvironmentProbeControl

java.lang.Object
com.jme3.light.Light
com.jme3.light.LightProbe
com.jme3.environment.EnvironmentProbeControl
All Implemented Interfaces:
Savable, Control, Cloneable

public class EnvironmentProbeControl extends LightProbe implements Control
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); } });
  • Constructor Details

    • EnvironmentProbeControl

      protected EnvironmentProbeControl()
    • EnvironmentProbeControl

      public EnvironmentProbeControl(AssetManager assetManager, int size)
      Creates a new environment probe control.
      Parameters:
      assetManager - the asset manager used to load the shaders needed for the baking
      size - the size of side of the resulting cube map (eg. 1024)
  • Method Details

    • tag

      public void tag(Spatial s)
      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

      public void untag(Spatial s)
      Untags the specified spatial as part of the environment for this EnvironmentProbeControl.
      Parameters:
      s - the spatial
    • tagGlobal

      public static void tagGlobal(Spatial s)
      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

      public static void untagGlobal(Spatial s)
      Untags the specified spatial as part of the environment for every EnvironmentProbeControl.
      Parameters:
      s - the spatial
    • cloneForSpatial

      public Control cloneForSpatial(Spatial spatial)
      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 interface Control
      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

      public void setSpatial(Spatial spatial)
      Specified by:
      setSpatial in interface Control
      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.
      Specified by:
      update in interface Control
      Parameters:
      tpf - Time per frame.
    • render

      public void render(RenderManager rm, ViewPort vp)
      Description copied from interface: Control
      Should be called prior to queuing the spatial by the RenderManager. This should not be called from user code.
      Specified by:
      render in interface Control
      Parameters:
      rm - the caller (not null)
      vp - the relevant ViewPort (not null)
    • 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

      public void setAssetManager(AssetManager assetManager)
      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 class Light
      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.
      Overrides:
      isEnabled in class Light
      Returns:
      true if enabled, otherwise false.
    • getSpatial

      public Spatial getSpatial()
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class LightProbe
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class LightProbe
      Throws:
      IOException