Jump to content

How to snap an object to another precedurally?


Recommended Posts

Say I have a cone and a sphere:

61cfb42659b7e_Screenshot2022-01-01092845.png.55ab5bd506ab9367d8036348f5c7aabf.png

I'd like to snap the cone to the closest point on the sphere, along the direction {0, -1, 0}. Like this:

61cfb43e30102_Screenshot2022-01-01092857.png.0ea681f44d426423d322df0d847d84a5.png

I know Ray SOP, but it snaps every point to the sphere:

61cfb4461fa0a_Screenshot2022-01-01092911.thumb.png.e2f57147ca619ac3eb35fa5463b8a627.png

I'd like to keep the cone as a cone. Is there a node to do this procedurally?
Link to comment
Share on other sites

21 hours ago, konstantin magnus said:

Add a point underneath, ray and match its position.

match_ray_top.hiplc

Thank you!

But I'd like to know how to make it more generic. For example when the ray I cast doesn't align with the world axes (e.g. {0.811, 0.32, 0.48}). I'm trying to make something just like Ray but only ray the closest point, and translate the rest of the geo accordingly. Is it possible?

Edited by raincole
Link to comment
Share on other sites

Here are some ideas.

  • calculate the closest distance to geo for all points and calculate attributes (closest point on target geo or ray projected point, Normal optionally ...)
  • find best point (closest point)
  • add the target point of the best point (add attributes if needed)
  • substract closest point (source) to move object to center (reorient optionally using the direction to center point of the object and up vector the point with highest y-value for example)
  • move geo to target point (reorient geo optionally using N,up) 

snap_closest_point.hipnc

  • Thanks 1
Link to comment
Share on other sites

Compute N and  up for the destination surface, i.e on its points; somehow create the destination point on the surface - it could be a ray, scatter, attribute transfer - anything that interpolates N and up

Create your object with the part you want facing the object towards Z, then put a Match Size: Justify Z: min, the other Justify value depends on your geometry, make sure the tip of your object is on the origin.

Then copy to points SOP.

 

ctp.png

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