Class Stage
- All Implemented Interfaces:
StageSubscriber
While the scene has full control over the stage, this control cannot outlive the scene itself: at the end of the scene the contents of the stage are cleared so the next scene can take over.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStage(GraphicsMode graphicsMode, Canvas canvas) Creates a new stage that will be drawn to the specified canvas, using the specified graphics mode. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new container, then adds it to the root of the scene graph.addContainer(String name) Creates a new container with the specified name, then adds it to the root of the scene graph.Creates a new group with the specified name, then adds it to the root container for 3D graphics to make it part of the stage.voidclear()Removes all 2D and 3D graphics from the stage.voiddetach(StageNode2D node) Detaches the specified node from the scene graph.voiddetach(StageNode3D node) Detaches the specified node from the scene graph.findNodePath(StageNode2D node) Returns the path towards the specified node.findNodePath(StageNode3D node) Returns the path towards the specified node.getRoot()voidonNodeAdded(Container parent, StageNode2D node) voidonNodeAdded(Group parent, StageNode3D node) voidonNodeRemoved(Container parent, StageNode2D node) voidonNodeRemoved(Group parent, StageNode3D node) voidRecalculates the global transform for the specified node.voidRecalculates the global transform for the specified node.voidsetAmbientLightColor(ColorRGB ambientLightColor) voidsetBackgroundColor(ColorRGB backgroundColor) voidsetCameraFocus(Point3D cameraFocus) voidsetCameraPosition(Point3D cameraPosition) voidsetParentMap2D(Map<StageNode2D, Container> parentMap2D) voidsetParentMap3D(Map<StageNode3D, Group> parentMap3D) voidsubscribe(StageSubscriber subscriber) Subscribes to this stage, receiving events every time nodes are added or removed.toString()Returns a textual representation of the stage's current contents, which can be used for testing and debugging purposes.voidvisit(StageVisitor visitor) Visits all nodes that are currently part of the stage.
-
Field Details
-
DEFAULT_AMBIENT_LIGHT_COLOR
-
-
Constructor Details
-
Stage
Creates a new stage that will be drawn to the specified canvas, using the specified graphics mode.
-
-
Method Details
-
onNodeAdded
- Specified by:
onNodeAddedin interfaceStageSubscriber
-
onNodeRemoved
- Specified by:
onNodeRemovedin interfaceStageSubscriber
-
onNodeAdded
- Specified by:
onNodeAddedin interfaceStageSubscriber
-
onNodeRemoved
- Specified by:
onNodeRemovedin interfaceStageSubscriber
-
addContainer
Creates a new container, then adds it to the root of the scene graph. Returns the container that was just created. This is a convenience method to easily create top-level containers. -
addContainer
Creates a new container with the specified name, then adds it to the root of the scene graph. Returns the container that was just created. This is a convenience method to easily create top-level containers. -
addGroup
Creates a new group with the specified name, then adds it to the root container for 3D graphics to make it part of the stage. -
detach
Detaches the specified node from the scene graph. If the node is not currently part of the stage, calling this method does nothing.Prefer using
Container.removeChild(StageNode2D)over this method, as it has better performance. This method exists for convenience, as it does not require references to both parent and child, and can be used in situations that are not performance-critical. -
detach
Detaches the specified node from the scene graph. If the node is not currently part of the stage, calling this method does nothing.Prefer using
Group.removeChild(StageNode3D)over this method, as it has better performance. This method exists for convenience, as it does not require references to both parent and child, and can be used in situations that are not performance-critical. -
clear
public void clear()Removes all 2D and 3D graphics from the stage. This is always called at the end of a scene, but can also be used manually mid-scene. -
visit
Visits all nodes that are currently part of the stage. Nodes will be visited in the order in which they should be drawn. Parent nodes will be visited before their children. -
subscribe
Subscribes to this stage, receiving events every time nodes are added or removed. -
findNodePath
Returns the path towards the specified node. The first element in the list is the root node, the last element is the node itself. If the node is not currently part of the stage, this returns a list containing only the node itself. -
findNodePath
Returns the path towards the specified node. The first element in the list is the root node, the last element is the node itself. If the node is not currently part of the stage, this returns a list containing only the node itself. -
recalculateGlobalTransform
Recalculates the global transform for the specified node. The global transform is normally updated at the end of each frame update when the node is drawn. This method can be used to force-recalculate the global transform for a single node.Since the global transform is relative to the node's parent, this will also recalculate the global transform for its parents, recursively. This method therefore has a performance impact, and should only be used on/for a limited number of nodes per frame update.
-
recalculateGlobalTransform
Recalculates the global transform for the specified node. The global transform is normally updated at the end of each frame update when the node is drawn. This method can be used to force-recalculate the global transform for a single node.Since the global transform is relative to the node's parent, this will also recalculate the global transform for its parents, recursively. This method therefore has a performance impact, and should only be used on/for a limited number of nodes per frame update.
-
toString
Returns a textual representation of the stage's current contents, which can be used for testing and debugging purposes. -
getGraphicsMode
-
getCanvas
-
getAnimationTimer
-
getRoot
-
getBackgroundColor
-
getParentMap2D
-
getRoot3D
-
getCameraPosition
-
getCameraFocus
-
getAmbientLightColor
-
getParentMap3D
-
setBackgroundColor
-
setParentMap2D
-
setCameraPosition
-
setCameraFocus
-
setAmbientLightColor
-
setParentMap3D
-