sebastienlevieux Posted Friday at 06:33 PM Share Posted Friday at 06:33 PM (edited) Hello guys, I tried to create an animation with a curve based on this draw, point moves sequentially toward the next one, like a folding curtain that retracts point by point. Each point can only move once the previous one has reached its position, and they must never overlap... here is my file.. if you can take a look or if you have any idea for something better Image: point 1 goes to point 2, then point 1 and 2 go toward point 3....etc...Thanks for helping. test_anim.hiplc Edited Friday at 08:11 PM by sebastienlevieux Quote Link to comment Share on other sites More sharing options...
Librarian Posted Friday at 06:46 PM Share Posted Friday at 06:46 PM // === Parameters === float speed = chf("speed"); int start_frame = chi("start_frame"); // === Custom smoothstep function (renamed!) float my_smoothstep(float edge0, edge1, x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); } // === Point setup === int pt = @ptnum; int frame = int(@Frame); int offset = pt * 3; int local_frame = frame - start_frame - offset; if (local_frame < 0) { @P = point(0, "P", pt); return; } // === Start/end positions from two input curves vector start_pos = point(0, "P", pt); vector target_pos = point(1, "P", pt); // === Interpolation logic float dist = distance(start_pos, target_pos); float travel = speed * float(local_frame); float ratio = clamp(travel / dist, 0.0, 1.0); ratio = my_smoothstep(0.0, 1.0, ratio); // === Apply animated position @P = lerp(start_pos, target_pos, ratio); @sebastienlevieux Quote Link to comment Share on other sites More sharing options...
sebastienlevieux Posted Friday at 06:48 PM Author Share Posted Friday at 06:48 PM 1 minute ago, Librarian said: // === Parameters === float speed = chf("speed"); int start_frame = chi("start_frame"); // === Custom smoothstep function (renamed!) float my_smoothstep(float edge0, edge1, x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); } // === Point setup === int pt = @ptnum; int frame = int(@Frame); int offset = pt * 3; int local_frame = frame - start_frame - offset; if (local_frame < 0) { @P = point(0, "P", pt); return; } // === Start/end positions from two input curves vector start_pos = point(0, "P", pt); vector target_pos = point(1, "P", pt); // === Interpolation logic float dist = distance(start_pos, target_pos); float travel = speed * float(local_frame); float ratio = clamp(travel / dist, 0.0, 1.0); ratio = my_smoothstep(0.0, 1.0, ratio); // === Apply animated position @P = lerp(start_pos, target_pos, ratio); @sebastienlevieux Thank you, do you have any explanation? Quote Link to comment Share on other sites More sharing options...
sipi Posted Friday at 09:58 PM Share Posted Friday at 09:58 PM 3 hours ago, Librarian said: // === Parameters === float speed = chf("speed"); int start_frame = chi("start_frame"); // === Custom smoothstep function (renamed!) float my_smoothstep(float edge0, edge1, x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); } // === Point setup === int pt = @ptnum; int frame = int(@Frame); int offset = pt * 3; int local_frame = frame - start_frame - offset; if (local_frame < 0) { @P = point(0, "P", pt); return; } // === Start/end positions from two input curves vector start_pos = point(0, "P", pt); vector target_pos = point(1, "P", pt); // === Interpolation logic float dist = distance(start_pos, target_pos); float travel = speed * float(local_frame); float ratio = clamp(travel / dist, 0.0, 1.0); ratio = my_smoothstep(0.0, 1.0, ratio); // === Apply animated position @P = lerp(start_pos, target_pos, ratio); @sebastienlevieux For some reason it feels like this was chatGPT. Quote Link to comment Share on other sites More sharing options...
sipi Posted Friday at 11:10 PM Share Posted Friday at 11:10 PM 4 hours ago, sebastienlevieux said: Hello guys, I tried to create an animation with a curve based on this draw, point moves sequentially toward the next one, like a folding curtain that retracts point by point. Each point can only move once the previous one has reached its position, and they must never overlap... here is my file.. if you can take a look or if you have any idea for something better Image: point 1 goes to point 2, then point 1 and 2 go toward point 3....etc...Thanks for helping. test_anim.hiplc 101.3 kB · 1 download I'm not proud of this definitely not the best approach, (especially that it doesn't stop at the end ) but maybe can give you ideas. curtain_thingy.hiplc 1 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted yesterday at 08:16 AM Share Posted yesterday at 08:16 AM Here are some ideas using this on curves (if I understood correctly) shift_points_along_curve.hipnc 3 Quote Link to comment Share on other sites More sharing options...
sebastienlevieux Posted yesterday at 11:51 AM Author Share Posted yesterday at 11:51 AM 12 hours ago, sipi said: I'm not proud of this definitely not the best approach, (especially that it doesn't stop at the end ) but maybe can give you ideas. curtain_thingy.hiplc 138.55 kB · 2 downloads Thanks for your setup, it looks great! But I’m not seeing the same behavior on my end, in my screenshot, the points are overlapping, which doesn’t happen in your video. Quote Link to comment Share on other sites More sharing options...
sebastienlevieux Posted yesterday at 11:53 AM Author Share Posted yesterday at 11:53 AM 3 hours ago, Aizatulin said: Here are some ideas using this on curves (if I understood correctly) shift_points_along_curve.hipnc 201.31 kB · 2 downloads It is cool! I will explore how you solve it, your setup is completly different than mine, your setup is totally different from mine. Could you explain a bit about your workflow? 1 Quote Link to comment Share on other sites More sharing options...
sipi Posted yesterday at 11:55 AM Share Posted yesterday at 11:55 AM 2 minutes ago, sebastienlevieux said: Thanks for your setup, it looks great! But I’m not seeing the same behavior on my end, in my screenshot, the points are overlapping, which doesn’t happen in your video. Ah sorry, play with this parameter, set it for example -0.1. (i must have changed it after the gif making accidentally) But i want to emphasize that this method is not the best overall. Quote Link to comment Share on other sites More sharing options...
sebastienlevieux Posted yesterday at 12:00 PM Author Share Posted yesterday at 12:00 PM 4 minutes ago, sipi said: Ah sorry, play with this parameter, set it for example -0.1. (i must have changed it after the gif making accidentally) But i want to emphasize that this method is not the best overall. But it work fine! Thank you for sharing your setup. Quote Link to comment Share on other sites More sharing options...
sipi Posted yesterday at 12:02 PM Share Posted yesterday at 12:02 PM Just now, sebastienlevieux said: But it work fine! Thank you for sharing your setup. Yeah, but only works on straigth line @Aizatulin's file is awesome! 2 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted 9 hours ago Share Posted 9 hours ago 19 hours ago, sebastienlevieux said: It is cool! I will explore how you solve it, your setup is completly different than mine, your setup is totally different from mine. Could you explain a bit about your workflow? Sure :-) Each point has a position on a curve (called u, which is between 0.0 and 1.0). If you want to move the point, you change this u-value (by input parameter) and read the point again from the curve function (called primuv). If the first point has the position 0.0 and the second point has 0.25, you can move the first point until it reaches 0.25 (but 0.25 is already too much, so you substract a small value for example 0.01). So if the first point reaches 0.24 you start to move the second point (now you are adding the offset 0.01 again, that this point starts from 0.25 (if you input is 0.24)). If you have another (third point), you have substract 0.01 twice because you already have two moving points, so if this point starts from 0.5, it will start if your input u reaches 0.48 (position of the first point and the second point has position 0.49). In fact you can accumulate over different distances along the points just adding all distances from all points before. This method won't work, if the points are too close together, compared to defined distance. If you have smooth curve with a few points you can use a guide curve (with many points) to move the points smoothly just capturing the points on the smooth curve (using xyzdist). For a straight line it doesn't matter you can just use the same curve as guide curve. shift_points_along_curve_mod.hipnc 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.