Jump to content

FOREACH frame - sample attrib and gather... [SOLVED]


Recommended Posts

To start off...aparrently, FOREACH and SOLVER don't work well together...

 

I had a perfectly working system I only tested on a point that did a lot of crazy stuff, but it started like this :

- I have an attribute SINE

- SOLVER SOP - merge input with previous, then after the solver, timeshift end - so now I have 1 point per each frame with the attribute's value at that frame

- etc etc processing

 

It all rested on having the initial sampling for each frame of the Sine attribute above in individual points at frame 1.

Now, all said and done, the system worked and all was nice and easy - time to apply this to multiple points.

 

So FOREACH, include the above system inside (points, merge result) - and... fail. 

After many searches around here and in the help - apparently SOP SOLVER inside a FOREACH doesn't play nice at all. Or simply doesn't play.

My system kinda rests on "plotting" the said SINE attribute through the whole timeline with smth else that a solver now...

 

- I thought of bringing the attribute in a CHOP, then reading it back, but I haven't figured that one out, or if it would work.

- I tried delete-copyStamping the initial points, but that doesn't seem to do it either

 

So at the moment I am trying to process this initial point with the attribute through a wrangle node, using the CHF function - that can get a channel's value@frame X.

So per point, I am reading the current point's attribute in a spare parameter to have it in a channel, then using the code bellow, cloning the point per frame, and storing the channel's value at that frame in the point - but for some reason this fails miserably as well... :(

CHF seem to be reading a different value per frame and writing it, but side by side, not the same value.

 

float @test;
for (int i=1; i<=100; i++)
    {
    int pt = addpoint(geoself(), i);
    setpointattrib(pt, "test", i , chf("attrib",i));
    }

 

 

Scene attached.

Thanks for your help.

sampleAttribute.hip

Edited by cojoMan
Link to comment
Share on other sites

I never used the `chf` function in VEX and have no idea of how it works nor what are its pitfalls but it somehow feels a bit hacky to (indirectly) retrieve attributes this way. There's anyways simpler ways to do this, I believe.

 

In the attached scene you will find 2 methods to “plot” the sine attribute onto your 100 points—one relying on a simple combination of `ForEach` and `TimeShift` node, which seems the most intuitive of the 2, and the other one using CHOPs since you mentioned it.

 

sampleAttribute-Edit.hipnc

Link to comment
Share on other sites

I really didn't know WHAT to search for to plot via chops, but so happy I found out HOW :D (chopci ? never heard of it before...)

and I could beat myself over the head for the oh so obvious foreach+timeshift drill.

 

thanks a lot Chris !

Link to comment
Share on other sites

chf() in VEX is not the same as ch() in expression language

 

in VEX

 

ch() is asking for a generic parameter

chf() is asking for a float parameter

chi() is asking for an int parameter

chs() is asking for a string parameter

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...