Jump to content

Stepping Point move


Recommended Posts

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!

Link to comment
Share on other sites

Slight improvement to the code (if you have multiple primitives :P ):

// 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));

 

  • Like 2
Link to comment
Share on other sites

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?

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