Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Technical Architecture

fdb edited this page Oct 29, 2010 · 3 revisions

Basic building blocks

  • Node: The node is the basic building block in a scene. It contains a number of ports. During execution, it takes the values of the input ports, does some processing, and puts values in its output ports. To create a node, subclass from the Node class and override the execute method. If your node has some visual representation, you can also override the draw method.
  • Port: The port is a value slot on a node. It is used to tweak the operation of the node. Ports can be connected to other ports on different nodes. Ports have a type, such as integer, string or color. Generally, only ports of the same type can be connected, but a specific port can override this behavior and accept data from other port types.
  • Network: nodes are stored in networks. A network is a container for nodes. It is a node subclass itself, and can be contained in other networks, taking the shape of a tree. Ports of nodes in the network can be published. That means they are available on the network level. For procedural programming, networks are often used as blocks that need to be executed multiple times, such as the looper network.
  • Scene: All nodes are contained in a Scene. At the top is the root network and a number of scene properties, such as canvas size and the type of renderer (2D, 3D, etc.) The scene is the object that is saved and loaded.

Node Life Cycle

When writing a node, it is important to be aware of the node life cycle. The life cycle determines the method that get called during each stage of the node's life.

  • initialize: This method is called when the node is created. This is called just after the node is constructed and put in the network. It is called only once for every node instance. It is the counterpart of the destroy method.
  • activate: This method is called when the node is reachable from the rendered node, which means that it will be executed later. It can be used to initialize a web camera or open a network socket. It is the counterpart of the deactivate method.
  • execute: This method is called when the node needs to update its internal state. It does the bulk of the work, taking the values of the inputs, processing them, and setting its outputs. It should not cause any side effects, such as drawing to the canvas.
  • draw: This method is called when the node is the rendered node and needs to draw itself. It also takes the PGraphics object to draw to, which can be different from the PApplet's graphics (e.g. when exporting a PDF file)
  • deactivate: This method is called when the node is no longer reachable from the rendered node, and will not be executed or drawn. It can be used to stop a web camera or close a network socket. It is the counterpart of the activate method.
  • destroy: This method is called just before the node is removed from the network or the scene is closed. It can do any final cleanup not done in deactivate. It is the counterpart of initialize.
Clone this wiki locally