Jump to content

How to make the pointreplicate follow the shape of the mesh


awie12

Recommended Posts

Why don't you reproject these points onto the mesh ?

First solution, projecting points onto the closest surface : take a Point Wrangle, plug the points on first input and the mesh on the second input, and add the code :

vector pos = minpos(1, @P);

@P = pos;

Otherwise, you can also project each point onto the geometry along the vertical direction using intersect() function, but you will have to write a bit more code, because you need to cast ray upward or downward depending if your points are above or below ground. Just check what intersect returns : if it is -1, then it found no intersection, and you have to cast a ray in the reverse direction ({0,1,0} or {0,-1,0} : up or down).

Edited by StepbyStepVFX
Link to comment
Share on other sites

1 hour ago, StepbyStepVFX said:

Why don't you reproject these points onto the mesh ?

First solution, projecting points onto the closest surface : take a Point Wrangle, plug the points on first input and the mesh on the second input, and add the code :

vector pos = minpos(1, @P);

@P = pos;

Otherwise, you can also project each point onto the geometry along the vertical direction using intersect() function, but you will have to write a bit more code, because you need to cast ray upward or downward depending if your points are above or below ground. Just check what intersect returns : if it is -1, then it found no intersection, and you have to cast a ray in the reverse direction ({0,1,0} or {0,-1,0} : up or down).

THANK YOU SO MUCH StepbyStepVFX i did your first solution and it works.. vector pos = minpos(1, @P); can you explain this to me if thats okay. thanks again

can you help me again to make rotation base on the normal of the mesh thanks

 

 

Edited by awie12
Link to comment
Share on other sites

If you want to learn VEX code, your best friend will be the documentation page of VEX functions in Houdini : https://www.sidefx.com/docs/houdini/vex/functions/minpos.html

I don't know if you are fluent in any programming language (VEX is similar to C), but a function is a piece of code you can call, giving it some parameters, and it returns to you a result. In any language, your data is limited to certain types : in VEX, you will have integers, float, vectors etc. and arrays of above mentionned types. The result of a function is always of one of the types above (this is called the signature of the function).

Reading the doc you see that minpos() returns the closest position from another position on a surface, therefore it returns a data of type "vector" (position is made of three floats, which is a vector). For that it takes at least 2 parameters : the first is the geometry stream you are looking at (0 for geo plugged on the first input of your Point Wrangle, 1 for the second etc.), and the second one is a position in space (a vector). Here we search for the closest surface position of the current point : its position is "@P".

So I just create a local variable called "pos" like position and says it is equal to what the minpos() function returns when I give it the parameters 1 and @P .

I could have declared my variable alone, and then store the result of minpos() function in it, it would have worked the same :

vector pos;

pos = minpos(1,@P);

@P = pos;

Hope that's clear ;-)

 

Edited by StepbyStepVFX
Link to comment
Share on other sites

8 minutes ago, StepbyStepVFX said:

If you want to learn VEX code, your best friend will be the documentation page of VEX functions in Houdini : https://www.sidefx.com/docs/houdini/vex/functions/minpos.html

I don't know if you are fluent in any programming language (VEX is similar to C), but a function is a piece of code you can call, giving it some parameters, and it returns to you a result. In any language, your data is limited to certain types : in VEX, you will have integers, float, vectors etc. and arrays of above mentionned types. The result of a function is always of one of the types above (this is called the signature of the function).

Reading the doc you see that minpos() returns the closest position of another position on a surface, therefore it returns a data of type "vector" (position is made of three floats, which is a vector). For that it takes at least 2 parameters : the first is the geometry stream you are looking at (0 for geo plugged on the first input of your Point Wrangle, 1 for the second etc.), and the second one is a position in space (a vector). Here we search for the closest surface position of the current point : its position is "@P".

So I just create a local variable called "pos" like position and says it is equal to what the minpos() function returns when I give it the parameters 1 and @P .

I could have declared my variable alone, and then store the result of minpos() function in it, it would have worked the same :

vector pos;

pos = minpos(1,@P);

@P = pos;

Hope that's clear ;-)

 

Thanks a lot man. I will read the documents about vex function. have a nice day cheers.

Link to comment
Share on other sites

On 10/15/2019 at 2:06 PM, StepbyStepVFX said:

If you want to learn VEX code, your best friend will be the documentation page of VEX functions in Houdini : https://www.sidefx.com/docs/houdini/vex/functions/minpos.html

