User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:10_rgg_addition:04_operator_overload:01_node

Nodes

The most commonly used overload operators are applied to the Nodes.

Index

  • Node[Property] return the field with the given name of the node.
  • Node[Attribute] (graph attribute) return the attribute of the node. Only nodes that are part of the graph have graph attributes.
  • Node[int] get the n-th successor of the first branch of the Node. (useless?)
    • Node[NodeToInt] evaluate the function (NodeToInt) on the node.
    • Node[NodeToFloat] evaluate the function (NodeToFloat) on the node.
    • Node[NodeToDouble] evaluate the function (NodeToDouble) on the node.
  • Node[Location] evaluate the Location of the Node. The Location object can be null.

E.g.

module A(float len) extends Sphere; 
protected void init()[ Axiom ==> Translate(1,1,2) A; ]
 
static NodeToFloat fx = new NodeToFloat(){
	public float evaluateFloat(Node n){
		return location(n).x+location(n).y+location(n).z;
	}
};
 
 
void run(){
    A a = first((*A*)); // get a A that belong to the graph.
 
    a[len]; // get the field "len" of the node a.
 
    // Attributes 
    println( (de.grogra.vecmath.geom.Sphere) // get the VOLUME of the node
	a[de.grogra.imp3d.VolumeAttribute.ATTRIBUTE] 
    );
 
    println( (de.grogra.imp3d.objects.Sphere) // get the SHAPE of the node
	a[de.grogra.imp3d.objects.Attributes.SHAPE]
    );
 
    // Functions 
    a[ORDER]; // return the branching order according to the L-System definition it is a turtle state funtion.
    a[Location.X]; // return the global X location of a;
    a[Location.XYZ]; // return the global location as a Point3d
    a[fx]; // returns the sum of the coordinates as defined in the NodeToFloat lambda fx
 
}

LT, LE, GT, GE

  • Node > Node
  • Node >= Node
  • Node < Node
  • Node <= Node

All compare the IDs of the nodes.

SHL/RHL

The left and right shift can be used to forward the transformation matrix (Matrix4d) of a node that extends Null(de.grogra.imp3d.objects.Null) to another Null extending node.

This can be used to rewrite a node while keeping the applied local transformation.

protected void init ()
[
	Axiom ==> Box;
]
public void run ()
[
	//b:Box ==> Sphere.(b >> $);
	b:Box ==> Sphere.($ << b);
]

In the example above the box can be moved/rotated/scaled with the UI tools and after the run function is executed the Box is in the same position. The same effect can be described explicitly with b:Box ==> Sphere.($[transform]=b[transform]);.

This also works with Matrix4d objects as input or output.

ushl/ushr

The operator can be used with two Null extending nodes to forward all possible parameters from the right Node to the left Node(ushl) or from the left to the right (ushr). This is based on the inheritance of object orientation.

module A(float len) extends Sphere(0.1)
{
	{setShader(GREEN);}
}
 
protected void init ()
[
	Axiom ==> A(1);
]
 
public void run ()
[
	a:A ==> Sphere.($ <<<a); // creates a sphere with the same transformation, Shader and radius 
]
 
public void run2 ()
[
	a:A ==> Box.(a >>> $);// creates a Box with the same transformation and Shader 
 
]
01_user_documentation/07_rgg_xl/02_xl/10_rgg_addition/04_operator_overload/01_node.txt · Last modified: 2026/03/27 17:42 by Tim