Extract X Y and Z Values from Arrays

bi0drain's picture

I am looking to use the coordinate values contained within Arrays of Structures generated by GL, 1024 modules, did not see a feasible way to extract the x-y-z values, Did work with the JS, got stuck. These are the target values in question, so I assume it would be the following process, Explode the array For-next loop out the X,Y,Z to specific outputs, and or tie the XYZ to the required number of outputs... where I am lost in the array--->structures explode.

PreviewAttachmentSize
Screen Shot 2014-02-22 at 10.10.41 PM.png
Screen Shot 2014-02-22 at 10.10.41 PM.png351.2 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Achim Breidenbach's picture
Re: Extract X Y and Z Values from Arrays

I am not sure if I get your application right, but this is how you would walk through a array of xyz-structures:

1) The output of "1024_Struture_Circle" seems to be an "array of dictionaries". Use a "Structure Count" patch to get the number of xyz-coordinates and connect the "Count" result into the "Iteration" input of an "Iterator" patch

2) Jump inside the Iterator patch and place a "Input Splitter" patch inside. Switch its value type to "Structure" and publish its input as "in XYZ Structure"

3) step outside the iterator macro, you should see the new input "in XYZ Structure" here. Connect the "XYZ Structure" from the "1024_Structure_Circle" patch to the "in XYZ Structure" input of the iterator.

Now you have an iterator that cycles 1024 times

4) Go into the iterator, and add an "Iterator Variable" patch. This patch spits out the index variable

5) add a "Structure Index Member" patch. connect the "XYZ Structure" to the "Structure" and "Index" from the "Iterator Variable" to "Index" of the "Structure Index Member". the output "Member" now is the dictionary containing only one dictionary at a loop cycle.

6) Add three "Structure Key Member" patches, connect the output "Member" of the "Structure Index Member" to each "Structure" inputs of the "Structure Key Member".

7) Change the "Key" input of the three "Structure Key Member" to "X", "Y" and "Z"

Now the outputs of those "Structure Key Member" patches are the three single values. You may now use them as the x,y and z inputs of a "Sprite" patch.

I am wondering why you are doing this. Looks like you want to draw a circle or something. You may also consider using a "Replicate in Space" patch which let your graphics card doing the repetition of 1024 drawing cycles rather than doing it on the CPU.

bi0drain's picture
Re: Extract X Y and Z Values from Arrays

It's not primarily for the circle functions, but I have some ideas for use with the structuretools, not just the circle which has a radius and a count function, but improving on what I can feed coordinate value wise in my modules.. From this starting point tho I can get to where I need to be.... I had feared I was going to have to handle the structure as an external plugin in C++. Thanks.