Class ViewPort

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

public class ViewPort extends Object
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:
  • Field Details

    • name

      protected final String name
      Name for this viewport.
    • cam

      protected final Camera cam
      Camera used for rendering.
    • queue

      protected final RenderQueue queue
      Geometries for rendering, sorted.
    • sceneList

      protected final SafeArrayList<Spatial> sceneList
      Scene-graph hierarchies for rendering.
    • processors

      protected final SafeArrayList<SceneProcessor> processors
      Scene processors currently applied.
    • out

      protected FrameBuffer out
      FrameBuffer for output.
    • backColor

      protected final ColorRGBA backColor
      Color applied when the color buffer is cleared.
    • clearDepth

      protected boolean clearDepth
      Enables clearing the depth buffer.
    • clearColor

      protected boolean clearColor
      Enables clearing the color buffer.
    • clearStencil

      protected boolean clearStencil
      Enables clearing the stencil buffer.
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Returns the name of the viewport as set in the constructor.
      Returns:
      the name of the viewport
      See Also:
    • getProcessors

      public SafeArrayList<SceneProcessor> getProcessors()
      Gets the list of scene processors that were added to this ViewPort.
      Returns:
      the list of processors attached to this ViewPort
      See Also:
    • 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:
    • 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:
    • clearProcessors

      public void clearProcessors()
      Removes all scene 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

      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

      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:
    • getQueue

      public RenderQueue getQueue()
      Internal use only.
      Returns:
      the pre-existing instance
    • attachScene

      public void attachScene(Spatial scene)
      Attaches a new scene to render in this ViewPort.
      Parameters:
      scene - The scene to attach
      See Also:
    • detachScene

      public void detachScene(Spatial scene)
      Detaches a scene from rendering.
      Parameters:
      scene - The scene to detach
      See Also:
    • clearScenes

      public void clearScenes()
      Removes all attached scenes.
      See Also:
    • getScenes

      public SafeArrayList<Spatial> getScenes()
      Returns a list of all attached scenes.
      Returns:
      a list of all attached scenes.
      See Also:
    • 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:
    • 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: