Jump to content

line animation


sebastienlevieux

Recommended Posts

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

 

test_anim.hiplc

Edited by sebastienlevieux
Link to comment
Share on other sites

// === 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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

test_anim.hiplc 101.3 kB · 1 download

I'm not proud of this :D definitely not the best approach, (especially that it doesn't stop at the end :D) but maybe can give you ideas.

curtain_thingy.hiplc

curtain_thingy.gif.5a01b64c0c335b149b0fb1fff302ef21.gif

  • Like 1
Link to comment
Share on other sites

12 hours ago, sipi said:

I'm not proud of this :D definitely not the best approach, (especially that it doesn't stop at the end :D) but maybe can give you ideas.

curtain_thingy.hiplc 138.55 kB · 2 downloads

curtain_thingy.gif.5a01b64c0c335b149b0fb1fff302ef21.gif

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.image.gif.95d98d54bd8c3e1c1fba1f0de2627d72.gif

Link to comment
Share on other sites

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?

  • Like 1
Link to comment
Share on other sites

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.image.gif.95d98d54bd8c3e1c1fba1f0de2627d72.gif

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.

image.thumb.png.a6f1e9340537e2104aeaa379f8b95fbb.png

Link to comment
Share on other sites

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

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