Igor 2 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! Share this post Link to post Share on other sites
konstantin magnus 1,188 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 Share this post Link to post Share on other sites
petz 448 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 18 Share this post Link to post Share on other sites
Igor 2 Posted March 20, 2017 Thank you very much Konstantin and Petz! Your method work perfect! Share this post Link to post Share on other sites
patremblay 2 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? Share this post Link to post Share on other sites
konstantin magnus 1,188 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 Share this post Link to post Share on other sites
patremblay 2 Posted August 9, 2018 Thank you, this reminds me to look for simpler solutions first Share this post Link to post Share on other sites
tagosaku 3 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? Share this post Link to post Share on other sites
Librarian 869 Posted April 2, 2020 Hope it Helps. PoI ODforce.hipnc Share this post Link to post Share on other sites
konstantin magnus 1,188 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 3 3 Share this post Link to post Share on other sites
tagosaku 3 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. Share this post Link to post Share on other sites
Noobini 733 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 Share this post Link to post Share on other sites