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
Nested ClassesModifier and TypeClassDescriptionprotected classAn inner class to keep track on a snapshot job. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Vector3f[]protected static Vector3f[]protected static Vector3f[]protected ColorRGBAprotected ByteBuffer[]protected FrameBuffer[]protected Image.Formatprotected Image[]protected Vector3fprotected intThe size of environment cameras.protected ViewPort[] -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 voidcleanup(Application app) Called after the app state is detached or during application shutdown if the state is still attached.protected CameracreateOffCamera(int mapSize, Vector3f worldPos, Vector3f axisX, Vector3f axisY, Vector3f axisZ) Creates an off cameraprotected FrameBuffercreateOffScreenFrameBuffer(int mapSize, ViewPort offView) create an offscreen frame buffer.protected ViewPortcreateOffViewPort(String name, Camera offCamera) creates an off-screen VPreturns the images format used for the generated maps.intgetSize()Gets the size of environment cameras.ViewPort[]Returns an array of the 6 ViewPorts used to capture the snapshot.protected voidinitialize(Application app) Called during initialization once the app state is attached and before onEnable() is called.booleanisBusy()Test whether this EnvironmentCamera is busy.protected voidCalled when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected voidonEnable()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 voidrebuild()Rebuild all environment cameras.voidrender(RenderManager renderManager) Render the state.voidsetBackGroundColor(ColorRGBA bgColor) Alter the background color of an initialized EnvironmentCamera.voidsetPosition(Vector3f position) Sets the camera position in world space.voidsetSize(int size) Sets the size of environment cameras and rebuild this state if it was initialized.voidsnapshot(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:AppStateRender the state. This method will be called every render pass if theAppStateis both attached and enabled.- Specified by:
renderin interfaceAppState- Overrides:
renderin 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:BaseAppStateCalled during initialization once the app state is attached and before onEnable() is called.- Specified by:
initializein classBaseAppState- Parameters:
app- the application
-
cleanup
Description copied from class:BaseAppStateCalled 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:
cleanupin 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:BaseAppStateCalled 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:
onEnablein classBaseAppState
-
onDisable
protected void onDisable()Description copied from class:BaseAppStateCalled 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:
onDisablein 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
-