Class Node
- java.lang.Object
-
- nub.core.Node
-
public class Node extends Object
A node encapsulates a 2D or 3D coordinate system, represented by aposition()
, anorientation()
andmagnitude()
defined respect to areference()
node. The order of these transformations is important: the node is first translated, then rotated around the new translated origin and then scaled.Hierarchy of nodes
The defaultreference()
node is the world coordinate system (represented by anull
). If yousetReference(Node)
to a different node, you must then differentiate:- The local
position()
,orientation()
andmagnitude()
, defined with respect to thereference()
which represents an angle preserving transformation of space. - The global
worldPosition()
,worldOrientation()
andworldMagnitude()
, always defined with respect to the world coordinate system.
Geometry transformations
A node is useful to define the position, orientation and magnitude of an arbitrary object which may represent a point-of-view.Use
matrix()
to access the node coordinate system, as when drawing an object locally:// Builds a node at position (0.5,0,0) and oriented such that its Y axis is along the (1,1,1)
direction
Node node = new Node(new Vector(0.5,0,0), new Quaternion(new Vector(0,1,0), new Vector(1,1,1)));
push();
applyMatrix(node.matrix());
// Draw your object here, in the local node coordinate system.
pop();
Use
view()
when rendering the scene from the node point-of-view. Note that this method is automatically called by the graph, seeGraph.render(Node)
.To transform a point from one node to another use
location(Vector, Node)
andworldLocation(Vector)
. To transform a vector (such as a normal) usedisplacement(Vector, Node)
andworldDisplacement(Vector)
. To transform a quaternion usedisplacement(Quaternion, Node)
andworldDisplacement(Quaternion)
. To transform a scalar usedisplacement(float, Node)
andworldDisplacement(float)
.The methods
translate(Vector, float)
,rotate(Quaternion, float)
,orbit(Vector, float, Vector, float)
andscale(float, float)
, locally apply differential geometry transformations damped with a giveninertia
. Note that when the inertial parameter is omitted its value is defaulted to 0.Hierarchical traversals
Hierarchical traversals of the node hierarchy which automatically apply the local node transformations described above may be achieved withGraph.render()
andGraph.render(Node)
. Customize the rendering traversal withGraph.addBehavior(Node, BiConsumer)
(see alsocull
andbypass()
).Motion filters
One interesting feature of a node is that its displacements can be filtered. Setting a node filter allows to refine the input oftranslate(Vector)
,rotate(Quaternion)
,orbit(Vector, float)
andscale(float)
so that only the resulting filtered motion is applied to the node. The default filters arenull
resulting in no filtering. UsesetTranslationFilter(BiFunction, Object[])
,setRotationFilter(BiFunction, Object[])
andsetScalingFilter(BiFunction, Object[])
to set different filters to a node.Classical filters are provided for convenience (see
translationAxisFilter
,translationPlaneFilter
androtationAxisFilter
) and new filters can very easily be implemented.Visual hints
The node space visual representation may be configured using the following hints:CAMERA
,AXES
,HUD
,BOUNDS
,,SHAPE
,BULLSEYE
, andTORUS
.See
hint()
,configHint(int, Object...)
enableHint(int)
,enableHint(int, Object...)
,disableHint(int)
,toggleHint(int)
andresetHint()
.Ray casting
Set the node picking ray-casting mode withenablePicking(int)
(see alsopicking()
).Keyframe's based interpolated animations
Keyframes allow to define the position, orientation and magnitude a node (including the eye) should have at a particular moment in time. The node may then be animated through a Catmull-Rom spline, matching in space-time the key-frames which defines it. To define the keyframes comprising the path to be interpolated use code such as the following:Node shape = new Node(pshape); for (int i = 0; i < random(4, 10); i++) { scene.randomize(shape); // addKeyFrame(hint, elapsedTime) where elapsedTime is defined respect // to the previously added key-frame and expressed in milliseconds. shape.addKeyFrame(Node.AXES | Node.SHAPE, i % 2 == 1 ? 1000 : 4000); }
addKeyFrame()
,addKeyFrame(int, float)
, andaddKeyFrame(Node, float)
for the details.To then interpolate the path at a given
time
(expressed in milliseconds) callinterpolate(float)
. To play the path starting at thattime
, callanimate()
(see alsotoggleAnimation()
andresetAnimation()
). To disable/enableanimationRecurrence()
usesetAnimationRecurrence(boolean)
(it is disabled by default). Note that theanimationTime()
may set withsetAnimationTime(float)
.Custom behaviors
A custom node behavior to be executed during renderingGraph.render()
may be set withsetBehavior(Graph, Consumer)
. SeeGraph.addBehavior(Node, BiConsumer)
.Custom user interactions
Implementing a custom user interaction for node is a two step process:- Register a user gesture data parser, see
setInteraction(BiConsumer)
andsetInteraction(Consumer)
. - Send gesture data to the node by calling
Graph.interact(Node, Object...)
,Graph.interact(String, Object...)
orGraph.interact(Object...)
.
- The local
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Node.BullsEyeShape
-
Field Summary
Fields Modifier and Type Field Description static int
AXES
static int
BONE
static int
BOUNDS
static int
BULLSEYE
float
cacheMagnitude
Quaternion
cacheOrientation
Vector
cachePosition
Object[]
cacheRotationParams
Object[]
cacheScalingParams
float
cacheTargetMagnitude
Quaternion
cacheTargetOrientation
Vector
cacheTargetPosition
Quaternion
cacheTargetRotation
float
cacheTargetScaling
Vector
cacheTargetTranslation
Object[]
cacheTranslationParams
static int
CAMERA
boolean
cull
static int
FILTER
static BiFunction<Node,Object[],Quaternion>
forbidRotationFilter
Filters rotation so that it gets nullified.static BiFunction<Node,Object[],Float>
forbidScalingFilter
Filters scaling so that it gets nullified.static BiFunction<Node,Object[],Vector>
forbidTranslationFilter
Filters translation so that it gets nullified.static int
HUD
static int
KEYFRAMES
static int
maxSteps
static BiFunction<Node,Object[],Float>
minMaxScalingFilter
Filters scaling so that the node magnitude lies in[min..max]
.static BiFunction<Node,Object[],Quaternion>
rotationAxisFilter
Filtersquaternion
so that itsQuaternion.axis()
becomeaxis
(defined in this node coordinate system).static int
SHAPE
boolean
tagging
static int
TORUS
static BiFunction<Node,Object[],Vector>
translationAxisFilter
Filters translation so that the node is translated alongaxis
(defined in this node coordinate system).static BiFunction<Node,Object[],Vector>
translationPlaneFilter
Filters translation so that the node is translated along the plane defined bynormal
(defined in this node coordinate system).
-
Constructor Summary
Constructors Constructor Description Node()
Same asthis(null, new Vector(), new Quaternion(), 1)
.Node(boolean attach)
Same as {this(null, new Vector(), new Quaternion(), 1, attach)}.Node(Consumer<PGraphics> shape)
Same asthis(null, shape, new Vector(), new Quaternion(), 1)
.Node(Node reference)
Same asthis(reference, new Vector(), new Quaternion(), 1)
.Node(Node reference, Consumer<PGraphics> shape)
Same asthis(reference, shape, new Vector(), new Quaternion(), 1)
.Node(Node reference, Consumer<PGraphics> shape, Vector position, Quaternion orientation, float magnitude)
CallsNode(Node, Vector, Quaternion, float)
and thensetShape(Consumer)
.Node(Node reference, Vector position)
Same asthis(reference, position, new Quaternion(), 1
.Node(Node reference, Vector position, Quaternion orientation)
Same asthis(reference, position, orientation, 1
.Node(Node reference, Vector position, Quaternion orientation, float magnitude)
Creates a node withreference
asreference()
, havingposition
,orientation
andmagnitude
as theposition()
,orientation()
andmagnitude()
, respectively.Node(Node reference, PShape shape)
Same asthis(reference, shape, new Vector(), new Quaternion(), 1)
.Node(Node reference, PShape shape, Vector position, Quaternion orientation, float magnitude)
Creates a node withreference
asreference()
andshape
, havingposition
,orientation
andmagnitude
as theposition()
,orientation()
andmagnitude()
, respectively.Node(Vector position)
Same asthis(null, position, new Quaternion(), 1)
.Node(Vector position, boolean attach)
Same asthis(null, position, new Quaternion(), 1, attach)
.Node(Vector position, Quaternion orientation)
Same asthis(null, position, orientation, 1)
.Node(Vector position, Quaternion orientation, boolean attach)
Same asthis(null, position, orientation, 1, attach)
.Node(Vector position, Quaternion orientation, float magnitude)
Same asthis(null, position, orientation, magnitude)
.Node(Vector position, Quaternion orientation, float magnitude, boolean attach)
Same asthis(null, position, orientation, magnitude, attach)
.Node(PShape shape)
Same asthis(null, shape, new Vector(), new Quaternion(), 1)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKeyFrame()
Adds a node copy as keyframe at0
time if there are no currently keyframes in the path.void
addKeyFrame(int hint, float time)
Adds a node copy as a keyframe attime
(in milliseconds) and a maskhint
.void
addKeyFrame(Node node)
Addsnode
(as is) as a keyframe.void
addKeyFrame(Node node, float time)
Addsnode
(as is) as a keyframe at the giventime
(in milliseconds).void
align()
Same asalign(null)
.void
align(boolean move)
Same asalign(move, null)
.void
align(boolean move, float threshold)
Same asalign(move, threshold, null)
.void
align(boolean move, float threshold, Node node)
Aligns the node withnode
, so that two of their axis are parallel.void
align(boolean move, Node node)
Convenience function that simply callsalign(move, 0.85f, node)
.void
align(float threshold)
Same asalign(threshold, null)
.void
align(float threshold, Node node)
Convenience function that simply callsalign(false, threshold, node)
.void
align(Node node)
Convenience function that simply callsalign(false, 0.85f, node)
void
animate()
Run the animation defined by the node keyframes.void
animate(float speed)
Run the animation with the givenspeed
defined by the node keyframes.boolean
animationRecurrence()
Tells whether or not the keyframes animation is recurrent or not.float
animationTime()
Returns the current interpolation time (in milliseconds) along the keyframes path.void
attach()
Attaches the branch to which this node belongs to the tree so that this node (together with all nodes in the branch) is reached from theGraph.render()
algorithm.static float
blueID(int id)
Convert intid
to blue.float
bullsEyeSize()
void
bypass()
Bypass rendering the node for the current frame.List<Node>
children()
Returns the list a child nodes of this node.int
colorID()
Uniquely identifies the node.static int
colorID(int id)
Convert intid
to color.void
configHint(int hint, Object... params)
Configures the hint using varargs as follows:Node
copy()
Same asreturn copy(true)
.Node
copy(boolean recursive)
Performs a deep copy of this node, and its descendants iffrecursive
istrue
.void
detach()
Detach node from the tree so that it's not reached from theGraph.render()
algorithm and make all the nodes in thenode
branch eligible for garbage collection.void
disableHint(int hint)
Disables all the single visual hints encoded in the bitwise-orhint
mask.void
disablePicking(int hint)
Disables all the single visual hints encoded in the bitwise-orhint
mask.float
displacement(float scalar)
Convertsscalar
displacement from world to this node.float
displacement(float scalar, Node node)
Convertsscalar
displacement fromnode
to this node.Quaternion
displacement(Quaternion quaternion)
Convertsquaternion
displacement from world to this node.Quaternion
displacement(Quaternion quaternion, Node node)
Convertsquaternion
displacement fromnode
to this node.Vector
displacement(Vector vector)
Convertsvector
displacement from world to this node.Vector
displacement(Vector vector, Node node)
Convertsvector
displacement fromnode
to this node.void
enableHint(int hint)
Enables all single visual hints encoded in the bitwise-orhint
mask.void
enableHint(int hint, Object... params)
CallsenableHint(int)
followed byconfigHint(int, Object...)
.void
enablePicking(int picking)
Enables all single visual hints encoded in the bitwise-orpickingMode
mask.void
fromMatrix(Matrix matrix)
Sets the node from amatrix()
representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.void
fromWorldMatrix(Matrix matrix)
Sets the node fromworldMatrix()
representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.static float
greenID(int id)
Convert intid
to green.float
highlight()
Returns the highlighting magnitude use to scale the node when it's tagged.int
hint()
Returns the current visual hint mask.int
id()
Returns the unique sequential node id assigned at instantiation time.void
interact(Object[] gesture)
Parsegesture
params.void
interpolate(float time)
Interpolate the node at the given time (in milliseconds) along the keyframes path.Node
inverse()
Node
inverse(boolean attach)
Returns a node representing the inverse of this node space transformation.boolean
isAncestor(Node node)
Returnstrue
ifnode
is ancestor ofthis
node.static boolean
isAncestor(Node successor, Node ancestor)
Same asreturn successor.isAncestor(ancestor)
.boolean
isAttached()
Returns whether or not the node is reachable by the rendering algorithm.boolean
isEye()
Returns whether or not this node is some graphGraph.eye()
.boolean
isEye(Graph graph)
Returns whether or not this node is the givengraph
Graph.eye()
.boolean
isHintEnabled(int hint)
Returns whether or not all single visual hints encoded in the bitwise-orhint
mask are enable or not.boolean
isPickingEnabled(int hint)
Returns whether or not all hints encoded in the bitwise-orhint
mask are enable for node picking with ray casting.boolean
isReference(Node node)
boolean
isTagged(Graph graph)
Returnstrue
if thenode
has been tagged by thegraph
at least once andfalse
otherwise.long
lastUpdate()
float
localDisplacement(float scalar)
Convertsscalar
displacement fromreference()
to this node.Quaternion
localDisplacement(Quaternion quaternion)
Convertsquaternion
displacement fromreference()
to this node.Vector
localDisplacement(Vector vector)
Convertsvector
displacement fromreference()
to this node.Vector
localLocation(Vector vector)
Convertsvector
location fromreference()
to this node.Vector
location(Node node)
Converts thenode
origin location to this node.Vector
location(Vector vector)
Convertsvector
location from world to this node.Vector
location(Vector vector, Node node)
Convertsvector
location fromnode
to this node.float
magnitude()
Returns the node magnitude, defined with respect to thereference()
.boolean
matches(Node node)
Returns whether this node matches other taking into account theworldPosition()
,worldOrientation()
andworldMagnitude()
node parameters.Matrix
matrix()
Returns the local transformation matrix represented by the node.void
orbit(Vector axis, float angle)
Rotates the node aroundaxis
passing through the origin, both defined in the world coordinate system.void
orbit(Vector axis, float angle, float inertia)
Same asorbit(axis, angle, new Vector(), inertia)
.void
orbit(Vector axis, float angle, Vector center)
Rotates the node aroundaxis
passing throughcenter
, both defined in the world coordinate system.void
orbit(Vector axis, float angle, Vector center, float inertia)
Same asorbit(new Quaternion(displacement(axis), angle), center, inertia)
.Quaternion
orientation()
Returns the node orientation, defined with respect to thereference()
(i.e, the current Quaternion orientation).static List<Node>
path(Node tail, Node tip)
Returns an array containing a straight path of nodes fromtail
totip
.int
picking()
Returns the current visual picking hint mask encoding the visual aspects that are to be taken into account for picking the node with ray casting.Vector
position()
Returns the node position, defined with respect to thereference()
.void
projectOnLine(Vector origin, Vector direction)
Translates the node so that itsworldPosition()
lies on the line defined byorigin
anddirection
(defined in the world coordinate system).static Node
random(Graph graph)
Returns a random node attached tograph
.static Node
random(Vector center, float radius, boolean is3D)
Returns a random node.void
randomize(Vector center, float radius, boolean is3D)
Randomized this node.static float
redID(int id)
Convert intid
to red.Node
reference()
Returns the reference node, in which this node is defined.float
referenceDisplacement(float scalar)
Convertsscalar
displacement from this node toreference()
.Quaternion
referenceDisplacement(Quaternion quaternion)
Convertsquaternion
displacement from this node toreference()
.Vector
referenceDisplacement(Vector vector)
Convertsvector
displacement from this node toreference()
.Vector
referenceLocation(Vector vector)
Convertsvector
location from this node toreference()
.Node
removeKeyFrame(float time)
Remove the closest keyframe totime
(in milliseconds) and returns it.void
removeKeyFrames()
Removes all keyframes from the animation path.boolean
rendered(Graph graph)
Tells whether the node was rendered in the last frame fromgraph
after a call toGraph.render(Node)
is issued.void
reset()
void
resetAnimation()
Resets the node animation.void
resetBehavior(Graph graph)
Same asgraph.resetBehavior(this)
.void
resetHint()
Resets the currenthint()
, i.e., disables all single visual hints available for the node.void
resetHUD()
Same as callingresetRMRHUD()
andresetIMRHUD()
.void
resetIMRHUD()
Same assetIMRShape(null)
.void
resetIMRShape()
Resets the immediate-mode rendering shape.void
resetInertia()
Stops all node inertia's.void
resetPicking()
Resetspicking()
, i.e., disables all single visual hints available for node picking with ray casting.void
resetReference()
Setsreference()
to the world and make this node reachable (seeisAttached()
).void
resetRMRHUD()
Same assetRMRShape(null)
.void
resetRMRShape()
Resets the retained-mode rendering shape.void
resetRotationFilter()
Nullifies therotationFilter()
.void
resetScalingFilter()
Nullifies thescalingFilter()
.void
resetShape()
CallsresetIMRShape()
andresetRMRShape()
.void
resetTranslationFilter()
Nullifies thetranslationFilter()
.void
rotate(float x, float y, float z, float angle)
Same asrotate(new Vector(x,y,z), angle)
.void
rotate(float x, float y, float z, float angle, float inertia)
Same asrotate(new Vector(x, y, z), angle, inertia)
.void
rotate(Quaternion quaternion)
Same asorientation().compose((rotationfilter() != null) ? rotationfilter().apply(this, cacheRotationParams) : quaternion)
.void
rotate(Quaternion quaternion, float inertia)
Rotates the node byquaternion
(defined in the node coordinate system):orientation().compose(quaternion)
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.void
rotate(Vector axis, float angle)
Same asrotate(new Quaternion(axis, angle))
.void
rotate(Vector axis, float angle, float inertia)
Same asrotate(new Quaternion(axis, angle), inertia)
.BiFunction<Node,Object[],Quaternion>
rotationFilter()
Returns the rotation filter used byrotate(Quaternion)
.void
scale(float scaling)
Same asmagnitude() = magnitude() * (scalingFilter() != null ? scalingFilter().apply(this, cacheScalingParams) : scaling)
.void
scale(float scaling, float inertia)
Scales the node according toscaling
, locally defined with respect to thereference()
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.BiFunction<Node,Object[],Float>
scalingFilter()
Returns the scaling filter used byscale(float)
.void
set(Node node)
void
setAnimationRecurrence(boolean enable)
Enables (or disables) the recurrence of the keyframes animation.void
setAnimationTime(float time)
Sets the animation time (in milliseconds) used for the nextanimate()
call.void
setBehavior(Graph graph, BiConsumer<Graph,Node> behavior)
Same asgraph.addBehavior(this, behavior)
.void
setBehavior(Graph graph, Consumer<Graph> behavior)
Same asgraph.addBehavior(this, (g, n) -> behavior.accept(g))
.void
setBullsEyeSize(float size)
void
setForbidRotationFilter()
Same assetRotationFilter(forbidRotationFilter, new Object[] {})
.void
setForbidScalingFilter()
Same assetScalingFilter(forbidScalingFilter, new Object[] {})
.void
setForbidTranslationFilter()
Same assetTranslationFilter(forbidTranslationFilter, new Object[] {})
.void
setHighlight(float highlight)
Sets the nodehighlight()
which should be a value in[0..1]
.void
setHUD(Consumer<PGraphics> callback)
void
setHUD(Node node)
Sets this (H)eads (U)p (D)isplay from thenode
hud.void
setHUD(PShape shape)
void
setInteraction(BiConsumer<Node,Object[]> callback)
Sets the node interaction procedurecallback
which is a function that takes a node param (holding this node instance) and, optionally, a gesture encoded as an array of on Object params.void
setInteraction(Consumer<Object[]> callback)
Sets the node interaction procedurecallback
which is a function implemented by aNode
derived class and which takes no params, or a gesture encoded as an array of on Object params.void
setMagnitude(float magnitude)
Sets themagnitude()
of the node, locally defined with respect to thereference()
.void
setMinMaxScalingFilter(float min, float max)
Same assetScalingFilter(Node.minMaxScalingFilter, new Object[] { min, max })
.void
setOrientation(float x, float y, float z, float w)
Same assetOrientation(Quaternion)
but withfloat
Quaternion parameters.void
setOrientation(Quaternion orientation)
Sets the nodeorientation()
, locally defined with respect to thereference()
.void
setPosition(float x, float y)
Same assetPosition(Vector)
, but withfloat
parameters.void
setPosition(float x, float y, float z)
Same assetPosition(Vector)
, but withfloat
parameters.void
setPosition(Vector position)
Caches theposition()
of the node, locally defined with respect to thereference()
.void
setReference(Node node)
Sets thereference()
of the node.void
setRotationAxisFilter(Vector axis)
Same assetRotationFilter(Node.rotationAxisFilter, new Object[] { axis })
.void
setRotationFilter(BiFunction<Node,Object[],Quaternion> filter, Object[] params)
Sets therotationFilter()
and itscacheRotationParams
.void
setScalingFilter(BiFunction<Node,Object[],Float> filter, Object[] params)
Sets thescalingFilter()
and itscacheScalingParams
.void
setShape(Consumer<PGraphics> callback)
void
setShape(Node node)
Sets this shape from thenode
shape.void
setShape(PShape shape)
void
setTranslationAxisFilter(Vector axis)
Same assetTranslationFilter(translationAxisFilter, new Object[] { axis })
.void
setTranslationFilter(BiFunction<Node,Object[],Vector> filter, Object[] params)
Sets thetranslationFilter()
and itscacheTranslationParams
.void
setTranslationFilter(Function<Object[],Vector> filter, Object[] params)
void
setTranslationPlaneFilter(Vector normal)
Same assetTranslationFilter(translationPlaneFilter, new Object[] { axis })
.void
setWorldMagnitude(float magnitude)
Sets theworldMagnitude()
of the node, defined in the world coordinate system.void
setWorldMagnitude(Node node)
Sets theworldMagnitude()
to that ofnode
.void
setWorldOrientation(float x, float y, float z, float w)
Same assetWorldOrientation(Quaternion)
, but withfloat
parameters.void
setWorldOrientation(Node node)
Sets theworldOrientation()
to that ofnode
.void
setWorldOrientation(Quaternion quaternion)
Sets theworldOrientation()
of the node, defined in the world coordinate system.void
setWorldPosition(float x, float y)
Same assetWorldPosition(Vector)
, but withfloat
parameters.void
setWorldPosition(float x, float y, float z)
Same assetWorldPosition(Vector)
, but withfloat
parameters.void
setWorldPosition(Node node)
Sets theworldPosition()
to that ofnode
.void
setWorldPosition(Vector position)
Sets the nodeworldPosition()
, defined in the world coordinate system.void
setXAxis(Vector axis)
Rotates the node so that itsxAxis()
becomesaxis
defined in the world coordinate system.void
setYAxis(Vector axis)
Rotates the node so that itsyAxis()
becomesaxis
defined in the world coordinate system.void
setZAxis(Vector axis)
Rotates the node so that itszAxis()
becomesaxis
defined in the world coordinate system.void
toggleAnimation()
Toggles the node animation.void
toggleHint(int hint)
Toggles all single visual hints encoded in the bitwise-orhint
mask.void
togglePicking(int hint)
Toggles all single visual hints encoded in the bitwise-orhint
mask.String
toString()
Return this node components as a String.void
translate(float x, float y, float z)
Same astranslate(Vector)
but withfloat
parameters.void
translate(float x, float y, float z, float inertia)
Same astranslate(new Vector(x, y, z), inertia)
.void
translate(Vector vector)
Same asposition().add((translationFilter() != null) ? translationFilter().apply(this, cacheTranslationParams) : vector)
.void
translate(Vector vector, float inertia)
Translates the node according tovector
, locally defined with respect to thereference()
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.BiFunction<Node,Object[],Vector>
translationFilter()
Returns the translation filter used bytranslate(Vector)
.Matrix
view()
Returns the inverse of the matrix associated with the node position and orientation that is to be used when the node represents an eye.Matrix
viewInverse()
Returns the inverse of theview()
matrix.float
worldDisplacement(float scalar)
Convertsscalar
displacement from this node to world.Quaternion
worldDisplacement(Quaternion quaternion)
Convertsquaternion
displacement from this node to world.Vector
worldDisplacement(Vector vector)
Convertsvector
displacement from this node to world.Node
worldInverse()
Node
worldInverse(boolean attach)
Returns theinverse()
of the node world transformation.Vector
worldLocation(Vector vector)
Convertsvector
location from this node to world.float
worldMagnitude()
Returns the magnitude of the node, defined in the world coordinate system.Matrix
worldMatrix()
Returns the global transformation matrix represented by the node which grants direct access to it, without the need to traverse its ancestor hierarchy first (as it is the case withmatrix()
).Quaternion
worldOrientation()
Returns the orientation of the node, defined in the world coordinate system.Vector
worldPosition()
Returns the node position defined in the world coordinate system.Vector
xAxis()
Same asreturn xAxis(true)
Vector
xAxis(boolean positive)
Returns the x-axis of the node, represented as a normalized vector defined in the world coordinate system.Vector
yAxis()
Same asreturn yAxis(true)
Vector
yAxis(boolean positive)
Returns the y-axis of the node, represented as a normalized vector defined in the world coordinate system.Vector
zAxis()
Same asreturn zAxis(true)
Vector
zAxis(boolean positive)
Returns the z-axis of the node, represented as a normalized vector defined in the world coordinate system.
-
-
-
Field Detail
-
cull
public boolean cull
-
tagging
public boolean tagging
-
cacheTranslationParams
public Object[] cacheTranslationParams
-
cacheTargetPosition
public Vector cacheTargetPosition
-
cacheTargetTranslation
public Vector cacheTargetTranslation
-
cacheRotationParams
public Object[] cacheRotationParams
-
cacheTargetOrientation
public Quaternion cacheTargetOrientation
-
cacheTargetRotation
public Quaternion cacheTargetRotation
-
cacheScalingParams
public Object[] cacheScalingParams
-
cacheTargetMagnitude
public float cacheTargetMagnitude
-
cacheTargetScaling
public float cacheTargetScaling
-
cachePosition
public Vector cachePosition
-
cacheOrientation
public Quaternion cacheOrientation
-
cacheMagnitude
public float cacheMagnitude
-
CAMERA
public static final int CAMERA
- See Also:
- Constant Field Values
-
AXES
public static final int AXES
- See Also:
- Constant Field Values
-
HUD
public static final int HUD
- See Also:
- Constant Field Values
-
SHAPE
public static final int SHAPE
- See Also:
- Constant Field Values
-
BOUNDS
public static final int BOUNDS
- See Also:
- Constant Field Values
-
BULLSEYE
public static final int BULLSEYE
- See Also:
- Constant Field Values
-
TORUS
public static final int TORUS
- See Also:
- Constant Field Values
-
FILTER
public static final int FILTER
- See Also:
- Constant Field Values
-
BONE
public static final int BONE
- See Also:
- Constant Field Values
-
KEYFRAMES
public static final int KEYFRAMES
- See Also:
- Constant Field Values
-
maxSteps
public static int maxSteps
-
translationAxisFilter
public static BiFunction<Node,Object[],Vector> translationAxisFilter
Filters translation so that the node is translated alongaxis
(defined in this node coordinate system). Call it as:setTranslationFilter(Node.translationAxisFilter, new Object[] { axis })
.
-
forbidTranslationFilter
public static BiFunction<Node,Object[],Vector> forbidTranslationFilter
Filters translation so that it gets nullified. Call it as:setTranslationFilter(Node.forbidtranslationFilter, new Object[] { })
.- See Also:
setForbidTranslationFilter()
-
translationPlaneFilter
public static BiFunction<Node,Object[],Vector> translationPlaneFilter
Filters translation so that the node is translated along the plane defined bynormal
(defined in this node coordinate system). Call it as:setTranslationFilter(Node.vectorPlaneFilter, new Object[] { normal })
.
-
rotationAxisFilter
public static BiFunction<Node,Object[],Quaternion> rotationAxisFilter
Filtersquaternion
so that itsQuaternion.axis()
becomeaxis
(defined in this node coordinate system). Call it as:setRotationFilter(Node.rotationAxisFilter, new Object[] { axis })
.
-
forbidRotationFilter
public static BiFunction<Node,Object[],Quaternion> forbidRotationFilter
Filters rotation so that it gets nullified. Call it as:setRotationFilter(Node.forbidRotationFilter, new Object[] { })
.- See Also:
setForbidRotationFilter()
-
minMaxScalingFilter
public static BiFunction<Node,Object[],Float> minMaxScalingFilter
Filters scaling so that the node magnitude lies in[min..max]
. Call it as:setScalingFilter(Node.minMaxScalingFilter, new Object[] { min, max })
.
-
forbidScalingFilter
public static BiFunction<Node,Object[],Float> forbidScalingFilter
Filters scaling so that it gets nullified. Call it as:setScalingFilter(Node.forbidScalingilter, new Object[] { })
.- See Also:
setForbidScalingFilter()
-
-
Constructor Detail
-
Node
public Node()
Same asthis(null, new Vector(), new Quaternion(), 1)
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(boolean attach)
Same as {this(null, new Vector(), new Quaternion(), 1, attach)}. Theattach
var controls whether or not the nodeisAttached()
by theGraph.render()
algorithm.
-
Node
public Node(Vector position)
Same asthis(null, position, new Quaternion(), 1)
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(Vector position, boolean attach)
Same asthis(null, position, new Quaternion(), 1, attach)
. Theattach
var controls whether or not the nodeisAttached()
by theGraph.render()
algorithm.
-
Node
public Node(Vector position, Quaternion orientation)
Same asthis(null, position, orientation, 1)
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(Vector position, Quaternion orientation, boolean attach)
Same asthis(null, position, orientation, 1, attach)
. Theattach
var controls whether or not the nodeisAttached()
by theGraph.render()
algorithm.
-
Node
public Node(Node reference)
Same asthis(reference, new Vector(), new Quaternion(), 1)
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(Node reference, Vector position)
Same asthis(reference, position, new Quaternion(), 1
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(Node reference, Vector position, Quaternion orientation)
Same asthis(reference, position, orientation, 1
.
-
Node
public Node(Vector position, Quaternion orientation, float magnitude)
Same asthis(null, position, orientation, magnitude)
.- See Also:
Node(Node, Vector, Quaternion, float)
-
Node
public Node(Vector position, Quaternion orientation, float magnitude, boolean attach)
Same asthis(null, position, orientation, magnitude, attach)
.
-
Node
public Node(Node reference, Vector position, Quaternion orientation, float magnitude)
Creates a node withreference
asreference()
, havingposition
,orientation
andmagnitude
as theposition()
,orientation()
andmagnitude()
, respectively. ThebullsEyeSize()
is set to0.2
and thehighlight()
hint magnitude to0.15
. The nodeisAttached()
by theGraph.render()
algorithm iff the nodereference
happens to be.
-
Node
public Node(Consumer<PGraphics> shape)
Same asthis(null, shape, new Vector(), new Quaternion(), 1)
.
-
Node
public Node(PShape shape)
Same asthis(null, shape, new Vector(), new Quaternion(), 1)
.
-
Node
public Node(Node reference, Consumer<PGraphics> shape)
Same asthis(reference, shape, new Vector(), new Quaternion(), 1)
.
-
Node
public Node(Node reference, PShape shape)
Same asthis(reference, shape, new Vector(), new Quaternion(), 1)
.
-
Node
public Node(Node reference, Consumer<PGraphics> shape, Vector position, Quaternion orientation, float magnitude)
CallsNode(Node, Vector, Quaternion, float)
and thensetShape(Consumer)
.
-
Node
public Node(Node reference, PShape shape, Vector position, Quaternion orientation, float magnitude)
Creates a node withreference
asreference()
andshape
, havingposition
,orientation
andmagnitude
as theposition()
,orientation()
andmagnitude()
, respectively. ThebullsEyeSize()
is set to0
and thehighlight()
hint to0.15
.
-
-
Method Detail
-
matches
public boolean matches(Node node)
Returns whether this node matches other taking into account theworldPosition()
,worldOrientation()
andworldMagnitude()
node parameters.- Parameters:
node
- node
-
toString
public String toString()
Return this node components as a String.
-
copy
public Node copy()
Same asreturn copy(true)
.- See Also:
copy(boolean)
-
copy
public Node copy(boolean recursive)
Performs a deep copy of this node, and its descendants iffrecursive
istrue
. Note that neither the keyframes nor the node filters get copied.
-
set
public void set(Node node)
SetsworldPosition()
,worldOrientation()
andworldMagnitude()
values from those of thenode
. The nodereference()
is not affected by this call.After calling
set(node)
a call tothis.matches(node)
should returntrue
.
-
reset
public void reset()
Sets an identity node by resetting itsposition()
,orientation()
andmagnitude()
. The nodereference()
is not affected by this call. Callset(null)
if you want to reset the globalworldPosition()
,worldOrientation()
andworldMagnitude()
node parameters instead.- See Also:
set(Node)
-
id
public int id()
Returns the unique sequential node id assigned at instantiation time. Used bycolorID()
andGraph._displayBackHint(Node)
.
-
colorID
public int colorID()
Uniquely identifies the node. Also the color to be used for picking with a color buffer. See: http://stackoverflow.com/questions/2262100/rgb-int-to-rgb-python
-
redID
public static float redID(int id)
- See Also:
colorID(int)
-
greenID
public static float greenID(int id)
- See Also:
colorID(int)
-
blueID
public static float blueID(int id)
- See Also:
colorID(int)
-
colorID
public static int colorID(int id)
Convert intid
to color. See: http://stackoverflow.com/questions/2262100/rgb-int-to-rgb-python
-
lastUpdate
public long lastUpdate()
- Returns:
- the last frame this node affine transformation (
worldPosition()
,worldOrientation()
orworldMagnitude()
) orreference()
was updated.
-
isReference
public boolean isReference(Node node)
-
isAncestor
public boolean isAncestor(Node node)
Returnstrue
ifnode
is ancestor ofthis
node.
-
isAncestor
public static boolean isAncestor(Node successor, Node ancestor)
Same asreturn successor.isAncestor(ancestor)
.- See Also:
isAncestor(Node)
,path(Node, Node)
-
path
public static List<Node> path(Node tail, Node tip)
Returns an array containing a straight path of nodes fromtail
totip
. Returns an empty list iftail
is not ancestor oftip
.- See Also:
isAncestor(Node, Node)
-
reference
public Node reference()
Returns the reference node, in which this node is defined.The node
position()
,orientation()
andmagnitude()
are defined with respect to thereference()
coordinate system. Anull
reference node (default value) means that the node is defined in the world coordinate system.Use
worldPosition()
,worldOrientation()
andworldMagnitude()
to recursively convert values along the reference node chain and to get values expressed in the world coordinate system. The values match when the reference node isnull
.Use
setReference(Node)
to set this value and create a node hierarchy. Convenient functions allow you to convert coordinates and vectors from one node to another: seelocation(Vector, Node)
anddisplacement(Vector, Node)
, respectively.
-
resetReference
public void resetReference()
Setsreference()
to the world and make this node reachable (seeisAttached()
).- See Also:
setReference(Node)
,detach()
-
setReference
public void setReference(Node node)
Sets thereference()
of the node. The nodeworldPosition()
,worldOrientation()
andworldMagnitude()
are kept. Setting a detached reference of an attached node will make the node detached, while setting an attached reference of a detached node will keep it detached.The node
position()
,orientation()
andmagnitude()
are then defined in thereference()
coordinate system.Use
worldPosition()
,worldOrientation()
andworldMagnitude()
to express the node global transformation in the world coordinate system.Using this method, you can create a hierarchy of nodes. This hierarchy needs to be a tree, which root is the world coordinate system (i.e.,
null
reference()
). No action is performed if settingreference
as thereference()
would create a loop in the hierarchy.To make all the nodes in the
node
branch eligible for garbage collection calldetach()
.- See Also:
detach()
-
resetInertia
public void resetInertia()
Stops all node inertia's.
-
rendered
public boolean rendered(Graph graph)
Tells whether the node was rendered in the last frame fromgraph
after a call toGraph.render(Node)
is issued. Ths method should be called from within the main event loop (afterGraph.render(Node)
).
-
attach
public void attach()
Attaches the branch to which this node belongs to the tree so that this node (together with all nodes in the branch) is reached from theGraph.render()
algorithm. A call toisAttached()
will then returntrue
.detach()
performs the inverse operation.- See Also:
Graph.clearTree()
,detach()
,isAttached()
-
detach
public void detach()
Detach node from the tree so that it's not reached from theGraph.render()
algorithm and make all the nodes in thenode
branch eligible for garbage collection. A call toisAttached()
(including the node descendants) will then returnfalse
.attach()
performs the inverse operation.- See Also:
Graph.clearTree()
,attach()
,isAttached()
-
isAttached
public boolean isAttached()
Returns whether or not the node is reachable by the rendering algorithm. Note that a detached child of an attached node is not listed inchildren()
, even though they hold areference()
to the parent node.- See Also:
detach()
,attach()
,setReference(Node)
-
children
public List<Node> children()
Returns the list a child nodes of this node. Note that detached children of an attached node are not listed, even though they hold areference()
to the node.- See Also:
isAttached()
,attach()
,detach()
-
randomize
public void randomize(Vector center, float radius, boolean is3D)
Randomized this node. The node is randomly re-positioned inside the ball defined bycenter
andradius
, which in 2D is a circumference parallel to the x-y plane. TheworldOrientation()
is randomized byQuaternion.randomize()
. The new magnitude is a random in old-magnitude * [0,5...2].
-
random
public static Node random(Graph graph)
Returns a random node attached tograph
. The node is randomly positioned inside thegraph
viewing volume which is defined byGraph.center()
andGraph.radius()
(seeVector.random()
). TheworldOrientation()
is set byQuaternion.random()
. TheworldMagnitude()
is a random in [0,5...2].
-
random
public static Node random(Vector center, float radius, boolean is3D)
Returns a random node. The node is randomly positioned inside the ball defined bycenter
andradius
(seeVector.random()
), which in 2D is a circumference parallel to the x-y plane. TheworldOrientation()
is set byQuaternion.random()
. TheworldMagnitude()
is a random in [0,5...2].
-
setBullsEyeSize
public void setBullsEyeSize(float size)
Sets thebullsEyeSize()
of theBULLSEYE
hint()
.Picking a node is done with ray casting against a screen-space bullseye shape (see
configHint(int, Object...)
) whose length is defined as follows:- A percentage of the graph diameter (see
Graph.radius()
). Set it withsize in [0..1]
. - A fixed numbers of pixels. Set it with
size > 1
.
- See Also:
bullsEyeSize()
- A percentage of the graph diameter (see
-
setHighlight
public void setHighlight(float highlight)
- See Also:
highlight()
-
highlight
public float highlight()
Returns the highlighting magnitude use to scale the node when it's tagged.- See Also:
setHighlight(float)
-
bullsEyeSize
public float bullsEyeSize()
- See Also:
setBullsEyeSize(float)
-
position
public Vector position()
Returns the node position, defined with respect to thereference()
.Use
worldPosition()
to get the result in world coordinates. These two values are identical when thereference()
isnull
(default).- See Also:
setPosition(Vector)
-
setPosition
public void setPosition(Vector position)
Caches theposition()
of the node, locally defined with respect to thereference()
. If there's atranslationFilter()
it actually callstranslate(Vector.subtract(position, this.position()))
.Use
setWorldPosition(Vector)
to define the world coordinatesworldPosition()
.
-
setPosition
public void setPosition(float x, float y)
Same assetPosition(Vector)
, but withfloat
parameters.
-
setPosition
public void setPosition(float x, float y, float z)
Same assetPosition(Vector)
, but withfloat
parameters.
-
translate
public void translate(float x, float y, float z, float inertia)
Same astranslate(new Vector(x, y, z), inertia)
.- See Also:
translate(Vector, float)
-
translate
public void translate(float x, float y, float z)
Same astranslate(Vector)
but withfloat
parameters.
-
translate
public void translate(Vector vector, float inertia)
Translates the node according tovector
, locally defined with respect to thereference()
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.
-
translate
public void translate(Vector vector)
Same asposition().add((translationFilter() != null) ? translationFilter().apply(this, cacheTranslationParams) : vector)
.
-
setTranslationFilter
public void setTranslationFilter(Function<Object[],Vector> filter, Object[] params)
-
setTranslationFilter
public void setTranslationFilter(BiFunction<Node,Object[],Vector> filter, Object[] params)
Sets thetranslationFilter()
and itscacheTranslationParams
.
-
translationFilter
public BiFunction<Node,Object[],Vector> translationFilter()
Returns the translation filter used bytranslate(Vector)
.
-
resetTranslationFilter
public void resetTranslationFilter()
Nullifies thetranslationFilter()
.
-
setTranslationAxisFilter
public void setTranslationAxisFilter(Vector axis)
Same assetTranslationFilter(translationAxisFilter, new Object[] { axis })
.
-
setForbidTranslationFilter
public void setForbidTranslationFilter()
Same assetTranslationFilter(forbidTranslationFilter, new Object[] {})
.
-
setTranslationPlaneFilter
public void setTranslationPlaneFilter(Vector normal)
Same assetTranslationFilter(translationPlaneFilter, new Object[] { axis })
.
-
worldPosition
public Vector worldPosition()
Returns the node position defined in the world coordinate system.
-
setWorldPosition
public void setWorldPosition(Node node)
Sets theworldPosition()
to that ofnode
.- See Also:
setWorldPosition(Vector)
,set(Node)
-
setWorldPosition
public void setWorldPosition(Vector position)
Sets the nodeworldPosition()
, defined in the world coordinate system.Use
setPosition(Vector)
to define the local node position (with respect to thereference()
).
-
setWorldPosition
public void setWorldPosition(float x, float y)
Same assetWorldPosition(Vector)
, but withfloat
parameters.
-
setWorldPosition
public void setWorldPosition(float x, float y, float z)
Same assetWorldPosition(Vector)
, but withfloat
parameters.
-
orientation
public Quaternion orientation()
Returns the node orientation, defined with respect to thereference()
(i.e, the current Quaternion orientation).Use
worldOrientation()
to get the result in world coordinates. These two values are identical when thereference()
isnull
(default).- See Also:
setOrientation(Quaternion)
-
setOrientation
public void setOrientation(float x, float y, float z, float w)
Same assetOrientation(Quaternion)
but withfloat
Quaternion parameters.
-
setOrientation
public void setOrientation(Quaternion orientation)
Sets the nodeorientation()
, locally defined with respect to thereference()
. If there's arotationFilter()
it actually callsrotate(Quaternion.compose(orientation().inverse(), orientation))
.Use
setWorldOrientation(Quaternion)
to define the world coordinatesworldOrientation()
.- See Also:
orientation()
,setPosition(Vector)
,setMagnitude(float)
-
rotate
public void rotate(Vector axis, float angle, float inertia)
Same asrotate(new Quaternion(axis, angle), inertia)
.- See Also:
rotate(Quaternion, float)
-
rotate
public void rotate(Vector axis, float angle)
Same asrotate(new Quaternion(axis, angle))
.- See Also:
rotate(Quaternion)
-
rotate
public void rotate(float x, float y, float z, float angle, float inertia)
Same asrotate(new Vector(x, y, z), angle, inertia)
.- See Also:
rotate(Vector, float, float)
-
rotate
public void rotate(float x, float y, float z, float angle)
Same asrotate(new Vector(x,y,z), angle)
.- See Also:
rotate(Vector, float)
-
rotate
public void rotate(Quaternion quaternion, float inertia)
Rotates the node byquaternion
(defined in the node coordinate system):orientation().compose(quaternion)
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.
-
rotate
public void rotate(Quaternion quaternion)
Same asorientation().compose((rotationfilter() != null) ? rotationfilter().apply(this, cacheRotationParams) : quaternion)
.
-
setRotationFilter
public void setRotationFilter(BiFunction<Node,Object[],Quaternion> filter, Object[] params)
Sets therotationFilter()
and itscacheRotationParams
.
-
rotationFilter
public BiFunction<Node,Object[],Quaternion> rotationFilter()
Returns the rotation filter used byrotate(Quaternion)
.- See Also:
setRotationFilter(BiFunction, Object[])
-
resetRotationFilter
public void resetRotationFilter()
Nullifies therotationFilter()
.
-
setRotationAxisFilter
public void setRotationAxisFilter(Vector axis)
Same assetRotationFilter(Node.rotationAxisFilter, new Object[] { axis })
.
-
setForbidRotationFilter
public void setForbidRotationFilter()
Same assetRotationFilter(forbidRotationFilter, new Object[] {})
.- See Also:
setRotationFilter(BiFunction, Object[])
-
orbit
public void orbit(Vector axis, float angle, float inertia)
Same asorbit(axis, angle, new Vector(), inertia)
.
-
orbit
public void orbit(Vector axis, float angle)
Rotates the node aroundaxis
passing through the origin, both defined in the world coordinate system. Same asorbit(axis, angle, new Vector())
.
-
orbit
public void orbit(Vector axis, float angle, Vector center, float inertia)
Same asorbit(new Quaternion(displacement(axis), angle), center, inertia)
.- See Also:
orbit(Vector, float)
,orbit(Vector, float, float)
-
orbit
public void orbit(Vector axis, float angle, Vector center)
Rotates the node aroundaxis
passing throughcenter
, both defined in the world coordinate system. Same asorbit(new Quaternion(displacement(axis), angle), center)
.- See Also:
_orbit(Quaternion, Vector)
,orbit(Vector, float)
-
worldOrientation
public Quaternion worldOrientation()
Returns the orientation of the node, defined in the world coordinate system.
-
setWorldOrientation
public void setWorldOrientation(Node node)
Sets theworldOrientation()
to that ofnode
.- See Also:
setWorldOrientation(Quaternion)
,set(Node)
-
setWorldOrientation
public void setWorldOrientation(Quaternion quaternion)
Sets theworldOrientation()
of the node, defined in the world coordinate system.Use
setOrientation(Quaternion)
to define the local node orientation (with respect to thereference()
).
-
setWorldOrientation
public void setWorldOrientation(float x, float y, float z, float w)
Same assetWorldOrientation(Quaternion)
, but withfloat
parameters.
-
magnitude
public float magnitude()
Returns the node magnitude, defined with respect to thereference()
.Use
worldMagnitude()
to get the result in world coordinates. These two values are identical when thereference()
isnull
(default).- See Also:
setMagnitude(float)
-
setMagnitude
public void setMagnitude(float magnitude)
Sets themagnitude()
of the node, locally defined with respect to thereference()
. If there's ascalingFilter()
it actually callsscale(magnitude / magnitude())
.Use
setWorldMagnitude(float)
to define the world coordinatesworldMagnitude()
.- See Also:
scale(float)
-
scale
public void scale(float scaling, float inertia)
Scales the node according toscaling
, locally defined with respect to thereference()
and with an impulse defined withinertia
which should be in[0..1]
, 0 no inertia & 1 no friction.
-
scale
public void scale(float scaling)
Same asmagnitude() = magnitude() * (scalingFilter() != null ? scalingFilter().apply(this, cacheScalingParams) : scaling)
.- See Also:
scale(float, float)
,translate(Vector)
,rotate(Quaternion)
-
setScalingFilter
public void setScalingFilter(BiFunction<Node,Object[],Float> filter, Object[] params)
Sets thescalingFilter()
and itscacheScalingParams
.
-
scalingFilter
public BiFunction<Node,Object[],Float> scalingFilter()
Returns the scaling filter used byscale(float)
.- See Also:
setScalingFilter(BiFunction, Object[])
-
resetScalingFilter
public void resetScalingFilter()
Nullifies thescalingFilter()
.
-
setMinMaxScalingFilter
public void setMinMaxScalingFilter(float min, float max)
Same assetScalingFilter(Node.minMaxScalingFilter, new Object[] { min, max })
.
-
setForbidScalingFilter
public void setForbidScalingFilter()
Same assetScalingFilter(forbidScalingFilter, new Object[] {})
.- See Also:
setScalingFilter(BiFunction, Object[])
-
worldMagnitude
public float worldMagnitude()
Returns the magnitude of the node, defined in the world coordinate system.Note that the magnitude is used to compute the node
Graph.projection()
matrix to render a scene from the node point-of-view.
-
setWorldMagnitude
public void setWorldMagnitude(Node node)
Sets theworldMagnitude()
to that ofnode
.- See Also:
setWorldMagnitude(float)
,set(Node)
-
setWorldMagnitude
public void setWorldMagnitude(float magnitude)
Sets theworldMagnitude()
of the node, defined in the world coordinate system.Use
setMagnitude(float)
to define the local node magnitude (with respect to thereference()
).
-
align
public void align()
Same asalign(null)
.- See Also:
align(Node)
-
align
public void align(Node node)
Convenience function that simply callsalign(false, 0.85f, node)
- See Also:
align(boolean, float, Node)
-
align
public void align(boolean move)
Same asalign(move, null)
.- See Also:
align(boolean, Node)
-
align
public void align(boolean move, Node node)
Convenience function that simply callsalign(move, 0.85f, node)
.- See Also:
align(boolean, float, Node)
-
align
public void align(float threshold)
Same asalign(threshold, null)
.- See Also:
align(boolean, Node)
-
align
public void align(float threshold, Node node)
Convenience function that simply callsalign(false, threshold, node)
.- See Also:
align(boolean, float, Node)
-
align
public void align(boolean move, float threshold)
Same asalign(move, threshold, null)
.- See Also:
align(boolean, float, Node)
-
align
public void align(boolean move, float threshold, Node node)
Aligns the node withnode
, so that two of their axis are parallel.If one of the X, Y and Z axis of the Node is almost parallel to any of the X, Y, or Z axis of
node
, the Node is rotated so that these two axis actually become parallel.If, after this first rotation, two other axis are also almost parallel, a second alignment is performed. The two nodes then have identical orientations, up to 90 degrees rotations.
threshold
measures how close two axis must be to be considered parallel. It is compared with the absolute values of the dot product of the normalized axis.When
move
is set totrue
, the NodeworldPosition()
is also affected by the alignment. The new NodeworldPosition()
is such that thenode
node position (computed withlocation(Vector)
, in the Node coordinates system) does not change.node
may benull
and then represents the world coordinate system (same convention than for thereference()
).
-
projectOnLine
public void projectOnLine(Vector origin, Vector direction)
Translates the node so that itsworldPosition()
lies on the line defined byorigin
anddirection
(defined in the world coordinate system).Simply uses an orthogonal projection.
direction
does not need to be normalized.
-
setXAxis
public void setXAxis(Vector axis)
Rotates the node so that itsxAxis()
becomesaxis
defined in the world coordinate system. Attention: this rotation is not uniquely defined. SeeQuaternion.fromTo(Vector, Vector)
.- See Also:
xAxis()
,setYAxis(Vector)
,setZAxis(Vector)
-
setYAxis
public void setYAxis(Vector axis)
Rotates the node so that itsyAxis()
becomesaxis
defined in the world coordinate system. Attention: this rotation is not uniquely defined. SeeQuaternion.fromTo(Vector, Vector)
.- See Also:
yAxis()
,setYAxis(Vector)
,setZAxis(Vector)
-
setZAxis
public void setZAxis(Vector axis)
Rotates the node so that itszAxis()
becomesaxis
defined in the world coordinate system. Attention: this rotation is not uniquely defined. SeeQuaternion.fromTo(Vector, Vector)
.- See Also:
zAxis()
,setYAxis(Vector)
,setZAxis(Vector)
-
xAxis
public Vector xAxis()
Same asreturn xAxis(true)
- See Also:
xAxis(boolean)
-
xAxis
public Vector xAxis(boolean positive)
Returns the x-axis of the node, represented as a normalized vector defined in the world coordinate system.- See Also:
setXAxis(Vector)
,yAxis()
,zAxis()
-
yAxis
public Vector yAxis()
Same asreturn yAxis(true)
- See Also:
yAxis(boolean)
-
yAxis
public Vector yAxis(boolean positive)
Returns the y-axis of the node, represented as a normalized vector defined in the world coordinate system.- See Also:
setYAxis(Vector)
,xAxis()
,zAxis()
-
zAxis
public Vector zAxis()
Same asreturn zAxis(true)
- See Also:
zAxis(boolean)
-
zAxis
public Vector zAxis(boolean positive)
Returns the z-axis of the node, represented as a normalized vector defined in the world coordinate system.- See Also:
setZAxis(Vector)
,xAxis()
,yAxis()
-
matrix
public Matrix matrix()
Returns the local transformation matrix represented by the node.This matrix only represents the local node transformation (i.e., with respect to the
reference()
). UseworldMatrix()
to get the full Node transformation matrix (i.e., from the world to the Node coordinate system). These two match when thereference()
isnull
.Use this method to manually traverse the node tree hierarchy:
push();
applyMatrix(node.matrix());
// You are in the local node coordinate system.
pop();
- See Also:
set(Node)
,worldMatrix()
,view()
,viewInverse()
-
worldMatrix
public Matrix worldMatrix()
Returns the global transformation matrix represented by the node which grants direct access to it, without the need to traverse its ancestor hierarchy first (as it is the case withmatrix()
).This matrix represents the global node transformation: the entire
reference()
hierarchy is taken into account to define the node transformation from the world coordinate system. Usematrix()
to get the local node transformation matrix (i.e. defined with respect to thereference()
). These two match when thereference()
isnull
.- See Also:
set(Node)
,matrix()
,view()
,viewInverse()
-
view
public Matrix view()
Returns the inverse of the matrix associated with the node position and orientation that is to be used when the node represents an eye. This matrix matches the inverted of theworldMatrix()
whenmagnitude()
is1
.The view matrix converts from the world coordinates system to the eye coordinates system, so that coordinates can then be projected on screen using a projection matrix.
-
viewInverse
public Matrix viewInverse()
Returns the inverse of theview()
matrix. This matrix matches theworldMatrix()
whenworldMagnitude()
is1
.This matrix converts from the eye to world space.
- See Also:
view()
,matrix()
,worldMatrix()
,set(Node)
-
fromMatrix
public void fromMatrix(Matrix matrix)
Sets the node from amatrix()
representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.- See Also:
fromWorldMatrix(Matrix)
,matrix()
-
fromWorldMatrix
public void fromWorldMatrix(Matrix matrix)
Sets the node fromworldMatrix()
representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.Hence, if your openGL code fragment looks like:
float [] m = new float [16]; m[0]=...;
gl.glMultMatrixf(m);
It is equivalent to write:
Node node = new Node();
node.fromWorldMatrix(m);
graph.applyWorldTransformation(node);
// You are in the local node coordinate system.
Which allows to apply local transformations to the
node
while using geometry data from other node instances when necessary (seelocation(Vector, Node)
anddisplacement(Vector, Node)
).- See Also:
fromMatrix(Matrix)
,worldMatrix()
-
inverse
public Node inverse()
-
inverse
public Node inverse(boolean attach)
Returns a node representing the inverse of this node space transformation.The new node
orientation()
is theQuaternion.inverse()
of the original orientation. Itsposition()
is the negated inverse rotated image of the original position. Itsmagnitude()
is 1 / original magnitude.If a node is considered as a space rigid transformation, i.e., position and orientation, but no magnitude (magnitude=1), the inverse() node performs the inverse transformation.
Only the local node transformation (i.e., defined with respect to the
reference()
) is inverted. UseworldInverse()
for a global inverse.The resulting node has the same
reference()
as the this node.- See Also:
worldInverse()
-
worldInverse
public Node worldInverse()
-
worldInverse
public Node worldInverse(boolean attach)
Returns theinverse()
of the node world transformation.The
worldOrientation()
of the new node is theQuaternion.inverse()
of the original orientation. ItsworldPosition()
is the negated and inverse rotated image of the original position. TheworldMagnitude()
is the original magnitude multiplicative inverse.Use
inverse()
for a local (i.e., with respect toreference()
) transformation inverse.- See Also:
inverse()
-
displacement
public float displacement(float scalar)
Convertsscalar
displacement from world to this node. Same asreturn displacement(scalar, null)
.displacement(Vector)
converts vector displacements instead of scalar displacements.displacement(Quaternion)
converts quaternion displacements instead of scalar displacements.location(Vector)
converts locations instead of displacements.
-
displacement
public float displacement(float scalar, Node node)
Convertsscalar
displacement fromnode
to this node. Usenode.displacement(scalar, this)
to perform the inverse transformation.displacement(Vector, Node)
converts vector displacements instead of scalar displacements.displacement(Quaternion, Node)
converts quaternion displacements instead of scalar displacements.location(Vector, Node)
converts locations instead of displacements.
-
worldDisplacement
public float worldDisplacement(float scalar)
Convertsscalar
displacement from this node to world.displacement(float)
performs the inverse transformation.worldDisplacement(Vector)
converts vector displacements instead of scalar displacements.worldDisplacement(Quaternion)
converts quaternion displacements instead of scalar displacements.worldLocation(Vector)
converts locations instead of displacements.
-
localDisplacement
public float localDisplacement(float scalar)
Convertsscalar
displacement fromreference()
to this node.referenceDisplacement(float)
performs the inverse transformation.- See Also:
displacement(Quaternion)
,displacement(Vector)
-
referenceDisplacement
public float referenceDisplacement(float scalar)
Convertsscalar
displacement from this node toreference()
.localDisplacement(float)
performs the inverse transformation.
-
displacement
public Quaternion displacement(Quaternion quaternion)
Convertsquaternion
displacement from world to this node. Same asreturn displacement(quaternion, null)
.displacement(Vector)
converts vector displacements instead of quaternion displacements.displacement(float)
converts scalar displacements instead of quaternion displacements.location(Vector)
converts locations instead of displacements.
-
displacement
public Quaternion displacement(Quaternion quaternion, Node node)
Convertsquaternion
displacement fromnode
to this node. Usenode.displacement(quaternion, this)
to perform the inverse transformation.displacement(Vector, Node)
converts vector displacements instead of quaternion displacements.displacement(float, Node)
converts scalar displacements instead of quaternion displacements.location(Vector, Node)
converts locations instead of displacements.
-
worldDisplacement
public Quaternion worldDisplacement(Quaternion quaternion)
Convertsquaternion
displacement from this node to world.displacement(Vector)
performs the inverse transformation.worldDisplacement(Vector)
converts vector displacements instead of quaternion displacements.worldDisplacement(float)
converts scalar displacements instead of quaternion displacements.worldLocation(Vector)
converts locations instead of displacements.
-
localDisplacement
public Quaternion localDisplacement(Quaternion quaternion)
Convertsquaternion
displacement fromreference()
to this node.referenceDisplacement(Quaternion)
performs the inverse transformation.localLocation(Vector)
converts locations instead of displacements.- See Also:
displacement(Quaternion)
,displacement(Vector)
-
referenceDisplacement
public Quaternion referenceDisplacement(Quaternion quaternion)
Convertsquaternion
displacement from this node toreference()
.localDisplacement(Quaternion)
performs the inverse transformation.referenceLocation(Vector)
converts locations instead of displacements.
-
displacement
public Vector displacement(Vector vector)
Convertsvector
displacement from world to this node. Same asreturn displacement(vector, null)
.displacement(Quaternion)
converts quaternion displacements instead of vector displacements.location(Vector)
converts locations instead of displacements.
-
displacement
public Vector displacement(Vector vector, Node node)
Convertsvector
displacement fromnode
to this node. Usenode.displacement(vector, this)
to perform the inverse transformation.displacement(Quaternion, Node)
converts quaternion displacements instead of vector displacements.location(Vector, Node)
converts locations instead of displacements.
-
worldDisplacement
public Vector worldDisplacement(Vector vector)
Convertsvector
displacement from this node to world.displacement(Vector)
performs the inverse transformation.worldDisplacement(Quaternion)
converts quaternion displacements instead of vector displacements.worldLocation(Vector)
converts locations instead of displacements.
-
localDisplacement
public Vector localDisplacement(Vector vector)
Convertsvector
displacement fromreference()
to this node.referenceDisplacement(Vector)
performs the inverse transformation.localLocation(Vector)
converts locations instead of displacements.- See Also:
displacement(Vector)
-
referenceDisplacement
public Vector referenceDisplacement(Vector vector)
Convertsvector
displacement from this node toreference()
.localDisplacement(Vector)
performs the inverse transformation.referenceLocation(Vector)
converts locations instead of displacements.- See Also:
worldDisplacement(Vector)
-
location
public Vector location(Node node)
Converts thenode
origin location to this node. Same asreturn location(new Vector(), node)
.displacement(Vector, Node)
converts vector displacements instead of locations.displacement(Quaternion, Node)
converts quaternion displacements instead of locations.
-
location
public Vector location(Vector vector)
Convertsvector
location from world to this node. Same asreturn location(vector, null)
.displacement(Vector)
converts vector displacements instead of locations.displacement(Quaternion)
converts quaternion displacements instead of locations.
-
location
public Vector location(Vector vector, Node node)
Convertsvector
location fromnode
to this node. Usenode.location(vector, this)
to perform the inverse transformation.displacement(Vector, Node)
converts vector displacements instead of locations.displacement(Quaternion, Node)
converts quaternion displacements instead of locations.- See Also:
location(Node)
,location(Vector)
,worldLocation(Vector)
-
worldLocation
public Vector worldLocation(Vector vector)
Convertsvector
location from this node to world.location(Vector)
performs the inverse transformation.worldDisplacement(Vector)
converts vector displacements instead of locations.worldDisplacement(Quaternion)
converts quaternion displacements instead of locations.
-
localLocation
public Vector localLocation(Vector vector)
Convertsvector
location fromreference()
to this node.referenceLocation(Vector)
performs the inverse transformation.localDisplacement(Vector)
converts displacements instead of locations.- See Also:
location(Vector)
-
referenceLocation
public Vector referenceLocation(Vector vector)
Convertsvector
location from this node toreference()
.localLocation(Vector)
performs the inverse transformation.referenceDisplacement(Vector)
converts displacements instead of locations.- See Also:
worldLocation(Vector)
-
isTagged
public boolean isTagged(Graph graph)
Returnstrue
if thenode
has been tagged by thegraph
at least once andfalse
otherwise.- See Also:
Graph.hasTag(String, Node)
,Graph.hasTag(Node)
-
setBehavior
public void setBehavior(Graph graph, BiConsumer<Graph,Node> behavior)
Same asgraph.addBehavior(this, behavior)
.
-
setBehavior
public void setBehavior(Graph graph, Consumer<Graph> behavior)
Same asgraph.addBehavior(this, (g, n) -> behavior.accept(g))
.
-
resetBehavior
public void resetBehavior(Graph graph)
Same asgraph.resetBehavior(this)
.- See Also:
Graph.resetBehavior(Node)
-
bypass
public void bypass()
Bypass rendering the node for the current frame. Set it before callingGraph.render()
or any rendering algorithm. Note that the node nor its children get culled.
-
resetShape
public void resetShape()
CallsresetIMRShape()
andresetRMRShape()
.
-
resetRMRShape
public void resetRMRShape()
Resets the retained-mode rendering shape.- See Also:
setShape(Consumer)
-
resetIMRShape
public void resetIMRShape()
Resets the immediate-mode rendering shape.- See Also:
setShape(processing.core.PShape)
-
setShape
public void setShape(Node node)
Sets this shape from thenode
shape.
-
setShape
public void setShape(PShape shape)
Sets the node retained mode rendering (rmr)SHAPE
hint (seehint()
). UseenableHint(Node.SHAPE)
,disableHint(Node.SHAPE)
andtoggleHint(Node.SHAPE)
to (dis)enable the hint.- See Also:
setShape(Consumer)
,resetShape()
,resetIMRShape()
,resetRMRShape()
-
setInteraction
public void setInteraction(Consumer<Object[]> callback)
Sets the node interaction procedurecallback
which is a function implemented by aNode
derived class and which takes no params, or a gesture encoded as an array of on Object params.The interaction is performed either after calling the
Graph.interact(String, Object...)
,Graph.interact(Object...)
orGraph.interact(Node, Object...)
scene procedures.Same as
setInteraction((n, o) -> callback.accept(o))
.- See Also:
setInteraction(BiConsumer)
-
setInteraction
public void setInteraction(BiConsumer<Node,Object[]> callback)
Sets the node interaction procedurecallback
which is a function that takes a node param (holding this node instance) and, optionally, a gesture encoded as an array of on Object params.The interaction is performed either after calling the
Graph.interact(String, Object...)
,Graph.interact(Object...)
orGraph.interact(Node, Object...)
scene procedures.- See Also:
setInteraction(Consumer)
-
interact
public void interact(Object[] gesture)
Parsegesture
params. Useful to customize the node behavior. Default implementation is empty. , i.e., it is meant to be implemented by derived classes.
-
resetHUD
public void resetHUD()
Same as callingresetRMRHUD()
andresetIMRHUD()
.
-
resetRMRHUD
public void resetRMRHUD()
Same assetRMRShape(null)
.- See Also:
setShape(processing.core.PShape)
-
resetIMRHUD
public void resetIMRHUD()
Same assetIMRShape(null)
.- See Also:
setShape(Consumer)
-
setHUD
public void setHUD(Node node)
Sets this (H)eads (U)p (D)isplay from thenode
hud.
-
setHUD
public void setHUD(PShape shape)
Sets the node retained mode rendering (rmr) shapeHUD
hint (seehint()
). The 2Dshape
screen coordinates are interpreted relative to the nodeworldPosition()
screen projection when the hint is rendered (Graph.render(Node)
). UseenableHint(Node.HUD)
,disableHint(Node.HUD)
andtoggleHint(Node.HUD)
to (dis)enable the hint.- See Also:
setHUD(Consumer)
,resetHUD()
,resetIMRHUD()
,resetRMRHUD()
-
setHUD
public void setHUD(Consumer<PGraphics> callback)
Sets the node immediate mode rendering (imr) drawing procedureHUD
hint (seehint()
). The 2Dshape
screen coordinates are interpreted relative to the nodeworldPosition()
screen projection when the hint is rendered (Graph.render(Node)
). UseenableHint(Node.HUD)
,disableHint(Node.HUD)
andtoggleHint(Node.HUD)
to (dis)enable the hint.
-
isPickingEnabled
public boolean isPickingEnabled(int hint)
Returns whether or not all hints encoded in the bitwise-orhint
mask are enable for node picking with ray casting.
-
picking
public int picking()
Returns the current visual picking hint mask encoding the visual aspects that are to be taken into account for picking the node with ray casting. Refer tohint()
to learn how to configure the mask.Note that picking a node from one of its visual aspects requires both the
hint()
and this mask to have enabled the same aspects.
-
resetPicking
public void resetPicking()
Resetspicking()
, i.e., disables all single visual hints available for node picking with ray casting.
-
disablePicking
public void disablePicking(int hint)
Disables all the single visual hints encoded in the bitwise-orhint
mask.
-
enablePicking
public void enablePicking(int picking)
Enables all single visual hints encoded in the bitwise-orpickingMode
mask.
-
togglePicking
public void togglePicking(int hint)
Toggles all single visual hints encoded in the bitwise-orhint
mask.
-
isHintEnabled
public boolean isHintEnabled(int hint)
Returns whether or not all single visual hints encoded in the bitwise-orhint
mask are enable or not.
-
hint
public int hint()
Returns the current visual hint mask. The mask is a bitwise-or of the following single visual hints available for the node:CAMERA
which displays a camera hint centered at the node screen projection.AXES
which displays an axes hint centered at the nodeworldPosition()
an oriented according to the nodeworldOrientation()
.HUD
which displays the node Heads-Up-Display set withsetHUD(processing.core.PShape)
orsetHUD(Consumer)
.BOUNDS
which displays the bounding volume of each graph for which this node is the eye. Only meaningful if there's a second scene perspective to look at this eye node from.SHAPE
which displays the node shape set withsetShape(processing.core.PShape)
orsetShape(Consumer)
.BULLSEYE
which displays a bullseye centered at the nodeworldPosition()
screen projection. CallsetBullsEyeSize(float)
to set the size of the hintTORUS
which displays a torus solenoid.
enableHint(int)
) and then calling aGraph
rendering algorithm.
-
resetHint
public void resetHint()
Resets the currenthint()
, i.e., disables all single visual hints available for the node.
-
disableHint
public void disableHint(int hint)
Disables all the single visual hints encoded in the bitwise-orhint
mask.
-
enableHint
public void enableHint(int hint, Object... params)
CallsenableHint(int)
followed byconfigHint(int, Object...)
.
-
enableHint
public void enableHint(int hint)
Enables all single visual hints encoded in the bitwise-orhint
mask.
-
toggleHint
public void toggleHint(int hint)
Toggles all single visual hints encoded in the bitwise-orhint
mask.
-
configHint
public void configHint(int hint, Object... params)
Configures the hint using varargs as follows:CAMERA
hint:configHint(Node.CAMERA, cameraStroke)
orconfigHint(Node.CAMERA, cameraStroke, cameraLength)
.AXES
hint:configHint(Node.AXES, axesLength)
.BULLSEYE
hint:configHint(Node.BULLSEYE, bullseyeStroke)
,configHint(Node.BULLSEYE, bullseyeShape)
, orconfigHint(Node.BULLSEYE, bullseyeStroke, bullseyeShape)
.TORUS
hint:configHint(Node.TORUS, torusStroke)
, orconfigHint(Node.TORUS, torusStroke, torusFaces)
.BOUNDS
hint:configHint(Node.BOUNDS, boundsWeight)
.KEYFRAMES
hint:configHint(Node.KEYFRAMES, keyframesMask)
orconfigHint(Node.KEYFRAMES, keyframesMask, steps)
orconfigHint(Node.KEYFRAMES, keyframesMask, steps, splineStroke)
, orconfigHint(Node.KEYFRAMES, keyframesMask, steps, splineStroke, splineWeight)
.
cameraStroke
,splineStroke
,bullseyeStroke
andtorusStroke
are colorint
vars;cameraLength
andexesLength
are world magnitude numerical values;highlight
is a numerical value in[0..1]
which represents the scale factor to be applied to the node when it gets tagged (seeGraph.tag(String, Node)
);bullseyeShape
is either of typeNode.BullsEyeShape.SQUARE
orNode.BullsEyeShape.CIRCLE
;graph
is of typeGraph
;graph
may be of typePGraphics
; and,boundsWeight
is an int defining the bounds stroke andsplineWeight
is an int defining the spline stroke.
-
isEye
public boolean isEye()
Returns whether or not this node is some graphGraph.eye()
.
-
isEye
public boolean isEye(Graph graph)
Returns whether or not this node is the givengraph
Graph.eye()
.
-
animate
public void animate()
Run the animation defined by the node keyframes.
-
animate
public void animate(float speed)
Run the animation with the givenspeed
defined by the node keyframes.
-
toggleAnimation
public void toggleAnimation()
Toggles the node animation.
-
resetAnimation
public void resetAnimation()
Resets the node animation.
-
animationTime
public float animationTime()
Returns the current interpolation time (in milliseconds) along the keyframes path.
-
setAnimationTime
public void setAnimationTime(float time)
Sets the animation time (in milliseconds) used for the nextanimate()
call.
-
addKeyFrame
public void addKeyFrame()
Adds a node copy as keyframe at0
time if there are no currently keyframes in the path. Otherwise the keyframe is added 1000 milliseconds after the previously added one.
-
addKeyFrame
public void addKeyFrame(int hint, float time)
Adds a node copy as a keyframe attime
(in milliseconds) and a maskhint
.
-
addKeyFrame
public void addKeyFrame(Node node)
Addsnode
(as is) as a keyframe.
-
addKeyFrame
public void addKeyFrame(Node node, float time)
Addsnode
(as is) as a keyframe at the giventime
(in milliseconds).
-
removeKeyFrame
public Node removeKeyFrame(float time)
Remove the closest keyframe totime
(in milliseconds) and returns it. May returnnull
if the interpolator is empty.
-
removeKeyFrames
public void removeKeyFrames()
Removes all keyframes from the animation path.
-
interpolate
public void interpolate(float time)
Interpolate the node at the given time (in milliseconds) along the keyframes path.
-
animationRecurrence
public boolean animationRecurrence()
Tells whether or not the keyframes animation is recurrent or not.
-
setAnimationRecurrence
public void setAnimationRecurrence(boolean enable)
Enables (or disables) the recurrence of the keyframes animation.
-
-