AnchorNode | Node that is automatically positioned in world space based on an ARCore Anchor. |
AugmentedFaceNode | Node used to render visual effects on a face with ARCore's AugmentedFace
feature. |
BaseTransformableNode | Base class for nodes that can be transformed using gestures from TransformationSystem
. |
Camera | Represents a virtual camera, which determines the perspective through which the scene is viewed. |
SkeletonNode | A Node
that provides mappings between the bones of a skinned ModelRenderable
and
a set of Node
s. |
Sun | Represents the "sun" - the default directional light in the scene. |
A Node represents a transformation within the scene graph's hierarchy. It can contain a renderable for the rendering engine to render.
Each node can have an arbitrary number of child nodes and one parent. The parent may be another node, or the scene.
Nested Classes
Public Constructors
Public Methods
void | addLifecycleListener
( Node.LifecycleListener
lifecycleListener)
Adds a listener that will be called when node lifecycle events occur.
|
void | addTransformChangedListener
( Node.TransformChangedListener
transformChangedListener)
Adds a listener that will be called when the node's transformation changes.
|
void | callOnHierarchy
(Consumer< Node
> consumer)
Traverses the hierarchy and call a method on each node (including this node).
|
Node | findInHierarchy
(Predicate< Node
> condition)
Traverses the hierarchy to find the first node (including this node) that meets a condition.
|
final Vector3 | |
CollisionShape | |
final Vector3 | |
final Vector3 | |
final Vector3 | |
Light | |
final Vector3 | |
final Quaternion | |
final Vector3 | |
final String | |
final Node | |
Renderable | |
final Vector3 | |
final Scene | |
final Vector3 | |
final Vector3 | |
final Quaternion | |
final Vector3 | |
final boolean | |
final boolean | isDescendantOf
( NodeParent
ancestor)
Checks whether the given node parent is an ancestor of this node recursively.
|
final boolean | |
boolean | |
final Vector3 | localToWorldDirection
( Vector3
direction)
Converts a direction from the local-space of this node to world-space.
|
final Vector3 | |
void | |
void | |
boolean | onTouchEvent
( HitTestResult
hitTestResult, MotionEvent
motionEvent)
Handles when this node is touched.
|
void | |
void | |
void | removeLifecycleListener
( Node.LifecycleListener
lifecycleListener)
Removes a listener that will be called when node lifecycle events occur.
|
void | removeTransformChangedListener
( Node.TransformChangedListener
transformChangedListener)
Removes a listener that will be called when the node's transformation changes.
|
void | |
final void | |
void | |
void | setLocalPosition
( Vector3
position)
Sets the position of this node relative to its parent (local-space).
|
void | setLocalRotation
( Quaternion
rotation)
Sets the rotation of this node relative to its parent (local-space).
|
void | |
final void | setLookDirection
( Vector3
lookDirection)
Sets the direction that the node is looking at in world-space.
|
final void | setLookDirection
( Vector3
lookDirection, Vector3
upDirection)
Sets the direction that the node is looking at in world-space.
|
final void | |
void | setOnTapListener
( Node.OnTapListener
onTapListener)
Registers a callback to be invoked when this node is tapped.
|
void | setOnTouchListener
( Node.OnTouchListener
onTouchListener)
Registers a callback to be invoked when a touch event is dispatched to this node.
|
void | |
void | |
void | |
void | |
void | |
String | toString
()
|
final Vector3 | worldToLocalDirection
( Vector3
direction)
Converts a direction from world-space to the local-space of this node.
|
final Vector3 |
Protected Methods
final boolean | |
final void | |
final void |
Inherited Methods
Public Constructors
public Node ()
Creates a node with no parent.
Public Methods
public void addLifecycleListener ( Node.LifecycleListener lifecycleListener)
Adds a listener that will be called when node lifecycle events occur. The listeners will be called in the order in which they were added.
Parameters
public void addTransformChangedListener ( Node.TransformChangedListener transformChangedListener)
Adds a listener that will be called when the node's transformation changes.
Parameters
public void callOnHierarchy (Consumer< Node > consumer)
Traverses the hierarchy and call a method on each node (including this node). Traversal is depth first.
Parameters
public Node findInHierarchy (Predicate< Node > condition)
Traverses the hierarchy to find the first node (including this node) that meets a condition. Once the predicate is met, the traversal stops. Traversal is depth first.
Parameters
Returns
- the first node that matches the conditions of the predicate, otherwise null is returned
public final Vector3 getBack ()
Gets the world-space back vector (+z) of this node.
Returns
- a new vector that represents the node's back direction in world-space
public CollisionShape getCollisionShape ()
Gets the shape to use for collisions with this node. If the shape is null and setRenderable(Renderable)
is set, then getCollisionShape()
is used to
detect collisions for this Node
.
Returns
- represents a geometric shape, i.e. sphere, box, convex hull.
public final Vector3 getDown ()
Gets the world-space down vector (-y) of this node.
Returns
- a new vector that represents the node's down direction in world-space
public final Vector3 getForward ()
Gets the world-space forward vector (-z) of this node.
Returns
- a new vector that represents the node's forward direction in world-space
public final Vector3 getLeft ()
Gets the world-space left vector (-x) of this node.
Returns
- a new vector that represents the node's left direction in world-space
public Light getLight ()
Gets the current light, which is mutable.
public final Vector3 getLocalPosition ()
Gets a copy of the nodes position relative to its parent (local-space). If isTopLevel()
is true, then this is the same as getWorldPosition()
.
Returns
- a new vector that represents the node's local-space position
See Also
public final Quaternion getLocalRotation ()
Gets a copy of the nodes rotation relative to its parent (local-space). If isTopLevel()
is true, then this is the same as getWorldRotation()
.
Returns
- a new quaternion that represents the node's local-space rotation
See Also
public final Vector3 getLocalScale ()
Gets a copy of the nodes scale relative to its parent (local-space). If isTopLevel()
is true, then this is the same as getWorldScale()
.
Returns
- a new vector that represents the node's local-space scale
See Also
public final String getName ()
Returns the name of the node. The default value is "Node".
public final Node getParent ()
public Renderable getRenderable ()
Gets the renderable to display for this node.
Returns
- renderable to display for this node
public final Vector3 getRight ()
Gets the world-space right vector (+x) of this node.
Returns
- a new vector that represents the node's right direction in world-space
public final Scene getScene ()
Returns the scene that this node is part of, null if it isn't part of any scene. A node is part
of a scene if its highest level ancestor is a Scene
public final Vector3 getUp ()
Gets the world-space up vector (+y) of this node.
Returns
- a new vector that represents the node's up direction in world-space
public final Vector3 getWorldPosition ()
Get a copy of the nodes world-space position.
Returns
- a new vector that represents the node's world-space position
See Also
public final Quaternion getWorldRotation ()
Gets a copy of the nodes world-space rotation.
Returns
- a new quaternion that represents the node's world-space rotation
See Also
public final Vector3 getWorldScale ()
Gets a copy of the nodes world-space scale. Some precision will be lost if the node is skewed.
Returns
- a new vector that represents the node's world-space scale
See Also
public final boolean isActive ()
Returns true if the node is active. A node is considered active if it meets ALL of the following conditions:
- The node is part of a scene.
- the node's parent is active.
- The node is enabled.
- The node's
onUpdate(FrameTime)
function will be called every frame. - The node's
getRenderable()
will be rendered. - The node's
getCollisionShape()
will be checked in calls to Scene.hitTest. - The node's
onTouchEvent(HitTestResult, MotionEvent)
function will be called when the node is touched.
Returns
- the node's active status
See Also
public final boolean isDescendantOf ( NodeParent ancestor)
Checks whether the given node parent is an ancestor of this node recursively.
Parameters
Returns
- true if the node is an ancestor of this node
public final boolean isEnabled ()
Gets the enabled state of this node. Note that a Node may be enabled but still inactive if it isn't part of the scene or if its parent is inactive.
Returns
- the node's enabled status.
See Also
public boolean isTopLevel ()
Returns true if this node is top level. A node is considered top level if it has no parent or if the parent is the scene.
Returns
- true if the node is top level
public final Vector3 localToWorldDirection ( Vector3 direction)
Converts a direction from the local-space of this node to world-space. Not impacted by the position or scale of the node.
Parameters
Returns
- a new vector that represents the direction in world-space
public final Vector3 localToWorldPoint ( Vector3 point)
Converts a point in the local-space of this node to world-space.
Parameters
Returns
- a new vector that represents the point in world-space
public void onActivate ()
Handles when this node becomes active. A Node is active if it's enabled, part of a scene, and its parent is active.
Override to perform any setup that needs to occur when the node is activated.
See Also
public void onDeactivate ()
Handles when this node becomes inactivate. A Node is inactive if it's disabled, not part of a scene, or its parent is inactive.
Override to perform any setup that needs to occur when the node is deactivated.
See Also
public boolean onTouchEvent ( HitTestResult hitTestResult, MotionEvent motionEvent)
Handles when this node is touched.
Override to perform any logic that should occur when this node is touched. The way that touch events are propagated mirrors the way touches are propagated to Android Views. This is only called when the node is active.
When an ACTION_DOWN event occurs, that represents the start of a gesture. ACTION_UP or ACTION_CANCEL represents when a gesture ends. When a gesture starts, the following is done:
- Dispatch touch events to the node that was touched as detected by
hitTest(MotionEvent)
. - If the node doesn't consume the event, recurse upwards through the node's parents and dispatch the touch event until one of the node's consumes the event.
- If no nodes consume the event, the gesture is ignored and subsequent events that are part of the gesture will not be passed to any nodes.
- If one of the node's consumes the event, then that node will consume all future touch events for the gesture.
Node.OnTouchListener
. If the Node.OnTouchListener
doesn't handle the event, it is passed to onTouchEvent(HitTestResult, MotionEvent)
.Parameters
hitTestResult | Represents the node that was touched, and information about where it was
touched. On ACTION_DOWN events, getNode()
will always be this node or
one of its children. On other events, the touch may have moved causing the getNode()
to change (or possibly be null). |
---|---|
motionEvent | The motion event. |
Returns
- True if the event was handled, false otherwise.
public void onTransformChange ( Node originatingNode)
Handles when this node's transformation is changed.
The originating node is the most top-level node in the hierarchy that triggered this node to
change. It will always be either the same node or one of its' parents. i.e. if node A's
position is changed, then that will trigger onTransformChange(Node)
to be called for
all of it's children with the originatingNode being node A.
Parameters
public void onUpdate ( FrameTime frameTime)
Handles when this node is updated. A node is updated before rendering each frame. This is only called when the node is active.
Override to perform any updates that need to occur each frame.
Parameters
public void removeLifecycleListener ( Node.LifecycleListener lifecycleListener)
Removes a listener that will be called when node lifecycle events occur.
Parameters
public void removeTransformChangedListener ( Node.TransformChangedListener transformChangedListener)
Removes a listener that will be called when the node's transformation changes.
Parameters
public void setCollisionShape ( CollisionShape collisionShape)
Sets the shape to used to detect collisions for this Node
. If the shape is not set and setRenderable(Renderable)
is set, then getCollisionShape()
is
used to detect collisions for this Node
.
Parameters
public final void setEnabled (boolean enabled)
Sets the enabled state of this node. Note that a Node may be enabled but still inactive if it isn't part of the scene or if its parent is inactive.
Parameters
See Also
public void setLight ( Light light)
Sets the Light
to display. To use, first create a Light
using Light.Builder
. Set the parameters you care about and then attach it to the node using this
function. A node may have a renderable and a light or just act as a Light
.
Parameters
public void setLocalPosition ( Vector3 position)
Sets the position of this node relative to its parent (local-space). If isTopLevel()
is true, then this is the same as setWorldPosition(Vector3)
.
Parameters
See Also
public void setLocalRotation ( Quaternion rotation)
Sets the rotation of this node relative to its parent (local-space). If isTopLevel()
is true, then this is the same as setWorldRotation(Quaternion)
.
Parameters
See Also
public void setLocalScale ( Vector3 scale)
Sets the scale of this node relative to its parent (local-space). If isTopLevel()
is
true, then this is the same as setWorldScale(Vector3)
.
Parameters
See Also
public final void setLookDirection ( Vector3 lookDirection)
Sets the direction that the node is looking at in world-space. After calling this, getForward()
will match the look direction passed in. World-space up (0, 1, 0) will be
used to determine the orientation of the node around the direction.
Parameters
public final void setLookDirection ( Vector3 lookDirection, Vector3 upDirection)
Sets the direction that the node is looking at in world-space. After calling this, getForward()
will match the look direction passed in. The up direction will determine the
orientation of the node around the direction. The look direction and up direction cannot be
coincident (parallel) or the orientation will be invalid.
Parameters
lookDirection | a vector representing the desired look direction in world-space |
---|---|
upDirection | a vector representing a valid up vector to use, such as Vector3.up() |
public final void setName ( String name)
Sets the name of this node. Nodes can be found using their names. Multiple nodes may have the
same name, in which case calling findByName(String)
will return the first
node with the given name.
Parameters
public void setOnTapListener ( Node.OnTapListener onTapListener)
Registers a callback to be invoked when this node is tapped. If there is a callback registered, then touch events will not bubble to this node's parent. If the Node.onTouchEvent is overridden and super.onTouchEvent is not called, then the tap will not occur.
Parameters
See Also
public void setOnTouchListener ( Node.OnTouchListener onTouchListener)
Registers a callback to be invoked when a touch event is dispatched to this node. The way that touch events are propagated mirrors the way touches are propagated to Android Views. This is only called when the node is active.
When an ACTION_DOWN event occurs, that represents the start of a gesture. ACTION_UP or ACTION_CANCEL represents when a gesture ends. When a gesture starts, the following is done:
- Dispatch touch events to the node that was touched as detected by
hitTest(MotionEvent)
. - If the node doesn't consume the event, recurse upwards through the node's parents and dispatch the touch event until one of the node's consumes the event.
- If no nodes consume the event, the gesture is ignored and subsequent events that are part of the gesture will not be passed to any nodes.
- If one of the node's consumes the event, then that node will consume all future touch events for the gesture.
Node.OnTouchListener
. If the Node.OnTouchListener
doesn't handle the event, it is passed to onTouchEvent(HitTestResult, MotionEvent)
.Parameters
See Also
public void setParent ( NodeParent parent)
Changes the parent node of this node. If set to null, this node will be detached from its parent. The local position, rotation, and scale of this node will remain the same. Therefore, the world position, rotation, and scale of this node may be different after the parent changes.
The parent may be another Node
or a Scene
. If it is a scene, then this Node
is considered top level. getParent()
will return null, and getScene()
will return the scene.
Parameters
See Also
public void setRenderable ( Renderable renderable)
Sets the Renderable
to display for this node. If setCollisionShape(CollisionShape)
is not set, then getCollisionShape()
is used to detect collisions for this Node
.
Parameters
See Also
public void setWorldPosition ( Vector3 position)
Sets the world-space position of this node.
Parameters
See Also
public void setWorldRotation ( Quaternion rotation)
Sets the world-space rotation of this node.
Parameters
See Also
public void setWorldScale ( Vector3 scale)
Sets the world-space scale of this node.
Parameters
See Also
public String toString ()
public final Vector3 worldToLocalDirection ( Vector3 direction)
Converts a direction from world-space to the local-space of this node. Not impacted by the position or scale of the node.
Parameters
Returns
- a new vector that represents the direction in local-space
Protected Methods
protected final boolean canAddChild ( Node child, StringBuilder failureReason)
Parameters
child |
---|
failureReason |