Fitting a mesh between curves / Bilinear interpolation?

Recommended Posts

I am trying to fit a 2d mesh between 4 curves. Pretty much what the skin SOP does but potentially with a custom mesh.

```vector bbox = relbbox(0, v@P);

function vector blerp(vector a, b, c, d; float x, y){
vector lr = a * (1.0 - x) + b * (x);
vector tb = c * (1.0 - y) + d * (y);
return 0.5 * (lr + tb);
}

vector p0 = primuv(1, 'P', 0, bbox.z);
vector p1 = primuv(1, 'P', 1, bbox.x);
vector p2 = primuv(1, 'P', 2, bbox.z);
vector p3 = primuv(1, 'P', 3, bbox.x);

v@P = blerp(p0, p2, p1, p3, bbox.x, bbox.z);```

How can I smoothly interpolate the point positions so the borders actually touch the curves?

blerp.hiplc

Share on other sites

Hi,

here is an approach using linear blend for profile curves and transforming them onto the rail curves.

Edited by Aizatulin
Share on other sites

the attached file shoud do the trick.

hth. petz

Share on other sites

Thank you @petz! I can see myself creating procedural cars with this!

* once I have found an elegant way to shape the guide curves and solved a bunch of other problems ; )

Edited by konstantin magnus
Share on other sites

• 5 months later...

Broken down into more comprehensible steps:

```vector uv = relbbox(0, v@P);

vector crv_0 = primuv(1, 'P', 0, uv.z);
vector crv_1 = primuv(1, 'P', 1, uv.x);
vector crv_2 = primuv(1, 'P', 2, uv.z);
vector crv_3 = primuv(1, 'P', 3, uv.x);

vector start_0 = primuv(1, 'P', 0, 0);
vector start_2 = primuv(1, 'P', 2, 0);
vector end_0   = primuv(1, 'P', 0, 1);
vector end_2   = primuv(1, 'P', 2, 1);

vector ipol = lerp(crv_0, crv_2, uv.x);
ipol       += lerp(crv_1, crv_3, uv.z);

vector fit_0 = lerp(start_0, end_0, uv.z);
vector fit_2 = lerp(start_2, end_2, uv.z);

v@P = ipol - lerp(fit_0, fit_2, uv.x);```

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×