Crisis Posted May 16, 2018 Share Posted May 16, 2018 Hi. Probably this is trivial but i don't know how to deal with this in Vex in very optimal way. I have problem with shifting values in Vex. For example I have a line with points from 0 - 100. Points have Cd from point 0 - 0 in Cd.r to 100 - 1 in Cd.r. How to shift this values about custom value? ( If last value is shifted then must go to the begining of my list of points ). I can do this in loop by checking last value and storing it in temporary parameter , but this is not a very optimal way. I'm searching for function but I don't see any. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted May 16, 2018 Share Posted May 16, 2018 Try the modulo operator: http://www.sidefx.com/docs/houdini/vex/lang.html#operators 1 Quote Link to comment Share on other sites More sharing options...
probiner Posted May 16, 2018 Share Posted May 16, 2018 (edited) Modulo indeed a way to go and worth to learn about. Here's some pieces to help with a VEX setup: vertexprimindex() gives you the index on a primitive and primvertexcount() gives you max amount. Modulo the first with the second while adding an offset value to the first and you got your carrousel. Or... you can just shift the points with Sort SOP and read the value from the point with the same newly aquired index. Scene PRB_ShiftAttrib.hiplc Another example of a setup using Modulo. If confused check the initial explanation. Cheers Edited May 16, 2018 by probiner Quote Link to comment Share on other sites More sharing options...
Crisis Posted May 16, 2018 Author Share Posted May 16, 2018 (edited) Thanks. I probably do it wrong but I cant figure out how to do it by modulo operator. I used sawtooth function. Not to hard to fit this function in range. Still simple code, but maybe some novice as I, will feel this is a usefull. float amplitude = chf("amplitude"); // sawtooth - function with offset about an amplitude. - Begining at 0 and rising up. With animation. @P.y =((-2 * amplitude)/3.14) * atan(1/tan((@Cd.r + @Time * -0.5 * 3.14)/chf("period"))) + amplitude; Yes i like to complicate everything. But this make so fun even if I don't have to much free time. Edited May 16, 2018 by Crisis Quote Link to comment Share on other sites More sharing options...
Crisis Posted May 16, 2018 Author Share Posted May 16, 2018 Sort sop. That is it. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.