Save Interaction Positions

jersmi's picture

Any solution to date for out of order structures with file tools? This qtz uses Kineme File Tools, and .plist files are saved in order, but out of order when read by Struct From File. (Old story, afaik). I was wondering if there's a way with Kineme Data Tools, now that it can save Sample & Hold data with the comp. I can't see how.

PreviewAttachmentSize
Interaction_save_pos.qtz62.31 KB

Comment viewing options

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

franz's picture
Re: Save Interaction Positions

use a "key" in your structure. Later, refer to each element by "key" instead of index.

jersmi's picture
Re: Save Interaction Positions

hmm, thanks, but can't get it. i can produce keyed sub-structures. for ex., this javascript and interaction are inside an iterator:

_Queue = []
 
function (__structure Queue) main (__number x, __number y, __boolean mouseDown, __index Size)
 
{
   var result = new Object();
   //if(_Queue == undefined)
 
   if (mouseDown)
   {  var pos = new Object();
 
      pos["x"] = x;
      pos["y"] = y;
 
      _Queue.push(pos);
      if(_Queue.length > Size) _Queue.shift(pos);
      result.Queue = _Queue;
   }
   return result;
}

this produces an ordered structure which gets jumbled when read back in to the comp. (see screenshots). (EDIT: updated screenshots). how could i do what is suggested?

PreviewAttachmentSize
writeStruct-good.jpg
writeStruct-good.jpg33.47 KB
readStruct-jumbled.jpg
readStruct-jumbled.jpg38.63 KB

jersmi's picture
Re: Save Interaction Positions

I'm looking into one of usefuldesign's js demos with some sorting suggestions. Maybe folks have resolved this. I have asked similar question before but i still don't have a clear solution for sorting a .plist structure dictionary with integer key values when members get out of order.

usefuldesign.au's picture
Re: Save Interaction Positions

It really doesn't matter if the order is jumbled. You just choose to poll the object using the key not the index.

See attached demo.

I might have once suggested this is infact a problem I while back when I first banged my head against this (non)'problem', BTW ;-)

PreviewAttachmentSize
keys v indexes in objects.qtz9.64 KB

voxdeserti's picture
Re: Save Interaction Positions

Also you can add a bit more life to your comp))

PreviewAttachmentSize
Inertia_save_pos.qtz102.42 KB

gtoledo3's picture
Re: Save Interaction Positions

I think order jumble may be a problem if one is trying to draw triangle strips with the resulting data, but not if each point is "it's own thing". I may be wrong about that triangle strip thing, but it sure seems like it... I'll test. Just mentioning this in case someone tries something with tri-strip or mesh creator and goes "but it was supposed to work" :-)

usefuldesign.au's picture
Re: Save Interaction Positions

If you really want to un-jumble a QC structure object you can do it in JS by iterating though the structure and transposing each item to an element inside an array. Then output the resultant array.

Pretty sure I've post eg comp on a few threads on Kineme. My demo comp folder is too big for me to find it though.

Sidenote: Kineme's Spotlight plugin never really seemed to log Note text inside compositions for me to the extent that I ever get a hit. I tested it with unique strings but wasn't sure if Spotlight needs to comb the HD as part of system maintenance before new results are available. I can't see any way to force a Spotlight update on a Drive/Folder/File either.

jersmi's picture
Re: Save Interaction Positions

ahhh! way too easy! iterator variable index to key member threw me off. thanks, usefuldesign.au.

if you do find that example js for reassigning jumbled structures, it would be great to see it.

gtoledo3's picture
Re: Save Interaction Positions

There is a "Kineme Structure Key", that returns Key value (Data Tools)... it seems like if Current Index was hooked to Index input on that patch, and then the result of that was used to feed the index of a Structure Index Member, that it would sort something into the right order, when using an iterator. Err... I really should test that, but it sure seems like it would work.

edit...hmm, I'm having a hard time generating a structure that gets read out of order to begin with.

usefuldesign.au's picture
Re: Save Interaction Positions

Then look at my demo!

gtoledo3's picture
Re: Save Interaction Positions

Ewwwww! Yeah, that's a pain!

So I see why I don't run into this as much- when you manually set index, things are fine, but generating it for a given count like that seems to screwup because it's always outputting keys that's don't get order.

One could use the kineme key from index connected to current index of iterator vars. I think the number output of that, hooked to structure index, would reorder it all correctly, in an iterator type setup. Kinda should test that, just theorizing....

gtoledo3's picture
Re: Save Interaction Positions

jersmi's picture
Re: Save Interaction Positions

Thanks for posting this with the inertia, voxdeserti. That's nice to see. I haven't explored those tools much.

jersmi's picture
Re: Save Interaction Positions

Why did I think it was a bad idea to put a queue patch inside an iterator? Maybe because I wasn't careful about input/output and would end up with things like 5000 iterations of a 5000 member queue....

jersmi's picture
Re: Save Interaction Positions

Now to the next js challenge here with the interaction inside the iterator patch:

Create the queue order (per iteration) then always keep the same order as structure members change values.

usefuldesign.au's picture
Re: Save Interaction Positions

Yes, arrays make the QC structure indexes and keys the same. Objects give 'jumbled' impression: key is what you set, index is seemingly random. Not sure if random is correct word but there's seemingly no rhyme or reason as to how QC assigns the indexes.