Jump to content

Blend curve towards another curve


Recommended Posts

I have a source curve and I want to move the points of the curve closer towards a goal curve, if the points are outside of a certain distance. That part works already.

 

// Define the second curve input
int curve2 = 1; // Assuming the second curve is the second input (input 1)

// Define distance threshold and move distance
float distanceThreshold = 0.1; // Specify your threshold value
float moveDistance = 0.1; // Specify how far to move the point along the normal

// Initialize variables
int prim;
vector uv;
float minDist;

// Use xyzdist to find the closest point on the second curve
minDist = xyzdist(curve2, @P, prim, uv);

// Get the position of the closest point using the primitive and UV
vector closestPoint = primuv(curve2, "P", prim, uv);

// Store the distance as a new attribute on the current point
f@dist_to_curve = minDist;

// Calculate the normal vector pointing towards the closest point
vector normalDirection = normalize(closestPoint - @P);

// Store the normal direction as a new attribute
v@N = normalDirection;

// Check if the distance exceeds the threshold
if (minDist > distanceThreshold)
{
    // Move the point along the normal direction by a set amount
    @P += normalDirection * (0.02);
}

image.png.5aaf4645c04f0a99faff355aec3ddb1d.png

 

What I want to achieve, however, is to use a set of goal curves that are horizontally stacked and do the following:

1) move the curve points of the first source curve towards the bottom curve of the goal curves.

2) use the result of 1 and copy/move it up horizontally to the same y-coordinates as the next goal curve and use the result of 1 as the new source curve

3) repeat and go upwards until I reach the last of the goal curves

image.png.d323c22affa7933df58883227546335e.png

 

I've attached what I have so far. I'm looking for a way to iterate through all the goal curves and also to make sure that the source curve moves always towards the goal curve on the same horizontal level. The screenshot above shows my current bug - if the distance to another layer is shorter than to the goal curve on the same layer, xyzdist points towards the wrong curve/primitive.

 

 

limit_angle.hipnc

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...