Class ViewPort
FrameBuffer
to which scenes will be rendered.
A viewport has a camera
which is used to render a set of scenes
.
A view port has a location on the screen as set by the
Camera.setViewPort(float, float, float, float)
method.
By default, a view port does not clear the framebuffer, but it can be
set to clear the framebuffer
.
The background color which the color buffer is cleared to can be specified
via the setBackgroundColor(com.jme3.math.ColorRGBA)
method.
A ViewPort has a list of SceneProcessor
s which can
control how the ViewPort is rendered by the RenderManager
.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ColorRGBA
Color applied when the color buffer is cleared.protected final Camera
Camera used for rendering.protected boolean
Enables clearing the color buffer.protected boolean
Enables clearing the depth buffer.protected boolean
Enables clearing the stencil buffer.protected final String
Name for this viewport.protected FrameBuffer
FrameBuffer for output.protected final SafeArrayList<SceneProcessor>
Scene processors currently applied.protected final RenderQueue
Geometries for rendering, sorted.protected final SafeArrayList<Spatial>
Scene-graph hierarchies for rendering. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addProcessor
(SceneProcessor processor) Adds aSceneProcessor
to this ViewPort.void
attachScene
(Spatial scene) Attaches a new scene to render in this ViewPort.void
Removes allscene processors
from this ViewPort.void
Removes all attached scenes.void
detachScene
(Spatial scene) Detaches a scene from rendering.Returns the background color of this ViewPort.Returns the camera which renders the attached scenes.getName()
Returns the name of the viewport as set in the constructor.Returns the framebuffer where this ViewPort's scenes are rendered to.Gets the list ofscene processors
that were added to thisViewPort
.getQueue()
Internal use only.Returns a list of all attached scenes.boolean
Checks if color buffer clearing is enabled.boolean
Checks if depth buffer clearing is enabled.boolean
Checks if stencil buffer clearing is enabled.boolean
Returns true if the viewport is enabled, false otherwise.void
removeProcessor
(SceneProcessor processor) Removes aSceneProcessor
from this ViewPort.void
setBackgroundColor
(ColorRGBA background) Sets the background color.void
setClearColor
(boolean clearColor) Enables or disables clearing of the color buffer for this ViewPort.void
setClearDepth
(boolean clearDepth) Enables or disables clearing of the depth buffer for this ViewPort.void
setClearFlags
(boolean color, boolean depth, boolean stencil) Sets the clear flags (color, depth, stencil) in one call.void
setClearStencil
(boolean clearStencil) Enables or disables clearing of the stencil buffer for this ViewPort.void
setEnabled
(boolean enable) Enables or disables this ViewPort.void
Sets the output framebuffer for the ViewPort.
-
Field Details
-
name
Name for this viewport. -
cam
Camera used for rendering. -
queue
Geometries for rendering, sorted. -
sceneList
Scene-graph hierarchies for rendering. -
processors
Scene processors currently applied. -
out
FrameBuffer for output. -
backColor
Color applied when the color buffer is cleared. -
clearDepth
protected boolean clearDepthEnables clearing the depth buffer. -
clearColor
protected boolean clearColorEnables clearing the color buffer. -
clearStencil
protected boolean clearStencilEnables clearing the stencil buffer.
-
-
Constructor Details
-
ViewPort
Creates a new viewport. User code should generally use these methods instead:
- Parameters:
name
- The name of the viewport. Used for debugging only.cam
- The camera through which the viewport is rendered. The camera cannot be swapped to a different one after creating the viewport.
-
-
Method Details
-
getName
Returns the name of the viewport as set in the constructor.- Returns:
- the name of the viewport
- See Also:
-
getProcessors
Gets the list ofscene processors
that were added to thisViewPort
.- Returns:
- the list of processors attached to this ViewPort
- See Also:
-
addProcessor
Adds aSceneProcessor
to this ViewPort.SceneProcessors that are added to the ViewPort will be notified of events as the ViewPort is being rendered by the
RenderManager
.- Parameters:
processor
- The processor to add- See Also:
-
removeProcessor
Removes aSceneProcessor
from this ViewPort.The processor will no longer receive events occurring to this ViewPort.
- Parameters:
processor
- The processor to remove- See Also:
-
clearProcessors
public void clearProcessors()Removes allscene processors
from this ViewPort.- See Also:
-
isClearDepth
public boolean isClearDepth()Checks if depth buffer clearing is enabled.- Returns:
- true if depth buffer clearing is enabled.
- See Also:
-
setClearDepth
public void setClearDepth(boolean clearDepth) Enables or disables clearing of the depth buffer for this ViewPort.By default depth clearing is disabled.
- Parameters:
clearDepth
- Enable/disable depth buffer clearing.
-
isClearColor
public boolean isClearColor()Checks if color buffer clearing is enabled.- Returns:
- true if color buffer clearing is enabled.
- See Also:
-
setClearColor
public void setClearColor(boolean clearColor) Enables or disables clearing of the color buffer for this ViewPort.By default color clearing is disabled.
- Parameters:
clearColor
- Enable/disable color buffer clearing.
-
isClearStencil
public boolean isClearStencil()Checks if stencil buffer clearing is enabled.- Returns:
- true if stencil buffer clearing is enabled.
- See Also:
-
setClearStencil
public void setClearStencil(boolean clearStencil) Enables or disables clearing of the stencil buffer for this ViewPort.By default stencil clearing is disabled.
- Parameters:
clearStencil
- Enable/disable stencil buffer clearing.
-
setClearFlags
public void setClearFlags(boolean color, boolean depth, boolean stencil) Sets the clear flags (color, depth, stencil) in one call.- Parameters:
color
- If color buffer clearing should be enabled.depth
- If depth buffer clearing should be enabled.stencil
- If stencil buffer clearing should be enabled.- See Also:
-
getOutputFrameBuffer
Returns the framebuffer where this ViewPort's scenes are rendered to.- Returns:
- the framebuffer where this ViewPort's scenes are rendered to.
- See Also:
-
setOutputFrameBuffer
Sets the output framebuffer for the ViewPort.The output framebuffer specifies where the scenes attached to this ViewPort are rendered to. By default, this is
null
, which indicates the scenes are rendered to the display window.- Parameters:
out
- The framebuffer to render scenes to, or null if to render to the screen.
-
getCamera
Returns the camera which renders the attached scenes.- Returns:
- the camera which renders the attached scenes.
- See Also:
-
getQueue
Internal use only.- Returns:
- the pre-existing instance
-
attachScene
Attaches a new scene to render in this ViewPort.- Parameters:
scene
- The scene to attach- See Also:
-
detachScene
Detaches a scene from rendering.- Parameters:
scene
- The scene to detach- See Also:
-
clearScenes
public void clearScenes()Removes all attached scenes.- See Also:
-
getScenes
Returns a list of all attached scenes.- Returns:
- a list of all attached scenes.
- See Also:
-
setBackgroundColor
Sets the background color.When the ViewPort's color buffer is cleared (if
color clearing
is enabled), this specifies the color to which the color buffer is set to. By default, the background color is black without alpha.- Parameters:
background
- the background color.
-
getBackgroundColor
Returns the background color of this ViewPort.- Returns:
- the background color of this ViewPort
- See Also:
-
setEnabled
public void setEnabled(boolean enable) Enables or disables this ViewPort.Disabled ViewPorts are skipped by the
RenderManager
when rendering. By default, all viewports are enabled.- Parameters:
enable
- If the viewport should be disabled or enabled.
-
isEnabled
public boolean isEnabled()Returns true if the viewport is enabled, false otherwise.- Returns:
- true if the viewport is enabled, false otherwise.
- See Also:
-