Jump to content
Sign in to follow this  
michael

Find closest point?

Recommended Posts

I asked about something like this in the character section and while MCronin refered me to a thread I don't think it's really what I'm after...

in the attached file there is:

a curve and an add

the curve goes into a group then into a point

the add just has a transform

what I'd like is to find an expression to use in the group sop that finds the closest point on the curve and then feeds that into the point sop which will move it based on the position of the add's xform

I've looked at pointdist() and xyzdist() but they'll only return a primitive# and not the point#...

hoop_02_test.hipnc

Share this post


Link to post
Share on other sites

Try the nearpoint() expression.

In the textport "exhelp nearpoint". Or you could read up on it in the expression reference....oh wait...its not in there. :rolleyes:

jim.

Share this post


Link to post
Share on other sites

Or, you could hack something with the Ray SOP set to Minimum Distance.

Share this post


Link to post
Share on other sites

thanks guys,

I'll look into it in the morning

Share this post


Link to post
Share on other sites

nearpoint works really well....at least when I toggle the expression it seems to be returning the nearest point....but now the group sop claims there are 9 points in the group - all the points in the curve... :blink:

in the above hip file I'm using:

nearpoint("/obj/geo1/curve1", ch("/obj/geo1/xform1/tx"), ch("/obj/geo1/xform1/ty"), ch("/obj/geo1/xform1/tz"))

Share this post


Link to post
Share on other sites

just wanted to bump this back into the land of the living...

I really don't understand why the expression in the group1 works (gives the right point #) but when I MMB on the group it says that there are 9 points in the group > there should just be one > from the nearpoint() expression.

hoop_04_post.hipnc

Share this post


Link to post
Share on other sites

there is also xyzdist()

ill get a small sample up when i get the chance

Share this post


Link to post
Share on other sites

thanks!

I think xyzdist() will only return the primitive #, not the point #

Share this post


Link to post
Share on other sites

I took a look at your hipfile. You are using the filter expression with the nearpoint expression. Your nearpoint expression returns the number 2. So the expression will always be true. What houdini does in the filter expression is effectively 2=2 which is always true for every point of your geometry. So all the points will be in your group. You need to use a condition. So $PT==nearpoint(blablabla) is what you're after.

Also, you don't need to use a transform sop and reference that. You can use the add just like you started, click on a point, fill in the coordinates and reference those channels. Copy the channels and look on your clipboard for the actual name. (Expand the horizontal bar just above your parameters). It's just neater like that.

DRie.s

Share this post


Link to post
Share on other sites
thanks!

I think xyzdist() will only return the primitive #, not the point #

yah you will create a couple attributes, it is using the variable you created as a result of xyzdist() ...primuv() is getting the point nfo. ill do a small sample which will make more sense :)

Share this post


Link to post
Share on other sites

well I'm still stuck on this...

using the conditional works really well (thanks again Dries) to find the closest point, but now i can't figure out how to get a smoother deformation in the curve and how to prevent it 'snapping' when a new CV is selected...

I think I've gone about this the wrong way but I don't really know how else to do it....

here is the file with comments

hoop_05.hipnc

Share this post


Link to post
Share on other sites

If you want such a smooth deformation, the attempt of grouping the point with minimal distance is the wrong way. A global approach is better. You would need to add a custom point-attribute on the curve, which stores a weight for deformation. This is based on the distance of each point to the reference-position from the xform1-SOP and the smooth-expression. This weight can then be used to pull the vertices of the curve.

But this is rather compicated and here is another proposal:

Use a metaball and the magnet-SOP to deform the curve. You can control the size and weight of the metaball in order to achieve a good deformation.

Take a look at the hip-file attached.

hoop.zip

Share this post


Link to post
Share on other sites

thanks Frank...

th first method I tried used a metaball...but it didn't really work the way I wanted, your solution looks much better....

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  

×