Igor Posted March 16, 2017 Share Posted March 16, 2017 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! Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 17, 2017 Share Posted March 17, 2017 (edited) 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 March 17, 2017 by konstantin magnus 7 Quote Link to comment Share on other sites More sharing options...
Popular Post petz Posted March 19, 2017 Popular Post Share Posted March 19, 2017 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 20 Quote Link to comment Share on other sites More sharing options...
Igor Posted March 20, 2017 Author Share Posted March 20, 2017 Thank you very much Konstantin and Petz! Your method work perfect! Quote Link to comment Share on other sites More sharing options...
patremblay Posted August 9, 2018 Share Posted August 9, 2018 Konstantin would it be possible from your setup to include the first and last points as well and also smoothly close the curve? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted August 9, 2018 Share Posted August 9, 2018 (edited) 2 hours ago, patremblay said: include the first and last points as well and also smoothly close the curve? I dont think the spline()-function does this for cubic splines. You can read about it here: http://www.sidefx.com/docs/houdini/vex/functions/spline.html But you could connect points to a curve and close it with an add-node and resample this to an 'interpolating curve' or a 'subdivision curve'. spline.hipnc Edited August 9, 2018 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
patremblay Posted August 9, 2018 Share Posted August 9, 2018 Thank you, this reminds me to look for simpler solutions first Quote Link to comment Share on other sites More sharing options...
tagosaku Posted April 2, 2020 Share Posted April 2, 2020 Hi, I have an additional question, related to this thread. There are random existing curves, for instance. When applying a resample node, it adds points evenly. However, I am looking for a way to add points exponentially then add points with even distance. Is that possible to do it procedurally? Quote Link to comment Share on other sites More sharing options...
Librarian Posted April 2, 2020 Share Posted April 2, 2020 Hope it Helps. PoI ODforce.hipnc Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 2, 2020 Share Posted April 2, 2020 (edited) Hi @tagosaku, you can shift points by sampling positions from their respective curves with a channel ramp: float u = vertexprimindex(0, i@vtxnum) / float(primvertexcount(0, i@primnum) - 1); v@P = primuv(0, 'P', i@primnum, chramp('shift', u)); curve_density.hipnc Edited April 3, 2020 by konstantin magnus 4 3 Quote Link to comment Share on other sites More sharing options...
tagosaku Posted April 3, 2020 Share Posted April 3, 2020 Thank you so much, Konstatin M ! That's very smart and primuv seems to be very powerful. I can proceed my stuff from there. Tesan, thanks, too. I will use it for different cases in future, too. Quote Link to comment Share on other sites More sharing options...
Noobini Posted April 3, 2020 Share Posted April 3, 2020 On 4/3/2020 at 6:29 AM, konstantin magnus said: Hi @tagosaku, you can shift points by sampling positions from their respective curves with a channel ramp: float u = vertexprimindex(0, i@vtxnum) / float(primvertexcount(0, i@primnum)); v@P = primuv(0, 'P', i@primnum, chramp('shift', u)); curve_density.hipnc well this trumps my curveu bias HDA royally !!! 1 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.