Saturday, 17 July 2010
Context Switching Using Set Nodes and Filter
In the roll object compound below I use the Set nodes to move between point context and object context. Combined with filter, it's a powerful way to access an individual component in a specific context and make it available to all other components in that context.
On the list here (and on several occasions before), Ciaran Moloney has suggested a technique for using Set nodes, Filter and the Repeat node for gathering data in one context and turning it into an object context array. It's a great technique and one which deserves a closer look.
Whenever you use a specific context node e.g. point, node, polygon in the branch of an ICE Tree its context takes precedence over any object context nodes in the same branch. As soon as you try and set any data in that branch it will always be in the more granular context. Using the Get Set xx nodes, however, acts as a switch to the context of the branch and turns it back into object context. Put simply if you start off in 'polygon position' context you can finish the branch with a Get xx in Set node which provides you with a single piece of object context data e.g. maximum in set.
Ciaran's trick involves using this switching ability to continually iterate over each point, polygon or node and isolate a single item each time - pushing that item onto an object context array.
In the tree above I construct an object context array of all the node positions. You can see that the tree starts in node context but then each node has a repeat loop iterating over itself matching it's own element index with the list of all node element indexes. When it finds a match the output is a single node still in node context. Pumping this into Get Maximum in Set - a filtered set of one - simply switches the output to object context and the node position gets pushed onto an object context array.
The downside is obviously iteration time as each node has to iterate NbNodes times over itself and with large numbers of nodes, polygons etc. this could be slow. However, it seems like the only surefire way to construct robust object context arrays of node positions, polygon positions etc.
Subscribe to:
Post Comments (Atom)
Hey Jules, thanks for that. Thats pretty useful. You'd have thought that if we can construct that in ICE it should be possible to do it in a c++ node and maybe eliminate any inefficiencies. I don't know, I've not had a play with the ICE SDK yet.
ReplyDeleteTwo blog posts in two days huh? Nice!
Hi Andy,
ReplyDeleteI've been looking at it today but I'm not sure how straightforward it is to provide a generic node that will handle all context types and output an object context array...definitely worth a shot though :-)