Class EnvironmentCamera

java.lang.Object
com.jme3.app.state.BaseAppState
com.jme3.environment.EnvironmentCamera
All Implemented Interfaces:
AppState

public class EnvironmentCamera extends BaseAppState
A 360 camera that can capture a cube map of a scene, and then generate the Prefiltered Environment cube Map and the Irradiance cube Map needed for PBR indirect lighting
See Also:
  • Field Details Link icon

    • axisX Link icon

      protected static Vector3f[] axisX
    • axisY Link icon

      protected static Vector3f[] axisY
    • axisZ Link icon

      protected static Vector3f[] axisZ
    • imageFormat Link icon

      protected Image.Format imageFormat
    • debugEnv Link icon

      public TextureCubeMap debugEnv
    • images Link icon

      protected Image[] images
    • viewports Link icon

      protected ViewPort[] viewports
    • framebuffers Link icon

      protected FrameBuffer[] framebuffers
    • buffers Link icon

      protected ByteBuffer[] buffers
    • position Link icon

      protected Vector3f position
    • backGroundColor Link icon

      protected ColorRGBA backGroundColor
    • size Link icon

      protected int size
      The size of environment cameras.
  • Constructor Details Link icon

    • EnvironmentCamera Link icon

      public EnvironmentCamera()
      Creates an EnvironmentCamera with a size of 256
    • EnvironmentCamera Link icon

      public EnvironmentCamera(int size)
      Creates an EnvironmentCamera with the given size.
      Parameters:
      size - the size of the resulting texture.
    • EnvironmentCamera Link icon

      public EnvironmentCamera(int size, Vector3f position)
      Creates an EnvironmentCamera with the given size, and the given position
      Parameters:
      size - the size of the resulting texture.
      position - the position of the camera.
    • EnvironmentCamera Link icon

      public EnvironmentCamera(int size, Vector3f position, Image.Format imageFormat)
      Creates an EnvironmentCamera with the given size, and the given position
      Parameters:
      size - the size of the resulting texture, and the given ImageFormat.
      position - the position of the camera.
      imageFormat - the ImageFormat to use for the resulting texture.
  • Method Details Link icon

    • snapshot Link icon

      public void snapshot(Spatial scene, JobProgressListener<TextureCubeMap> done)
      Takes a snapshot of the surrounding scene.
      Parameters:
      scene - the scene to snapshot.
      done - a callback to call when the snapshot is done.
    • render Link icon

      public void render(RenderManager renderManager)
      Description copied from interface: AppState
      Render the state. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      render in interface AppState
      Overrides:
      render in class BaseAppState
      Parameters:
      renderManager - RenderManager
    • setBackGroundColor Link icon

      public void setBackGroundColor(ColorRGBA bgColor)
      Alter the background color of an initialized EnvironmentCamera.
      Parameters:
      bgColor - the desired color (not null, unaffected, default is the background color of the application's default viewport)
    • getSize Link icon

      public int getSize()
      Gets the size of environment cameras.
      Returns:
      the size of environment cameras.
    • setSize Link icon

      public void setSize(int size)
      Sets the size of environment cameras and rebuild this state if it was initialized.
      Parameters:
      size - the size of environment cameras.
    • rebuild Link icon

      protected void rebuild()
      Rebuild all environment cameras.
    • getPosition Link icon

      public Vector3f getPosition()
    • setPosition Link icon

      public void setPosition(Vector3f position)
      Sets the camera position in world space.
      Parameters:
      position - the position in world space
    • getViewPorts Link icon

      public ViewPort[] getViewPorts()
      Returns an array of the 6 ViewPorts used to capture the snapshot. Note that this will be null until after initialize() is called.
      Returns:
      array of ViewPorts
    • isBusy Link icon

      public boolean isBusy()
      Test whether this EnvironmentCamera is busy. Avoid reconfiguring while busy!
      Returns:
      true if busy, otherwise false
    • initialize Link icon

      protected void initialize(Application app)
      Description copied from class: BaseAppState
      Called during initialization once the app state is attached and before onEnable() is called.
      Specified by:
      initialize in class BaseAppState
      Parameters:
      app - the application
    • cleanup Link icon

      protected void cleanup(Application app)
      Description copied from class: BaseAppState
      Called after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.
      Specified by:
      cleanup in class BaseAppState
      Parameters:
      app - the application
    • getImageFormat Link icon

      public Image.Format getImageFormat()
      returns the images format used for the generated maps.
      Returns:
      the enum value
    • onEnable Link icon

      protected void onEnable()
      Description copied from class: BaseAppState
      Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.
      Specified by:
      onEnable in class BaseAppState
    • onDisable Link icon

      protected void onDisable()
      Description copied from class: BaseAppState
      Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.
      Specified by:
      onDisable in class BaseAppState
    • createOffCamera Link icon

      protected Camera createOffCamera(int mapSize, Vector3f worldPos, Vector3f axisX, Vector3f axisY, Vector3f axisZ)
      Creates an off camera
      Parameters:
      mapSize - the size
      worldPos - the position
      axisX - the x axis
      axisY - the y axis
      axisZ - tha z axis
      Returns:
      a new instance
    • createOffViewPort Link icon

      protected ViewPort createOffViewPort(String name, Camera offCamera)
      creates an off-screen VP
      Parameters:
      name - the desired name for the offscreen viewport
      offCamera - the Camera to be used (alias created)
      Returns:
      a new instance
    • createOffScreenFrameBuffer Link icon

      protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView)
      create an offscreen frame buffer.
      Parameters:
      mapSize - the desired size (pixels per side)
      offView - the off-screen viewport to be used (alias created)
      Returns:
      a new instance