Jump to content

Point Replication Procedural Help

Recommended Posts

I was wondering if there's a way to replicate points along a spline/curve through cvex?


I know that you can replicate points along an line by storing the normal direction of the line and the distance and then multiplying by a random number to generate the replicated points but is there an way to do this same effect using a curved line?


Link to comment
Share on other sites

you can create any sort of pattern you want.  the trick is figuring out how to define that pattern in terms of point attributes and then how to code the cvex to use them.


this is off the top of my head and it's late... so....


bezier curves are not very hard.  you'll need to set up some vectors on your points first, tho.  create tangent vectors on each point (these are the bezier "handles").  the tangent vector for P1 would be P2-P0 for a smooth curve, i think.  so once those are all defined on your geometry, you'll need to include the next point's P and tangents for the current point.  the end result will be each point will have 4 vectors: P, tangent, P_next, tangent_next.


your cvex code then just needs to pick a random u value (0-1).

P_next = P_next - tangent_next;

Pa = P + tangent * u;

Pb = lerp(P+tangent, P_next, u);

Pc = P_next + tangent_next * u;


Pd = lerp(Pa,Pb,u);

Pe = lerp(Pb,Pc,u);


P = lerp(Pd,Pe,u);



wow, hopefully i haven't completely mangled that.



also, you'll need to pick a good multplier based on the distance of your line segment.

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.

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