Showing posts with label surface. Show all posts
Showing posts with label surface. Show all posts

Thursday, 27 October 2022

"shrinkwrap" push faces from one object towards another

More Julian scripting
Use case - an object lying on the floor is not quite touching the surface - so lets pull points of the floor toward the surface. The floor object would go into the first input and the object to "wrap" to goes into the 2nd input. Put this code into a point wrangle -

 i@prim;

v@uvw;

@dist = xyzdist(1, @P, @prim, @uvw);

@bias = fit(@dist, 0, .01, .79, 0);

@P = lerp(@P, primuv(1, "P", @prim, @uvw), @bias);


It might be necessary to play with the "fit" values & ensure the objects are kinda close to each other to begin with! This is good for bodge fixing stuff!


Tuesday, 27 September 2016

Snap surface points to another mesh, based on distance

Eg. When you have a simmed fluid not quite sitting on it's collision surface/ intersecting & you want it to be fixed/better.

Using a Point Vop. Plug in the surface and it's "collider".
Drop down a xyzdist plug that into a primitive normal. Hook up the appropriate inputs, don't for the the "file" input in the primitive normal. Set the max search distance to something sensible (probably a small value)

Plug the resultant "dist" from the xyzdist into a fit range node and promote the max value to the object level. In the destination value, set the min to 1 and the max to 0. Multiply this by the distance to avoid affecting the entire object (the max value will clamp a lot of values to 0 and nullify it)

Plug things into a displace along normal node. Promote the scale value. Finally connect the final P value.

It's worth having a group node with bounding points to check how well it's all worked.