Navneet Arora Posted February 4, 2018 Share Posted February 4, 2018 hey guys, I have various primitives and those have different amount of points on them, for example each one primitive might have 10 points and other might have 20 so it varies like this, Now i want to have an attributes which ranges from 0 to 1 for each primitive just like what we get from curveu attribute in resample node. I know how to do this in for each sop but i want to do this in vex, am somehow not able to get that loop working correctly. I store the array using primpoints to get the points on that primitive and iterate that through a for loop but i am not able to get normalised value ranging from 0 - 1. Can please someone help? Quote Link to comment Share on other sites More sharing options...
toadstorm Posted February 4, 2018 Share Posted February 4, 2018 Check the attached HIP. You can definitely do this in a single primitive wrangle. The VEX looks like this: int pts[] = primpoints(0, @primnum); int npts = len(pts); for(int i=0; i<npts; i++) { // need to explicitly cast i to float // in order to divide integers. float u = (float)i / npts; setpointattrib(0, "u", pts[i], u, "set"); } The tricky bit you might have missed is that you have to explicitly cast your iterator to a float in order to get a float result for u when you're dividing i by npts. foreach_prim_curveu.hip 1 Quote Link to comment Share on other sites More sharing options...
Navneet Arora Posted February 4, 2018 Author Share Posted February 4, 2018 thanks man! that works, i didn't miss that float thing i missed up with setting the attribute i believe. because i did turn that into float but certainly i was not setting up the attribute this way. anyways i really thank you for the help 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.