Jump to content

nearest pt num


Recommended Posts

I'm using Houdini 15, and i'm following CmiVfx Connections tutorial, chapter 4 where you create sphere and grid and a vop sop wich is suposse to tell which point from the sphere is closest to which point on the grid. I know things changed with the latest H release, and i thought i kind of a figured it out, but all i get is constant number and it's not point number that is closest to anything. I'va attached the file, if anyone can look inside and tell me what i'm missing?

nearestPTNUM.hip

Link to comment
Share on other sites

thank you so much Bunker! :D so easy.. still got a loooot to learn. :)

and how about other attributes like distance between 2 points, normals, position, color, alpha? can it all be done in attribute wrangle node or is this suposse to be done in pc import?

Link to comment
Share on other sites

getting attributes is easy, now that you have the point number, you can use the "point" function:

 

int closestpoint = nearpoint(1,@P);
v@Cd=point(1,"Cd",closestpoint);

 

or in just one line:
v@Cd=point(1,"Cd",nearpoint(1,@P));

 

using pointclouds you can limit the search radius:

 

float radius = 1;
int maxpoints = 1;
int handle = pcopen(1,"P",@P,radius,maxpoints);
// import Cd from first point from second input
@Cd = pcimportbyidxv(handle,"Cd",0);

 

you'll have to replace pcimportbyidxv if the attribute is a float for example: pcimportbyidxf

 

or in one line:

@Cd = pcimportbyidxv(pcopen(1,"P",@P,1,1),"Cd",0);

 

getting the distance is easy:

vector P2 = pcimportbyidxv(pcopen(1,"P",@P,1,1),"P",0);

float dist = distance(@P,P2);

  • Like 1
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...