Jump to content
Sign in to follow this  

How to snap an object to another precedurally?

Recommended Posts

Say I have a cone and a sphere:


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


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


I'd like to keep the cone as a cone. Is there a node to do this procedurally?

Share this post

Link to post
Share on other sites
Posted (edited)
21 hours ago, konstantin magnus said:

Add a point underneath, ray and match its position.


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

Share this post

Link to post
Share on other sites

Hi rain,

isolate the closest point and apply its offset vector to all other points. 

vector pos = point(1, 'P', 0);
vector rest = point(1, 'rest', 0);
vector delta = pos - rest;
v@P += delta;



Share this post

Link to post
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) 


  • Thanks 1

Share this post

Link to post
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.



Share this post

Link to post
Share on other sites

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
Sign in to follow this