awie12 Posted October 15, 2019 Share Posted October 15, 2019 Hi guys I need help to make the points follow the shape of a mesh or position of the mesh. thanks in advance Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted October 15, 2019 Share Posted October 15, 2019 (edited) 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 October 15, 2019 by StepbyStepVFX Quote Link to comment Share on other sites More sharing options...
awie12 Posted October 15, 2019 Author Share Posted October 15, 2019 (edited) 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 October 15, 2019 by awie12 Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted October 15, 2019 Share Posted October 15, 2019 (edited) 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 October 15, 2019 by StepbyStepVFX Quote Link to comment Share on other sites More sharing options...
awie12 Posted October 15, 2019 Author Share Posted October 15, 2019 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. Quote Link to comment Share on other sites More sharing options...
awie12 Posted October 17, 2019 Author Share Posted October 17, 2019 (edited) 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 mesh Edited October 17, 2019 by awie12 Quote Link to comment Share on other sites More sharing options...
StepbyStepVFX Posted October 17, 2019 Share Posted October 17, 2019 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); 1 Quote Link to comment Share on other sites More sharing options...
awie12 Posted October 17, 2019 Author Share Posted October 17, 2019 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 Quote Link to comment Share on other sites More sharing options...
awie12 Posted October 17, 2019 Author Share Posted October 17, 2019 (edited) 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 October 17, 2019 by awie12 Quote Link to comment Share on other sites More sharing options...
vinyvince Posted October 21, 2019 Share Posted October 21, 2019 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.