Package com.jme3.environment
Class EnvironmentCamera
java.lang.Object
com.jme3.app.state.BaseAppState
com.jme3.environment.EnvironmentCamera
- All Implemented Interfaces:
AppState
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
An inner class to keep track on a snapshot job. -
Field Summary
Modifier and TypeFieldDescriptionprotected static Vector3f[]
protected static Vector3f[]
protected static Vector3f[]
protected ColorRGBA
protected ByteBuffer[]
protected FrameBuffer[]
protected Image.Format
protected Image[]
protected Vector3f
protected int
The size of environment cameras.protected ViewPort[]
-
Constructor Summary
ConstructorDescriptionCreates an EnvironmentCamera with a size of 256EnvironmentCamera
(int size) Creates an EnvironmentCamera with the given size.EnvironmentCamera
(int size, Vector3f position) Creates an EnvironmentCamera with the given size, and the given positionEnvironmentCamera
(int size, Vector3f position, Image.Format imageFormat) Creates an EnvironmentCamera with the given size, and the given position -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup
(Application app) Called after the app state is detached or during application shutdown if the state is still attached.protected Camera
createOffCamera
(int mapSize, Vector3f worldPos, Vector3f axisX, Vector3f axisY, Vector3f axisZ) Creates an off cameraprotected FrameBuffer
createOffScreenFrameBuffer
(int mapSize, ViewPort offView) create an offscreen frame buffer.protected ViewPort
createOffViewPort
(String name, Camera offCamera) creates an off-screen VPreturns the images format used for the generated maps.int
getSize()
Gets the size of environment cameras.ViewPort[]
Returns an array of the 6 ViewPorts used to capture the snapshot.protected void
initialize
(Application app) Called during initialization once the app state is attached and before onEnable() is called.boolean
isBusy()
Test whether this EnvironmentCamera is busy.protected void
Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected void
onEnable()
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.protected void
rebuild()
Rebuild all environment cameras.void
render
(RenderManager renderManager) Render the state.void
setBackGroundColor
(ColorRGBA bgColor) Alter the background color of an initialized EnvironmentCamera.void
setPosition
(Vector3f position) Sets the camera position in world space.void
setSize
(int size) Sets the size of environment cameras and rebuild this state if it was initialized.void
snapshot
(Spatial scene, JobProgressListener<TextureCubeMap> done) Takes a snapshot of the surrounding scene.Methods inherited from class com.jme3.app.state.BaseAppState
cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, setEnabled, setId, stateAttached, stateDetached, update
-
Field Details
-
axisX
-
axisY
-
axisZ
-
imageFormat
-
debugEnv
-
images
-
viewports
-
framebuffers
-
buffers
-
position
-
backGroundColor
-
size
protected int sizeThe 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
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
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
Takes a snapshot of the surrounding scene.- Parameters:
scene
- the scene to snapshot.done
- a callback to call when the snapshot is done.
-
render
Description copied from interface:AppState
Render the state. This method will be called every render pass if theAppState
is both attached and enabled.- Specified by:
render
in interfaceAppState
- Overrides:
render
in classBaseAppState
- Parameters:
renderManager
- RenderManager
-
setBackGroundColor
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
-
setPosition
Sets the camera position in world space.- Parameters:
position
- the position in world space
-
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
Description copied from class:BaseAppState
Called during initialization once the app state is attached and before onEnable() is called.- Specified by:
initialize
in classBaseAppState
- Parameters:
app
- the application
-
cleanup
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 classBaseAppState
- Parameters:
app
- the application
-
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 classBaseAppState
-
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 classBaseAppState
-
createOffCamera
protected Camera createOffCamera(int mapSize, Vector3f worldPos, Vector3f axisX, Vector3f axisY, Vector3f axisZ) Creates an off camera- Parameters:
mapSize
- the sizeworldPos
- the positionaxisX
- the x axisaxisY
- the y axisaxisZ
- tha z axis- Returns:
- a new instance
-
createOffViewPort
creates an off-screen VP- Parameters:
name
- the desired name for the offscreen viewportoffCamera
- the Camera to be used (alias created)- Returns:
- a new instance
-
createOffScreenFrameBuffer
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
-