Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Create a node

AntoineCharton edited this page Jan 4, 2018 · 1 revision

Node Structure

  • Node should implement INode, IReceiver interfaces
  • Node input or output should be set in the setup() function.

Node Namespaces:

  • 100% functionnal nodes should be in inside one of the following namespaces: Constellation.Math, Constellation.UI, Constellation.Unity, Constellation.BasicNodes, Constellation.Physics.
  • Incomplete and test nodes should be inside Constellation.ExperimentalNodes. and be setted inside experimental node factory.

Pattern.

Stock nodes should use one of the node Factory to be instantiated and should be set inside the one linked to it's namespace. Ex: You create a MousePosition.cs class you should add it to Constellation.Unity namespace and instantiate it inside UnityNodeFactory.cs

Example

namespace Constellation.ExperimentalNodes{
    public class Example: INode, IReceiver{
        private ISender sender;
        private Attribute attribute;
        public const string NAME = "Example";

        public void Setup (INodeParameters _node, ILogger _logger) {
            var wordValue = new Variable ();
            _node.AddInput (this, false, "Cold input example");
            _node.AddInput (this, true, "Warm input example");
            sender = _node.AddOutput (false, "Current setted word");
            attribute = _node.AddAttribute (wordValue.Set("My default value"), Attribute.AttributeType.ReadOnlyValue, "");
        }

        public string NodeName () {
            return NAME;
        }

        public string NodeNamespace () {
            return NameSpace.NAME;
        }

        public void Receive (Variable _value, Input _input) {
            if (_input.InputId == 0)
                attribute.Value.Set (_value);

            if (_input.InputId == 1)
                sender.Send (attribute.Value, 0);
        }
    }
}

Variable

Variable is very simillar to javascript variables. It basically do conversions for you so you don't have to worry about type in the editor. Variable has 4 types;

  • number
  • string
  • bool
  • object
  • Variable[]

Setting a variable

new Variable();

Set an empty variable.;

new Variable(0); var variable = new Variable(); variable.Set(0);

Set a number variable

var variable = new Variable("my string"); variable.Set(0);

On the first line variable is a string and on the second one it become a float

Tutorials

Beginner

intermediate

advanced

OSC

Contribute

Create a node

Documentation

[Error codes] link

Clone this wiki locally