vesaw55345 Posted January 11 Share Posted January 11 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); } 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 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 1 Quote Link to comment Share on other sites More sharing options...
fencer Posted January 11 Share Posted January 11 Foreach should help. limit_angle_v02.hipnc 2 Quote Link to comment Share on other sites More sharing options...
vesaw55345 Posted January 12 Author Share Posted January 12 Thanks, that's great. I had to change the method in the "Block Begin" to "Fetch Feedback" instead of "Fetch Input" for it to work as expected. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.