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 alsocullandbypass()).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 arenullresulting 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,translationPlaneFilterandrotationAxisFilter) 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:
refer toNode 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 classNode.BullsEyeShape
-
Field Summary
Fields Modifier and Type Field Description static intAXESstatic intBONEstatic intBOUNDSstatic intBULLSEYEfloatcacheMagnitudeQuaternioncacheOrientationVectorcachePositionObject[]cacheRotationParamsObject[]cacheScalingParamsfloatcacheTargetMagnitudeQuaternioncacheTargetOrientationVectorcacheTargetPositionQuaternioncacheTargetRotationfloatcacheTargetScalingVectorcacheTargetTranslationObject[]cacheTranslationParamsstatic intCAMERAbooleancullstatic intFILTERstatic BiFunction<Node,Object[],Quaternion>forbidRotationFilterFilters rotation so that it gets nullified.static BiFunction<Node,Object[],Float>forbidScalingFilterFilters scaling so that it gets nullified.static BiFunction<Node,Object[],Vector>forbidTranslationFilterFilters translation so that it gets nullified.static intHUDstatic intKEYFRAMESstatic intmaxStepsstatic BiFunction<Node,Object[],Float>minMaxScalingFilterFilters scaling so that the node magnitude lies in[min..max].static BiFunction<Node,Object[],Quaternion>rotationAxisFilterFiltersquaternionso that itsQuaternion.axis()becomeaxis(defined in this node coordinate system).static intSHAPEbooleantaggingstatic intTORUSstatic BiFunction<Node,Object[],Vector>translationAxisFilterFilters translation so that the node is translated alongaxis(defined in this node coordinate system).static BiFunction<Node,Object[],Vector>translationPlaneFilterFilters 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 withreferenceasreference(), havingposition,orientationandmagnitudeas 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 withreferenceasreference()andshape, havingposition,orientationandmagnitudeas 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 voidaddKeyFrame()Adds a node copy as keyframe at0time if there are no currently keyframes in the path.voidaddKeyFrame(int hint, float time)Adds a node copy as a keyframe attime(in milliseconds) and a maskhint.voidaddKeyFrame(Node node)Addsnode(as is) as a keyframe.voidaddKeyFrame(Node node, float time)Addsnode(as is) as a keyframe at the giventime(in milliseconds).voidalign()Same asalign(null).voidalign(boolean move)Same asalign(move, null).voidalign(boolean move, float threshold)Same asalign(move, threshold, null).voidalign(boolean move, float threshold, Node node)Aligns the node withnode, so that two of their axis are parallel.voidalign(boolean move, Node node)Convenience function that simply callsalign(move, 0.85f, node).voidalign(float threshold)Same asalign(threshold, null).voidalign(float threshold, Node node)Convenience function that simply callsalign(false, threshold, node).voidalign(Node node)Convenience function that simply callsalign(false, 0.85f, node)voidanimate()Run the animation defined by the node keyframes.voidanimate(float speed)Run the animation with the givenspeeddefined by the node keyframes.booleananimationRecurrence()Tells whether or not the keyframes animation is recurrent or not.floatanimationTime()Returns the current interpolation time (in milliseconds) along the keyframes path.voidattach()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 floatblueID(int id)Convert intidto blue.floatbullsEyeSize()voidbypass()Bypass rendering the node for the current frame.List<Node>children()Returns the list a child nodes of this node.intcolorID()Uniquely identifies the node.static intcolorID(int id)Convert intidto color.voidconfigHint(int hint, Object... params)Configures the hint using varargs as follows:Nodecopy()Same asreturn copy(true).Nodecopy(boolean recursive)Performs a deep copy of this node, and its descendants iffrecursiveistrue.voiddetach()Detach node from the tree so that it's not reached from theGraph.render()algorithm and make all the nodes in thenodebranch eligible for garbage collection.voiddisableHint(int hint)Disables all the single visual hints encoded in the bitwise-orhintmask.voiddisablePicking(int hint)Disables all the single visual hints encoded in the bitwise-orhintmask.floatdisplacement(float scalar)Convertsscalardisplacement from world to this node.floatdisplacement(float scalar, Node node)Convertsscalardisplacement fromnodeto this node.Quaterniondisplacement(Quaternion quaternion)Convertsquaterniondisplacement from world to this node.Quaterniondisplacement(Quaternion quaternion, Node node)Convertsquaterniondisplacement fromnodeto this node.Vectordisplacement(Vector vector)Convertsvectordisplacement from world to this node.Vectordisplacement(Vector vector, Node node)Convertsvectordisplacement fromnodeto this node.voidenableHint(int hint)Enables all single visual hints encoded in the bitwise-orhintmask.voidenableHint(int hint, Object... params)CallsenableHint(int)followed byconfigHint(int, Object...).voidenablePicking(int picking)Enables all single visual hints encoded in the bitwise-orpickingModemask.voidfromMatrix(Matrix matrix)Sets the node from amatrix()representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.voidfromWorldMatrix(Matrix matrix)Sets the node fromworldMatrix()representation: orientation and magnitude in the upper left 3x3 matrix and position on the last column.static floatgreenID(int id)Convert intidto green.floathighlight()Returns the highlighting magnitude use to scale the node when it's tagged.inthint()Returns the current visual hint mask.intid()Returns the unique sequential node id assigned at instantiation time.voidinteract(Object[] gesture)Parsegestureparams.voidinterpolate(float time)Interpolate the node at the given time (in milliseconds) along the keyframes path.Nodeinverse()Nodeinverse(boolean attach)Returns a node representing the inverse of this node space transformation.booleanisAncestor(Node node)Returnstrueifnodeis ancestor ofthisnode.static booleanisAncestor(Node successor, Node ancestor)Same asreturn successor.isAncestor(ancestor).booleanisAttached()Returns whether or not the node is reachable by the rendering algorithm.booleanisEye()Returns whether or not this node is some graphGraph.eye().booleanisEye(Graph graph)Returns whether or not this node is the givengraphGraph.eye().booleanisHintEnabled(int hint)Returns whether or not all single visual hints encoded in the bitwise-orhintmask are enable or not.booleanisPickingEnabled(int hint)Returns whether or not all hints encoded in the bitwise-orhintmask are enable for node picking with ray casting.booleanisReference(Node node)booleanisTagged(Graph graph)Returnstrueif thenodehas been tagged by thegraphat least once andfalseotherwise.longlastUpdate()floatlocalDisplacement(float scalar)Convertsscalardisplacement fromreference()to this node.QuaternionlocalDisplacement(Quaternion quaternion)Convertsquaterniondisplacement fromreference()to this node.VectorlocalDisplacement(Vector vector)Convertsvectordisplacement fromreference()to this node.VectorlocalLocation(Vector vector)Convertsvectorlocation fromreference()to this node.Vectorlocation(Node node)Converts thenodeorigin location to this node.Vectorlocation(Vector vector)Convertsvectorlocation from world to this node.Vectorlocation(Vector vector, Node node)Convertsvectorlocation fromnodeto this node.floatmagnitude()Returns the node magnitude, defined with respect to thereference().booleanmatches(Node node)Returns whether this node matches other taking into account theworldPosition(),worldOrientation()andworldMagnitude()node parameters.Matrixmatrix()Returns the local transformation matrix represented by the node.voidorbit(Vector axis, float angle)Rotates the node aroundaxispassing through the origin, both defined in the world coordinate system.voidorbit(Vector axis, float angle, float inertia)Same asorbit(axis, angle, new Vector(), inertia).voidorbit(Vector axis, float angle, Vector center)Rotates the node aroundaxispassing throughcenter, both defined in the world coordinate system.voidorbit(Vector axis, float angle, Vector center, float inertia)Same asorbit(new Quaternion(displacement(axis), angle), center, inertia).Quaternionorientation()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 fromtailtotip.intpicking()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.Vectorposition()Returns the node position, defined with respect to thereference().voidprojectOnLine(Vector origin, Vector direction)Translates the node so that itsworldPosition()lies on the line defined byoriginanddirection(defined in the world coordinate system).static Noderandom(Graph graph)Returns a random node attached tograph.static Noderandom(Vector center, float radius, boolean is3D)Returns a random node.voidrandomize(Vector center, float radius, boolean is3D)Randomized this node.static floatredID(int id)Convert intidto red.Nodereference()Returns the reference node, in which this node is defined.floatreferenceDisplacement(float scalar)Convertsscalardisplacement from this node toreference().QuaternionreferenceDisplacement(Quaternion quaternion)Convertsquaterniondisplacement from this node toreference().VectorreferenceDisplacement(Vector vector)Convertsvectordisplacement from this node toreference().VectorreferenceLocation(Vector vector)Convertsvectorlocation from this node toreference().NoderemoveKeyFrame(float time)Remove the closest keyframe totime(in milliseconds) and returns it.voidremoveKeyFrames()Removes all keyframes from the animation path.booleanrendered(Graph graph)Tells whether the node was rendered in the last frame fromgraphafter a call toGraph.render(Node)is issued.voidreset()voidresetAnimation()Resets the node animation.voidresetBehavior(Graph graph)Same asgraph.resetBehavior(this).voidresetHint()Resets the currenthint(), i.e., disables all single visual hints available for the node.voidresetHUD()Same as callingresetRMRHUD()andresetIMRHUD().voidresetIMRHUD()Same assetIMRShape(null).voidresetIMRShape()Resets the immediate-mode rendering shape.voidresetInertia()Stops all node inertia's.voidresetPicking()Resetspicking(), i.e., disables all single visual hints available for node picking with ray casting.voidresetReference()Setsreference()to the world and make this node reachable (seeisAttached()).voidresetRMRHUD()Same assetRMRShape(null).voidresetRMRShape()Resets the retained-mode rendering shape.voidresetRotationFilter()Nullifies therotationFilter().voidresetScalingFilter()Nullifies thescalingFilter().voidresetShape()CallsresetIMRShape()andresetRMRShape().voidresetTranslationFilter()Nullifies thetranslationFilter().voidrotate(float x, float y, float z, float angle)Same asrotate(new Vector(x,y,z), angle).voidrotate(float x, float y, float z, float angle, float inertia)Same asrotate(new Vector(x, y, z), angle, inertia).voidrotate(Quaternion quaternion)Same asorientation().compose((rotationfilter() != null) ? rotationfilter().apply(this, cacheRotationParams) : quaternion).voidrotate(Quaternion quaternion, float inertia)Rotates the node byquaternion(defined in the node coordinate system):orientation().compose(quaternion)and with an impulse defined withinertiawhich should be in[0..1], 0 no inertia & 1 no friction.voidrotate(Vector axis, float angle)Same asrotate(new Quaternion(axis, angle)).voidrotate(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).voidscale(float scaling)Same asmagnitude() = magnitude() * (scalingFilter() != null ? scalingFilter().apply(this, cacheScalingParams) : scaling).voidscale(float scaling, float inertia)Scales the node according toscaling, locally defined with respect to thereference()and with an impulse defined withinertiawhich should be in[0..1], 0 no inertia & 1 no friction.BiFunction<Node,Object[],Float>scalingFilter()Returns the scaling filter used byscale(float).voidset(Node node)voidsetAnimationRecurrence(boolean enable)Enables (or disables) the recurrence of the keyframes animation.voidsetAnimationTime(float time)Sets the animation time (in milliseconds) used for the nextanimate()call.voidsetBehavior(Graph graph, BiConsumer<Graph,Node> behavior)Same asgraph.addBehavior(this, behavior).voidsetBehavior(Graph graph, Consumer<Graph> behavior)Same asgraph.addBehavior(this, (g, n) -> behavior.accept(g)).voidsetBullsEyeSize(float size)voidsetForbidRotationFilter()Same assetRotationFilter(forbidRotationFilter, new Object[] {}).voidsetForbidScalingFilter()Same assetScalingFilter(forbidScalingFilter, new Object[] {}).voidsetForbidTranslationFilter()Same assetTranslationFilter(forbidTranslationFilter, new Object[] {}).voidsetHighlight(float highlight)Sets the nodehighlight()which should be a value in[0..1].voidsetHUD(Consumer<PGraphics> callback)voidsetHUD(Node node)Sets this (H)eads (U)p (D)isplay from thenodehud.voidsetHUD(PShape shape)voidsetInteraction(BiConsumer<Node,Object[]> callback)Sets the node interaction procedurecallbackwhich is a function that takes a node param (holding this node instance) and, optionally, a gesture encoded as an array of on Object params.voidsetInteraction(Consumer<Object[]> callback)Sets the node interaction procedurecallbackwhich is a function implemented by aNodederived class and which takes no params, or a gesture encoded as an array of on Object params.voidsetMagnitude(float magnitude)Sets themagnitude()of the node, locally defined with respect to thereference().voidsetMinMaxScalingFilter(float min, float max)Same assetScalingFilter(Node.minMaxScalingFilter, new Object[] { min, max }).voidsetOrientation(float x, float y, float z, float w)Same assetOrientation(Quaternion)but withfloatQuaternion parameters.voidsetOrientation(Quaternion orientation)Sets the nodeorientation(), locally defined with respect to thereference().voidsetPosition(float x, float y)Same assetPosition(Vector), but withfloatparameters.voidsetPosition(float x, float y, float z)Same assetPosition(Vector), but withfloatparameters.voidsetPosition(Vector position)Caches theposition()of the node, locally defined with respect to thereference().voidsetReference(Node node)Sets thereference()of the node.voidsetRotationAxisFilter(Vector axis)Same assetRotationFilter(Node.rotationAxisFilter, new Object[] { axis }).voidsetRotationFilter(BiFunction<Node,Object[],Quaternion> filter, Object[] params)Sets therotationFilter()and itscacheRotationParams.voidsetScalingFilter(BiFunction<Node,Object[],Float> filter, Object[] params)Sets thescalingFilter()and itscacheScalingParams.voidsetShape(Consumer<PGraphics> callback)voidsetShape(Node node)Sets this shape from thenodeshape.voidsetShape(PShape shape)voidsetTranslationAxisFilter(Vector axis)Same assetTranslationFilter(translationAxisFilter, new Object[] { axis }).voidsetTranslationFilter(BiFunction<Node,Object[],Vector> filter, Object[] params)Sets thetranslationFilter()and itscacheTranslationParams.voidsetTranslationFilter(Function<Object[],Vector> filter, Object[] params)voidsetTranslationPlaneFilter(Vector normal)Same assetTranslationFilter(translationPlaneFilter, new Object[] { axis }).voidsetWorldMagnitude(float magnitude)Sets theworldMagnitude()of the node, defined in the world coordinate system.voidsetWorldMagnitude(Node node)Sets theworldMagnitude()to that ofnode.voidsetWorldOrientation(float x, float y, float z, float w)Same assetWorldOrientation(Quaternion), but withfloatparameters.voidsetWorldOrientation(Node node)Sets theworldOrientation()to that ofnode.voidsetWorldOrientation(Quaternion quaternion)Sets theworldOrientation()of the node, defined in the world coordinate system.voidsetWorldPosition(float x, float y)Same assetWorldPosition(Vector), but withfloatparameters.voidsetWorldPosition(float x, float y, float z)Same assetWorldPosition(Vector), but withfloatparameters.voidsetWorldPosition(Node node)Sets theworldPosition()to that ofnode.voidsetWorldPosition(Vector position)Sets the nodeworldPosition(), defined in the world coordinate system.voidsetXAxis(Vector axis)Rotates the node so that itsxAxis()becomesaxisdefined in the world coordinate system.voidsetYAxis(Vector axis)Rotates the node so that itsyAxis()becomesaxisdefined in the world coordinate system.voidsetZAxis(Vector axis)Rotates the node so that itszAxis()becomesaxisdefined in the world coordinate system.voidtoggleAnimation()Toggles the node animation.voidtoggleHint(int hint)Toggles all single visual hints encoded in the bitwise-orhintmask.voidtogglePicking(int hint)Toggles all single visual hints encoded in the bitwise-orhintmask.StringtoString()Return this node components as a String.voidtranslate(float x, float y, float z)Same astranslate(Vector)but withfloatparameters.voidtranslate(float x, float y, float z, float inertia)Same astranslate(new Vector(x, y, z), inertia).voidtranslate(Vector vector)Same asposition().add((translationFilter() != null) ? translationFilter().apply(this, cacheTranslationParams) : vector).voidtranslate(Vector vector, float inertia)Translates the node according tovector, locally defined with respect to thereference()and with an impulse defined withinertiawhich should be in[0..1], 0 no inertia & 1 no friction.BiFunction<Node,Object[],Vector>translationFilter()Returns the translation filter used bytranslate(Vector).Matrixview()Returns the inverse of the matrix associated with the node position and orientation that is to be used when the node represents an eye.MatrixviewInverse()Returns the inverse of theview()matrix.floatworldDisplacement(float scalar)Convertsscalardisplacement from this node to world.QuaternionworldDisplacement(Quaternion quaternion)Convertsquaterniondisplacement from this node to world.VectorworldDisplacement(Vector vector)Convertsvectordisplacement from this node to world.NodeworldInverse()NodeworldInverse(boolean attach)Returns theinverse()of the node world transformation.VectorworldLocation(Vector vector)Convertsvectorlocation from this node to world.floatworldMagnitude()Returns the magnitude of the node, defined in the world coordinate system.MatrixworldMatrix()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()).QuaternionworldOrientation()Returns the orientation of the node, defined in the world coordinate system.VectorworldPosition()Returns the node position defined in the world coordinate system.VectorxAxis()Same asreturn xAxis(true)VectorxAxis(boolean positive)Returns the x-axis of the node, represented as a normalized vector defined in the world coordinate system.VectoryAxis()Same asreturn yAxis(true)VectoryAxis(boolean positive)Returns the y-axis of the node, represented as a normalized vector defined in the world coordinate system.VectorzAxis()Same asreturn zAxis(true)VectorzAxis(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
Filtersquaternionso 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)}. Theattachvar 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). Theattachvar 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). Theattachvar 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 withreferenceasreference(), havingposition,orientationandmagnitudeas theposition(),orientation()andmagnitude(), respectively. ThebullsEyeSize()is set to0.2and thehighlight()hint magnitude to0.15. The nodeisAttached()by theGraph.render()algorithm iff the nodereferencehappens 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 withreferenceasreference()andshape, havingposition,orientationandmagnitudeas theposition(),orientation()andmagnitude(), respectively. ThebullsEyeSize()is set to0and 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 iffrecursiveistrue. 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 intidto 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)
Returnstrueifnodeis ancestor ofthisnode.
-
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 fromtailtotip. Returns an empty list iftailis 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. Anullreference 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.,
nullreference()). No action is performed if settingreferenceas thereference()would create a loop in the hierarchy.To make all the nodes in the
nodebranch 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 fromgraphafter 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 thenodebranch 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 bycenterandradius, 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 thegraphviewing 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 bycenterandradius(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 theBULLSEYEhint().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 withfloatparameters.
-
setPosition
public void setPosition(float x, float y, float z)Same assetPosition(Vector), but withfloatparameters.
-
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 withfloatparameters.
-
translate
public void translate(Vector vector, float inertia)
Translates the node according tovector, locally defined with respect to thereference()and with an impulse defined withinertiawhich 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 withfloatparameters.
-
setWorldPosition
public void setWorldPosition(float x, float y, float z)Same assetWorldPosition(Vector), but withfloatparameters.
-
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 withfloatQuaternion 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 withinertiawhich 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 aroundaxispassing 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 aroundaxispassing 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 withfloatparameters.
-
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 withinertiawhich 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.
thresholdmeasures 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
moveis set totrue, the NodeworldPosition()is also affected by the alignment. The new NodeworldPosition()is such that thenodenode position (computed withlocation(Vector), in the Node coordinates system) does not change.nodemay benulland 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 byoriginanddirection(defined in the world coordinate system).Simply uses an orthogonal projection.
directiondoes not need to be normalized.
-
setXAxis
public void setXAxis(Vector axis)
Rotates the node so that itsxAxis()becomesaxisdefined 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()becomesaxisdefined 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()becomesaxisdefined 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
nodewhile 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)
Convertsscalardisplacement 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)Convertsscalardisplacement fromnodeto 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)
Convertsscalardisplacement 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)
Convertsscalardisplacement fromreference()to this node.referenceDisplacement(float)performs the inverse transformation.- See Also:
displacement(Quaternion),displacement(Vector)
-
referenceDisplacement
public float referenceDisplacement(float scalar)
Convertsscalardisplacement from this node toreference().localDisplacement(float)performs the inverse transformation.
-
displacement
public Quaternion displacement(Quaternion quaternion)
Convertsquaterniondisplacement 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)
Convertsquaterniondisplacement fromnodeto 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)
Convertsquaterniondisplacement 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)
Convertsquaterniondisplacement 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)
Convertsquaterniondisplacement from this node toreference().localDisplacement(Quaternion)performs the inverse transformation.referenceLocation(Vector)converts locations instead of displacements.
-
displacement
public Vector displacement(Vector vector)
Convertsvectordisplacement 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)
Convertsvectordisplacement fromnodeto 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)
Convertsvectordisplacement 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)
Convertsvectordisplacement 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)
Convertsvectordisplacement 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 thenodeorigin 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)
Convertsvectorlocation 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)
Convertsvectorlocation fromnodeto 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)
Convertsvectorlocation 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)
Convertsvectorlocation 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)
Convertsvectorlocation 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)
Returnstrueif thenodehas been tagged by thegraphat least once andfalseotherwise.- 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 thenodeshape.
-
setShape
public void setShape(PShape shape)
Sets the node retained mode rendering (rmr)SHAPEhint (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 procedurecallbackwhich is a function implemented by aNodederived 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 procedurecallbackwhich 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)
Parsegestureparams. 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 thenodehud.
-
setHUD
public void setHUD(PShape shape)
Sets the node retained mode rendering (rmr) shapeHUDhint (seehint()). The 2Dshapescreen 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 procedureHUDhint (seehint()). The 2Dshapescreen 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-orhintmask 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-orhintmask.
-
enablePicking
public void enablePicking(int picking)
Enables all single visual hints encoded in the bitwise-orpickingModemask.
-
togglePicking
public void togglePicking(int hint)
Toggles all single visual hints encoded in the bitwise-orhintmask.
-
isHintEnabled
public boolean isHintEnabled(int hint)
Returns whether or not all single visual hints encoded in the bitwise-orhintmask 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:CAMERAwhich displays a camera hint centered at the node screen projection.AXESwhich displays an axes hint centered at the nodeworldPosition()an oriented according to the nodeworldOrientation().HUDwhich displays the node Heads-Up-Display set withsetHUD(processing.core.PShape)orsetHUD(Consumer).BOUNDSwhich 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.SHAPEwhich displays the node shape set withsetShape(processing.core.PShape)orsetShape(Consumer).BULLSEYEwhich displays a bullseye centered at the nodeworldPosition()screen projection. CallsetBullsEyeSize(float)to set the size of the hintTORUSwhich displays a torus solenoid.
enableHint(int)) and then calling aGraphrendering 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-orhintmask.
-
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-orhintmask.
-
toggleHint
public void toggleHint(int hint)
Toggles all single visual hints encoded in the bitwise-orhintmask.
-
configHint
public void configHint(int hint, Object... params)Configures the hint using varargs as follows:CAMERAhint:configHint(Node.CAMERA, cameraStroke)orconfigHint(Node.CAMERA, cameraStroke, cameraLength).AXEShint:configHint(Node.AXES, axesLength).BULLSEYEhint:configHint(Node.BULLSEYE, bullseyeStroke),configHint(Node.BULLSEYE, bullseyeShape), orconfigHint(Node.BULLSEYE, bullseyeStroke, bullseyeShape).TORUShint:configHint(Node.TORUS, torusStroke), orconfigHint(Node.TORUS, torusStroke, torusFaces).BOUNDShint:configHint(Node.BOUNDS, boundsWeight).KEYFRAMEShint:configHint(Node.KEYFRAMES, keyframesMask)orconfigHint(Node.KEYFRAMES, keyframesMask, steps)orconfigHint(Node.KEYFRAMES, keyframesMask, steps, splineStroke), orconfigHint(Node.KEYFRAMES, keyframesMask, steps, splineStroke, splineWeight).
cameraStroke,splineStroke,bullseyeStrokeandtorusStrokeare colorintvars;cameraLengthandexesLengthare world magnitude numerical values;highlightis 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));bullseyeShapeis either of typeNode.BullsEyeShape.SQUAREorNode.BullsEyeShape.CIRCLE;graphis of typeGraph;graphmay be of typePGraphics; and,boundsWeightis an int defining the bounds stroke andsplineWeightis 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 givengraphGraph.eye().
-
animate
public void animate()
Run the animation defined by the node keyframes.
-
animate
public void animate(float speed)
Run the animation with the givenspeeddefined 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 at0time 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 returnnullif 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.
-
-