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

    • axisX

      protected static Vector3f[] axisX
    • axisY

      protected static Vector3f[] axisY
    • axisZ

      protected static Vector3f[] axisZ
    • imageFormat

      protected Image.Format imageFormat
    • debugEnv

      public TextureCubeMap debugEnv
    • images

      protected Image[] images
    • viewports

      protected ViewPort[] viewports
    • framebuffers

      protected FrameBuffer[] framebuffers
    • buffers

      protected ByteBuffer[] buffers
    • position

      protected Vector3f position
    • backGroundColor

      protected ColorRGBA backGroundColor
    • size

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

    • EnvironmentCamera

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

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

      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

      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

    • snapshot

      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

      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

      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

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

      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

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

      public Vector3f getPosition()
    • setPosition

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

      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

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

      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

      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

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

      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

      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

      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

      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

      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