I don't know if you are fluent in any programming language (VEX is similar to C), but a function is a piece of code you can call, giving it some parameters, and it returns to you a result. In any language, your data is limited to certain types : in VEX, you will have integers, float, vectors etc. and arrays of above mentionned types. The result of a function is always of one of the types above (this is called the signature of the function).

Reading the doc you see that minpos() returns the closest position from another position on a surface, therefore it returns a data of type "vector" (position is made of three floats, which is a vector). For that it takes at least 2 parameters : the first is the geometry stream you are looking at (0 for geo plugged on the first input of your Point Wrangle, 1 for the second etc.), and the second one is a position in space (a vector). Here we search for the closest surface position of the current point : its position is "@P".

So I just create a local variable called "pos" like position and says it is equal to what the minpos() function returns when I give it the parameters 1 and @P .

I could have declared my variable alone, and then store the result of minpos() function in it, it would have worked the same :

vector pos;

pos = minpos(1,@P);

@P = pos;

Hope that's clear ;-)

 

Hi man can i ask how to make the point faces to the normal of the meshimage.thumb.png.a8034a54292e76ac2cf0c149ffa755d9.png

Edited by awie12
Link to comment
Share on other sites

What do you mean ?

I understand you projected points on a mesh (a terrain probably ?) and now you want the points to inherit the normals from the faces of the mesh on which they landed after projection, correct ? (you probably want to instance tress on these points, and you want them to be oriented with the normal of the terrain ?).

If so, take a point wrangle, plug the points on the first input, put the terrain/mesh (who should have a normal attribute, otherwise it won't work), and write :

int crossprim;

vector crossuv;

int dist = xyzdist(1, @P, crossprim, crossuv);

@N = primuv(1, "N", crossprim, crossuv);

  • Like 1
Link to comment
Share on other sites

17 minutes ago, StepbyStepVFX said:

What do you mean ?

I understand you projected points on a mesh (a terrain probably ?) and now you want the points to inherit the normals from the faces of the mesh on which they landed after projection, correct ? (you probably want to instance tress on these points, and you want them to be oriented with the normal of the terrain ?).

If so, take a point wrangle, plug the points on the first input, put the terrain/mesh (who should have a normal attribute, otherwise it won't work), and write :

int crossprim;

vector crossuv;

int dist = xyzdist(1, @P, crossprim, crossuv);

@N = primuv(1, "N", crossprim, crossuv);

sorry for my bad explanation. yes i want to instance a leaves or trees on the points and oriented them with the normal of the terrain. sorry for the trouble man I am really new to houdini. I uploaded the file can you check if my nodes  are in the right position or somethings missing. thanks a lot

Parking_Leaves2.hip

Camera_TreesV3.abc

Link to comment
Share on other sites

2 hours ago, StepbyStepVFX said:

What do you mean ?

I understand you projected points on a mesh (a terrain probably ?) and now you want the points to inherit the normals from the faces of the mesh on which they landed after projection, correct ? (you probably want to instance tress on these points, and you want them to be oriented with the normal of the terrain ?).

If so, take a point wrangle, plug the points on the first input, put the terrain/mesh (who should have a normal attribute, otherwise it won't work), and write :

int crossprim;

vector crossuv;

int dist = xyzdist(1, @P, crossprim, crossuv);

@N = primuv(1, "N", crossprim, crossuv);

Thanks again Step I already got it. My brain is not working awhile ago haha but now I already got it thank you step cheers.

Edited by awie12
Link to comment
Share on other sites

On 10/17/2019 at 1:08 PM, StepbyStepVFX said:

What do you mean ?

I understand you projected points on a mesh (a terrain probably ?) and now you want the points to inherit the normals from the faces of the mesh on which they landed after projection, correct ? (you probably want to instance tress on these points, and you want them to be oriented with the normal of the terrain ?).

If so, take a point wrangle, plug the points on the first input, put the terrain/mesh (who should have a normal attribute, otherwise it won't work), and write :

int crossprim;

vector crossuv;

int dist = xyzdist(1, @P, crossprim, crossuv);

@N = primuv(1, "N", crossprim, crossuv);

All the powerfull and magic of houdini, few line written to do what other software will do with addon or more hassle, and with less flexibility.

 

If you are confused and intimidate but these vex lines, i could tell you that if you start learning houdini in a proper way from the base, this will look totally natural to you very quickly in fact :)

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