Jump to content
Sign in to follow this  
cermmid

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

Share this post


Link to post
Share on other sites

in a attrib wrangle:

i@closestpoint = nearpoint(1,@P);

  • Like 1

Share this post


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

Share this post


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

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  

×