Jump to content

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

Link to comment
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"))

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
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 :)

Link to comment
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

Link to comment
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

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