Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Igor

Make Curve In VEX

How can I make curve in VEX? In Documentation I found spline function but I do not understand how to use. I would like to make smooth blend-curve between many lines.

Thanks!

Share this post


Link to post
Share on other sites

Put all point positions into an array and make parameter "t" slide e.g. from 0 to 1 inside a for loop.

int steps = chi('steps');
vector all_points[];
resize(all_points, npoints(0));

for (int i = 0; i < npoints(0); i++){
    all_points[i] = point(0, "P", i);
}

int prim = addprim(0, "polyline");

for(int i = 0; i < steps; i++){
    float slide = i / float(steps - 1);
    vector pos = spline("catrom", slide, all_points);
    int inter_pt = addpoint(0, pos);
    addvertex(0, prim, inter_pt);   
}

Also a simple function for interpolating 4 points to a curve by yourself would be:

int steps = chi('steps');

vector pt0 = point(0, "P", 0);
vector pt1 = point(0, "P", 1);
vector pt2 = point(0, "P", 2);
vector pt3 = point(0, "P", 3);

int prim = addprim(0, "polyline");

for(int i = 0; i < steps; i++) {

    float slide = i / float(steps - 1);
    vector pos0 = lerp(pt0, pt1, slide);
    vector pos1 = lerp(pt2, pt3, slide);
    vector ipol = lerp(pos0, pos1, slide);

    int inter_pt = addpoint(0, ipol);
    addvertex(0, prim, inter_pt);
}

 

VEX_spline.hipnc

Edited by konstantin magnus
5 people like this

Share this post


Link to post
Share on other sites

 

On 17.3.2017 at 0:18 AM, Igor said:

I would like to make smooth blend-curve between many lines

 

please take a look at the attached file. it´s an example how you could create bezier curves with arbitrary degree and another one relying on beziers in hermite form since you wrote about blending curves...

petz

curves_vex.hipnc

6 people like this

Share this post


Link to post
Share on other sites

Thank you very much Konstantin and Petz! Your method work perfect!

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now