com.jme3.renderer
Class ViewPort

java.lang.Object
  extended by com.jme3.renderer.ViewPort

public class ViewPort
extends java.lang.Object

A 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 SceneProcessors which can control how the ViewPort is rendered by the RenderManager.

See Also:
RenderManager, SceneProcessor, Spatial, Camera

Field Summary
protected  ColorRGBA backColor
           
protected  Camera cam
           
protected  boolean clearColor
           
protected  boolean clearDepth
           
protected  boolean clearStencil
           
protected  java.lang.String name
           
protected  FrameBuffer out
           
protected  java.util.ArrayList<SceneProcessor> processors
           
protected  RenderQueue queue
           
protected  java.util.ArrayList<Spatial> sceneList
           
 
Constructor Summary
ViewPort(java.lang.String name, Camera cam)
          Create a new viewport.
 
Method Summary
 void addProcessor(SceneProcessor processor)
          Adds a SceneProcessor to this ViewPort.
 void attachScene(Spatial scene)
          Attaches a new scene to render in 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.
 java.util.List<SceneProcessor> getProcessors()
          Get the list of scene processors that were added to this ViewPort
 RenderQueue getQueue()
          Internal use only.
 java.util.List<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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name

cam

protected final Camera cam

queue

protected final RenderQueue queue

sceneList

protected final java.util.ArrayList<Spatial> sceneList

processors

protected final java.util.ArrayList<SceneProcessor> processors

out

protected FrameBuffer out

backColor

protected final ColorRGBA backColor

clearDepth

protected boolean clearDepth

clearColor

protected boolean clearColor

clearStencil

protected boolean clearStencil
Constructor Detail

ViewPort

public ViewPort(java.lang.String name,
                Camera cam)
Create 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 Detail

getName

public java.lang.String getName()
Returns the name of the viewport as set in the constructor.

Returns:
the name of the viewport
See Also:
ViewPort(java.lang.String, com.jme3.renderer.Camera)

getProcessors

public java.util.List<SceneProcessor> getProcessors()
Get the list of scene processors that were added to this ViewPort

Returns:
the list of processors attached to this ViewPort
See Also:
addProcessor(com.jme3.post.SceneProcessor)

addProcessor

public void addProcessor(SceneProcessor processor)
Adds a 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.

Parameters:
processor - The processor to add
See Also:
SceneProcessor

removeProcessor

public void removeProcessor(SceneProcessor processor)
Removes a SceneProcessor from this ViewPort.

The processor will no longer receive events occurring to this ViewPort.

Parameters:
processor - The processor to remove
See Also:
SceneProcessor

isClearDepth

public boolean isClearDepth()
Check if depth buffer clearing is enabled.

Returns:
true if depth buffer clearing is enabled.
See Also:
setClearDepth(boolean)

setClearDepth

public void setClearDepth(boolean clearDepth)
Enable or disable 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()
Check if color buffer clearing is enabled.

Returns:
true if color buffer clearing is enabled.
See Also:
setClearColor(boolean)

setClearColor

public void setClearColor(boolean clearColor)
Enable or disable 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()
Check if stencil buffer clearing is enabled.

Returns:
true if stencil buffer clearing is enabled.
See Also:
setClearStencil(boolean)

setClearStencil

public void setClearStencil(boolean clearStencil)
Enable or disable 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)
Set 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:
setClearColor(boolean), setClearDepth(boolean), setClearStencil(boolean)

getOutputFrameBuffer

public FrameBuffer 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(com.jme3.texture.FrameBuffer)

setOutputFrameBuffer

public void setOutputFrameBuffer(FrameBuffer out)
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

public Camera getCamera()
Returns the camera which renders the attached scenes.

Returns:
the camera which renders the attached scenes.
See Also:
Camera

getQueue

public RenderQueue getQueue()
Internal use only.


attachScene

public void attachScene(Spatial scene)
Attaches a new scene to render in this ViewPort.

Parameters:
scene - The scene to attach
See Also:
Spatial

detachScene

public void detachScene(Spatial scene)
Detaches a scene from rendering.

Parameters:
scene - The scene to detach
See Also:
attachScene(com.jme3.scene.Spatial)

clearScenes

public void clearScenes()
Removes all attached scenes.

See Also:
attachScene(com.jme3.scene.Spatial)

getScenes

public java.util.List<Spatial> getScenes()
Returns a list of all attached scenes.

Returns:
a list of all attached scenes.
See Also:
attachScene(com.jme3.scene.Spatial)

setBackgroundColor

public void setBackgroundColor(ColorRGBA background)
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

public ColorRGBA getBackgroundColor()
Returns the background color of this ViewPort

Returns:
the background color of this ViewPort
See Also:
setBackgroundColor(com.jme3.math.ColorRGBA)

setEnabled

public void setEnabled(boolean enable)
Enable or disable 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:
setEnabled(boolean)