public class ViewPort
extends java.lang.Object
ViewPort
represents a view inside the display
window or a 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
.
RenderManager
,
SceneProcessor
,
Spatial
,
Camera
Modifier and Type | Field and Description |
---|---|
protected ColorRGBA |
backColor |
protected Camera |
cam |
protected boolean |
clearColor |
protected boolean |
clearDepth |
protected boolean |
clearStencil |
protected java.lang.String |
name |
protected FrameBuffer |
out |
protected SafeArrayList<SceneProcessor> |
processors |
protected RenderQueue |
queue |
protected SafeArrayList<Spatial> |
sceneList |
Constructor and Description |
---|
ViewPort(java.lang.String name,
Camera cam)
Create a new viewport.
|
Modifier and Type | Method and Description |
---|---|
void |
addProcessor(SceneProcessor processor)
Adds a
SceneProcessor to this ViewPort. |
void |
attachScene(Spatial scene)
Attaches a new scene to render in this ViewPort.
|
void |
clearProcessors()
Removes all
scene processors from this
ViewPort. |
void |
clearScenes()
Removes all attached scenes.
|
void |
detachScene(Spatial scene)
Detaches a scene from rendering.
|
ColorRGBA |
getBackgroundColor()
Returns the background color of this ViewPort
|
Camera |
getCamera()
Returns the camera which renders the attached scenes.
|
java.lang.String |
getName()
Returns the name of the viewport as set in the constructor.
|
FrameBuffer |
getOutputFrameBuffer()
Returns the framebuffer where this ViewPort's scenes are
rendered to.
|
SafeArrayList<SceneProcessor> |
getProcessors()
Get the list of
scene processors that were
added to this ViewPort |
RenderQueue |
getQueue()
Internal use only.
|
SafeArrayList<Spatial> |
getScenes()
Returns a list of all attached scenes.
|
boolean |
isClearColor()
Check if color buffer clearing is enabled.
|
boolean |
isClearDepth()
Check if depth buffer clearing is enabled.
|
boolean |
isClearStencil()
Check if stencil buffer clearing is enabled.
|
boolean |
isEnabled()
Returns true if the viewport is enabled, false otherwise.
|
void |
removeProcessor(SceneProcessor processor)
Removes a
SceneProcessor from this ViewPort. |
void |
setBackgroundColor(ColorRGBA background)
Sets the background color.
|
void |
setClearColor(boolean clearColor)
Enable or disable clearing of the color buffer for this ViewPort.
|
void |
setClearDepth(boolean clearDepth)
Enable or disable clearing of the depth buffer for this ViewPort.
|
void |
setClearFlags(boolean color,
boolean depth,
boolean stencil)
Set the clear flags (color, depth, stencil) in one call.
|
void |
setClearStencil(boolean clearStencil)
Enable or disable clearing of the stencil buffer for this ViewPort.
|
void |
setEnabled(boolean enable)
Enable or disable this ViewPort.
|
void |
setOutputFrameBuffer(FrameBuffer out)
Sets the output framebuffer for the ViewPort.
|
protected final java.lang.String name
protected final Camera cam
protected final RenderQueue queue
protected final SafeArrayList<Spatial> sceneList
protected final SafeArrayList<SceneProcessor> processors
protected FrameBuffer out
protected final ColorRGBA backColor
protected boolean clearDepth
protected boolean clearColor
protected boolean clearStencil
public ViewPort(java.lang.String name, Camera cam)
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.public java.lang.String getName()
ViewPort(java.lang.String, com.jme3.renderer.Camera)
public SafeArrayList<SceneProcessor> getProcessors()
scene processors
that were
added to this ViewPort
addProcessor(com.jme3.post.SceneProcessor)
public void addProcessor(SceneProcessor processor)
SceneProcessor
to this ViewPort.
SceneProcessors that are added to the ViewPort will be notified
of events as the ViewPort is being rendered by the RenderManager
.
processor
- The processor to addSceneProcessor
public void removeProcessor(SceneProcessor processor)
SceneProcessor
from this ViewPort.
The processor will no longer receive events occurring to this ViewPort.
processor
- The processor to removeSceneProcessor
public void clearProcessors()
scene processors
from this
ViewPort.SceneProcessor
public boolean isClearDepth()
setClearDepth(boolean)
public void setClearDepth(boolean clearDepth)
By default depth clearing is disabled.
clearDepth
- Enable/disable depth buffer clearing.public boolean isClearColor()
setClearColor(boolean)
public void setClearColor(boolean clearColor)
By default color clearing is disabled.
clearColor
- Enable/disable color buffer clearing.public boolean isClearStencil()
setClearStencil(boolean)
public void setClearStencil(boolean clearStencil)
By default stencil clearing is disabled.
clearStencil
- Enable/disable stencil buffer clearing.public void setClearFlags(boolean color, boolean depth, boolean stencil)
color
- If color buffer clearing should be enabled.depth
- If depth buffer clearing should be enabled.stencil
- If stencil buffer clearing should be enabled.setClearColor(boolean)
,
setClearDepth(boolean)
,
setClearStencil(boolean)
public FrameBuffer getOutputFrameBuffer()
setOutputFrameBuffer(com.jme3.texture.FrameBuffer)
public void setOutputFrameBuffer(FrameBuffer out)
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.
out
- The framebuffer to render scenes to, or null if to render
to the screen.public Camera getCamera()
Camera
public RenderQueue getQueue()
public void attachScene(Spatial scene)
scene
- The scene to attachSpatial
public void detachScene(Spatial scene)
scene
- The scene to detachattachScene(com.jme3.scene.Spatial)
public void clearScenes()
attachScene(com.jme3.scene.Spatial)
public SafeArrayList<Spatial> getScenes()
attachScene(com.jme3.scene.Spatial)
public void setBackgroundColor(ColorRGBA background)
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.
background
- the background color.public ColorRGBA getBackgroundColor()
setBackgroundColor(com.jme3.math.ColorRGBA)
public void setEnabled(boolean enable)
Disabled ViewPorts are skipped by the RenderManager
when
rendering. By default all ViewPorts are enabled.
enable
- If the viewport should be disabled or enabled.public boolean isEnabled()
setEnabled(boolean)