tamagochy Posted February 1, 2017 Share Posted February 1, 2017 Hi, I have a curve with points. I need animation like this: First point start moving and when it reaches of the position of the next point both points start moving and the same with next. I remember that i already saw solution, but i cant find it. Thanks for helping! Quote Link to comment Share on other sites More sharing options...
acey195 Posted February 1, 2017 Share Posted February 1, 2017 The easiest solution would probably be using a "Carve" SOP, although you could write your own solution in an attrib wrangle, if you really want to keep all the points. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 1, 2017 Share Posted February 1, 2017 If you referring to this topic, solution was for vertical lines. Here is more general way: // Point wrangle. float u = (float) @ptnum / (@numpt-1.0); float time = @Time; if (u <= time) { @P = primuv(0, "P", 0, time); } drag_by_u.hipnc 1 Quote Link to comment Share on other sites More sharing options...
acey195 Posted February 1, 2017 Share Posted February 1, 2017 Slight improvement to the code (if you have multiple primitives ): // Point wrangle. (works with multiple primitives) int linVert = pointvertex(0, @ptnum); int pr = vertexprim(0, linVert); float u = (float) vertexprimindex(0, linVert) / (primvertexcount(0, pr) - 1.0); float time = @Time; if (u <= time) { @P = primuv(0, "P", pr, time); } Also, if you want the movement to be linear, so the point moves with the same speed regardless of edge length, you can go more complex, like: //Primitive wrangle int pts[], i, j; float segLens[], progress, segProgress; vector ps[]; pts = primpoints(0, @primnum); resize(ps, @numvtx); resize(segLens, @numvtx -1); for(i = 0; i < @numvtx; i++) ps[i] = point(0, "P", pts[i]); for(i = 0; i < (@numvtx - 1); i++) segLens[i] = distance(ps[i], ps[i + 1]); progress = @Time * 1000; segProgress = 0; i = 0; while(segProgress < progress && i < (@numvtx-1)) { segProgress += segLens[i]; i++; } progress = fit(progress, max(segProgress - segLens[i-1], 0), segProgress, 0, 1); for(j = 0; j < i; j++) setpointattrib(0, "P", pts[j], lerp(ps[i-1], ps[i], progress)); 2 Quote Link to comment Share on other sites More sharing options...
tamagochy Posted February 2, 2017 Author Share Posted February 2, 2017 18 hours ago, f1480187 said: If you referring to this topic, solution was for vertical lines. Here is more general way: // Point wrangle. float u = (float) @ptnum / (@numpt-1.0); float time = @Time; if (u <= time) { @P = primuv(0, "P", 0, time); } drag_by_u.hipnc If i need that points have gap between? Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 2, 2017 Share Posted February 2, 2017 @tamagochy, try offset time by rising value. float time = @Time + (u * 0.01); 1 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.