Jump to content

## 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 this post

##### 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 this post

##### Share on other sites

the attached file shoud do the trick.

hth. petz

• 3

#### Share this post

##### 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 this post

##### Share on other sites

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);```

• 1

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

×
• Donations

• Leaderboard