{"id":216,"date":"2011-04-10T16:33:27","date_gmt":"2011-04-10T14:33:27","guid":{"rendered":"http:\/\/www.ancor.ch\/schoebey\/?p=216"},"modified":"2011-04-12T22:02:02","modified_gmt":"2011-04-12T20:02:02","slug":"connecting-nodes-to-path-items","status":"publish","type":"post","link":"https:\/\/www.ancor.ch\/schoebey\/?p=216","title":{"rendered":"connecting nodes to path-items"},"content":{"rendered":"<p>in order to use the new nodes to connect path items with each other, the items need a set of new functions:<\/p>\n<ul>\n<li>createNode &#8211; to create a new node (the item has to store it, analog to the config window)<\/li>\n<li>&#8216;callback&#8217;-functions that get notified whenever a connection to a certain input\/output connector is made<\/li>\n<\/ul>\n<p>additionally, nodes need to be able to display certain UI elements within.<\/p>\n<p><!--more--><\/p>\n<h2>data types<\/h2>\n<p>input\/output data types will each get a color assigned to them, with white being &#8216;undetermined&#8217;.<\/p>\n<p>White connectors will allow any data type to be connected to them, \u00c2\u00a0forcing other white connectors to only accept the first data type connected.<\/p>\n<p>e.g. if an &#8216;add&#8217; node has two inputs and one output, all three connectors are white.<\/p>\n<p>if a 4d vector (red) is connected to the first input, the remaining two connectors turn red, indicating that no data type other than a 4d vector (or compatible types) can be added to the first one and that the result will again be a 4d vector.<\/p>\n<p>This concept can be expanded by allowing compatible types to be connected as well.<\/p>\n<p>int and double are allowed types for addition, so the data type of the first input connector would determine the output type and the way the operation is performed.<\/p>\n<p>&nbsp;<\/p>\n<h2>saving and loading a node system<\/h2>\n<p>the node system is managed by its container, the scene (or a class derived from it).<\/p>\n<p>That class has a save(), load() and postLoad() method in order to save the node graph and restore it.<\/p>\n<h3>Saving<\/h3>\n<p>the number of nodes are saved, the for each node, its save function is called right after three basic properties are stored in the stream:<\/p>\n<p>the node id, the node type and the id of the node&#8217;s parent object (if there is one, else -1 is stored).<\/p>\n<h3>loading<\/h3>\n<p>the three properties are read back from the stream prior to creating the new node.<\/p>\n<p>Depending on the type of the node, it is either created locally (i.e. &#8216;add&#8217; or &#8216;subtract&#8217; nodes) or remotely by calling the createNode() method of the node&#8217;s parent path item (&#8216;object&#8217;, &#8216;action&#8217; or &#8216;trigger&#8217; nodes).<\/p>\n<p>then, after the node has been created, its load() function is called.<\/p>\n<h3>post-loading<\/h3>\n<p>like with path-items before, post-loading is used to de-swizzle pointers. Parent path item IDs are resolved into pointers, outgoing connections are restored by resolving node ids to node pointers, then creating a connection between the output connector and the input connector(s) of the remote node id.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>in order to use the new nodes to connect path items with each other, the items need a set of new functions: createNode &#8211; to create a new node (the item has to store it, analog to the config window) &#8216;callback&#8217;-functions that get notified whenever a connection to a certain input\/output connector is made additionally, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,4],"tags":[],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-code","category-design","category-p407"],"_links":{"self":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":3,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions\/218"}],"wp:attachment":[{"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ancor.ch\/schoebey\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}