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 TypeMethodDescriptiondefault voidAttaches a sub-scene, based on the specified callback, to the currently active scene.default voidAttaches a sub-scene to the currently active scene.default voidAttaches a sub-scene, based on the specified callback, to the currently active scene.default voidattach(Updatable onFrame, BooleanSupplier completed, Runnable onComplete) Creates a sub-scene using the specified callback methods, then attaches that sub-scene to the currently active scene.default <T> nl.colorize.util.Subject<T> attach(nl.colorize.util.EventQueue<T> eventQueue) Attaches a sub-scene that processes anEventQueueduring frame updates.default <T> voidAttaches a sub-scene that processes anEventQueueusing the provided callback functions.default voidattachClickHandler(StageNode2D node, Runnable callback) Attaches a sub-scene that will invoke the specified callback function when the specified graphics are clicked.default voidattachGlobalSubScene(Scene globalSubScene) Attaches a sub-scene that is not tied to the currently active scene, and will remain active for as long as the application is active.default voidattachTimeline(nl.colorize.util.animation.Timeline timeline, Consumer<Float> callback) Attaches a sub-scene that will (A) update the timeline during every frame update, (B) invoke the callback function with the timeline's value.default voidattachTimeline(nl.colorize.util.animation.Timeline timeline, Consumer<Float> callback, Runnable onComplete) Attaches a sub-scene that will (A) update the timeline during every frame update, (B) invoke the callback function with the timeline's value.default voidattachTimer(float delay, Runnable callback) Attaches a sub-scene that will (A) update the timer during every frame update, (B) invoke the specified callback function exactly once when the timer has completed.default voidattachTimer(Timer timer, Runnable callback) Attaches a sub-scene that will (A) update the timer during every frame update, (B) invoke the specified callback function exactly once when the timer has completed.booleancastPickRay(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 voidchangeScene(Scene requestedScene) Requests to change the active scene after the current frame update has been completed.default MeshcreateMesh(Shape3D shape) 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 CanvasReturns debug and support information that can be displayed when running a MultimediaLib application in debug mode.default FrameStatsgetInput()Returns the display name for the underlying renderer.getStage()Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.voidtakeScreenshot(File screenshotFile) Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.voidTerminates the renderer, which will end the animation loop and quit the application.
-
Method Details
-
getConfig
RenderConfig getConfig() -
getCanvas
-
getMediaLoader
MediaLoader getMediaLoader() -
getInput
InputDevice getInput() -
getNetwork
Network getNetwork() -
getSceneManager
SceneManager getSceneManager() -
getStage
Stage getStage() -
getFrameStats
-
changeScene
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
Attaches a sub-scene to the currently active scene. The sub-scene will remain active untilScene.isCompleted()returns true or the parent scene ends.- See Also:
-
attach
Creates a sub-scene using the specified callback methods, then attaches that sub-scene to the currently active scene. The sub-scene will remain active untilcompletedreturns true or the parent scene ends.- See Also:
-
attach
Attaches a sub-scene, based on the specified callback, to the currently active scene. The sub-scene will remain active until the parent scene ends. -
attach
Attaches a sub-scene, based on the specified callback, to the currently active scene. The sub-scene will remain active until the parent scene ends. -
attach
default <T> void attach(nl.colorize.util.EventQueue<T> events, Consumer<T> onEvent, Consumer<Exception> onError) Attaches a sub-scene that processes anEventQueueusing the provided callback functions. This ensures asynchronous events are processed during frame updates, instead of when they are received. -
attach
default <T> nl.colorize.util.Subject<T> attach(nl.colorize.util.EventQueue<T> eventQueue) Attaches a sub-scene that processes anEventQueueduring frame updates. This returns aSubjectthat only publishes events during frame updates, instead of publishing events whenever they arrive. -
attachTimer
-
attachTimer
Attaches a sub-scene that will (A) update the timer during every frame update, (B) invoke the specified callback function exactly once when the timer has completed. This method is effectively performing an action with a time delay. -
attachTimeline
default void attachTimeline(nl.colorize.util.animation.Timeline timeline, Consumer<Float> callback, Runnable onComplete) Attaches a sub-scene that will (A) update the timeline during every frame update, (B) invoke the callback function with the timeline's value. The sub-scene will run until the timeline is completed. -
attachTimeline
-
attachClickHandler
Attaches a sub-scene that will invoke the specified callback function when the specified graphics are clicked.Note: This should be called "pointer released handler", since it also supports touch events. The term "click handler" exists for historic reasons.
-
attachGlobalSubScene
Attaches a sub-scene that is not tied to the currently active scene, and will remain active for as long as the application is active.- See Also:
-
createMesh
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
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 usingMesh.applyColor(ColorRGB)andMesh.applyTexture(Image)respectively.- Throws:
UnsupportedOperationException- if this renderer does not support 3D graphics.
-
project
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
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
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
-