Interface SceneContext


public interface SceneContext
The currently active scene (and its sub-scenes) receive access to the scene context, which is provided by the renderer via callback methods. This allows the scene to access the underlying renderer and the stage.

The stage contains the graphics and audio for the currently active scene. The stage can contain both 2D and 3D graphics, depending on what is supported by the renderer. At the end of a scene, the stage is cleared so the next scene can take over.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    attach(Runnable subScene)
    Wraps a Runnable so that is acts as a sub-scene for the currently active scene.
    default void
    attach(Scene subScene)
    Attaches a sub-scene to the currently active scene.
    default void
    attach(Updatable subScene)
    Attaches an Updatable to act as a sub-scene for the currently active scene.
    default void
    attachGlobal(Scene globalSubScene)
    Attaches a scene that is *not* tied to the currently active scene, and will remain active for the rest of the application.
    boolean
    castPickRay(Point2D canvasPosition, Box area)
    Casts a pick ray from the specified 2D canvas position, and returns true if the pick ray intersects with the specified 3D world coordinates.
    default void
    changeScene(Scene requestedScene)
    Requests to change the active scene after the current frame update has been completed.
    default Mesh
    Programmatically creates a 3D polygon mesh that initially does not have any color or texture information attached to it.
    createMesh(Shape3D shape, ColorRGB color)
    Programmatically creates a 3D polygon mesh with a solid color, based on the specified shape.
    default Canvas
     
     
    default List<String>
    Returns debug and support information that can be displayed when running a MultimediaLib application in debug mode.
    default FrameStats
     
     
     
     
    Returns the display name for the underlying renderer.
     
     
    project(Point3D position)
    Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.
    void
    takeScreenshot(File screenshotFile)
    Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.
    void
    Terminates the renderer, which will end the animation loop and quit the application.
  • Method Details

    • getConfig

      RenderConfig getConfig()
    • getCanvas

      default Canvas getCanvas()
    • getMediaLoader

      MediaLoader getMediaLoader()
    • getInput

      InputDevice getInput()
    • getNetwork

      Network getNetwork()
    • getSceneManager

      SceneManager getSceneManager()
    • getStage

      Stage getStage()
    • getFrameStats

      default FrameStats getFrameStats()
    • changeScene

      default void changeScene(Scene requestedScene)
      Requests to change the active scene after the current frame update has been completed. If another scene had already been requested, calling this method again will overrule that request.
    • attach

      default void attach(Scene subScene)
      Attaches a sub-scene to the currently active scene. The sub-scene will remain active until it is detached or the parent scene ends.
    • attach

      default void attach(Updatable subScene)
      Attaches an Updatable to act as a sub-scene for the currently active scene. The sub-scene will remain active until it is detached or the parent scene ends.
    • attach

      default void attach(Runnable subScene)
      Wraps a Runnable so that is acts as a sub-scene for the currently active scene. The sub-scene will remain active until it is detached or the parent scene ends.
    • attachGlobal

      default void attachGlobal(Scene globalSubScene)
      Attaches a scene that is *not* tied to the currently active scene, and will remain active for the rest of the application. Multiple global scenes can be attached.
    • createMesh

      Mesh createMesh(Shape3D shape, ColorRGB color)
      Programmatically creates a 3D polygon mesh with a solid color, based on the specified shape.
      Throws:
      UnsupportedOperationException - if this renderer does not support 3D graphics.
    • createMesh

      default Mesh createMesh(Shape3D shape)
      Programmatically creates a 3D polygon mesh that initially does not have any color or texture information attached to it. The mesh can be modified after creation using Mesh.applyColor(ColorRGB) and Mesh.applyTexture(Image) respectively.
      Throws:
      UnsupportedOperationException - if this renderer does not support 3D graphics.
    • project

      Point2D project(Point3D position)
      Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.
      Throws:
      UnsupportedOperationException - if this renderer does not support 3D graphics.
    • castPickRay

      boolean castPickRay(Point2D canvasPosition, Box area)
      Casts a pick ray from the specified 2D canvas position, and returns true if the pick ray intersects with the specified 3D world coordinates.
      Throws:
      UnsupportedOperationException - if this renderer does not support 3D graphics.
    • takeScreenshot

      void takeScreenshot(File screenshotFile)
      Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.
      Throws:
      UnsupportedOperationException - if this renderer does not support taking screenshots at runtime.
    • terminate

      void terminate()
      Terminates the renderer, which will end the animation loop and quit the application.
      Throws:
      UnsupportedOperationException - if the current platform does not support terminating applications.
    • getRendererName

      String getRendererName()
      Returns the display name for the underlying renderer. The display name will not include the word "renderer".
    • getDebugInformation

      default List<String> getDebugInformation()
      Returns debug and support information that can be displayed when running a MultimediaLib application in debug mode. The returned list is intended to be displayed in a Text, which can be styled to match the application appearance.