Jump to content

Loops (repeat, ping pong...etc.)


mstarktv

Recommended Posts

I am kind of stuck on how to use loops alongside of VEX...or even at all. I'm posting my example file, but what I'm trying to achieve is just to have a function repeat - and if possible in different ways. In my file, it's a line and I'm making the scale of the point equal 1, if the ptnum and Frame are equal. My problem is repeating it.

I tried using the solver sop, but it did as expected and just compounded the spheres scale to equal 0. I'm not really sure where to go from here :wacko:

Any help is always appreciated! 

loop.hipnc

Link to comment
Share on other sites

Unfortunately, that isn't it. That is scaling it by it's @ptnum.

Right now I have:

Quote

if(@ptnum==@Frame)
{
    @pscale = 1;
}
else
{
    @pscale = 0;
}

Which works. Basically, I'm trying to loop the action. I'm not trying to scale it by the point number. More or less I'm using this as a visual aid to help with implementing loops into vex.


 

Link to comment
Share on other sites

Modulo (%) is usually the way to loop things. It's similar to when you first learn how to divide, and calculate the remainder, modulo just gives you the remainder.

 

So if you do....

   float t = @Frame % 5;'

...t will be

    0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 

 

So if you need a longer loop, change '5' to some other number, and if you want the loop to be faster or slower, change the @Frame or @Time input, eg:

  float t = (@Time * ch('speed)) % ch('loop_length');

 

 

 

  • Like 1
Link to comment
Share on other sites

Just now, mestela said:

Modulo (%) is usually the way to loop things. It's similar to when you first learn how to divide, and calculate the remainder, modulo just gives you the remainder.

 

So if you do....

   float t = @Frame % 5;'

...t will be

    1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

 

So if you need a longer loop, change '5' to some other number, and if you want the loop to be faster or slower, change the @Frame or @Time input, eg:

  float t = (@Time * ch('speed)) % ch('loop_length');

 

 

 

Perfect! Coincidentally, I always scour your site before posting here. Also...off topic, looking forward to your Houdini Class thing. Thanks again, Matt!

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...