davidyannick Posted March 13, 2019 Share Posted March 13, 2019 (edited) I'm learning procedural modeling, I'm trying to find nearest points from a sphere with this @Cd=0; // point d'origine int origin=chi("Origin"); // Distance séparant les points float distance=ch("Distance"); // nombre de points à retourner int amount=chi("Amount"); int target; // retourne la position du point d'origine vector pos=point(1,"P",origin); printf("pos: %d\n",pos); // stocke les positions des "amount "points à une distance de "distance" int pcloud=pcopen(0,"P",pos,distance,amount); if(pcnumfound(pcloud)>0){ while(pciterate(pcloud)){ // stocke le numéro du point dans target par référence pcimport(pcloud,"point.number",target); setpointattrib(0,"Cd",target,{1,0,0},"set"); } } and the vector pos is always 0,0,0 even if a sphere is plugged in 1 ? I' ve found this example on youtube and it works ? Thanks for your help pcloud.hipnc Edited March 13, 2019 by davidyannick error Quote Link to comment Share on other sites More sharing options...
tmdag Posted March 13, 2019 Share Posted March 13, 2019 (edited) It took me quite a while to understand what is happening there looks like very overcomplicated code for a simple task. vector pos is returning 0 as in code: vector pos=point(1,"P",origin); You are asking for P (position) from input 1 (your sphere) of the point number "origin" which in your case is "115" in hip you sent. Your sphere has only 1 point (number 0). There is no point number "115" therefore it fails and returns {0,0,0}. ps. You don't need to export output to terminal to debug this (using printf), you can just export global variable and have live output of your work in "geometry spreadsheet" @test = pos; SideFX help file is very extensive and worth reading! Better than getting wrong ideas from youtube and potentially inexperienced people Edited March 13, 2019 by tmdag 1 Quote Link to comment Share on other sites More sharing options...
davidyannick Posted March 13, 2019 Author Share Posted March 13, 2019 1 minute ago, tmdag said: It took me quite a while to understand what is happening there looks like very overcomplicated code for a simple task. vector pos is returning 0 as in code: vector pos=point(1,"P",origin); You are asking for P (position) from input 1 (your sphere) of the point number "origin" which in your case is "115" in hip you sent. Your sphere has only 1 point (number 0). There is no point number "115" therefore it fails and returns {0,0,0}. ps. You don't need to export output to terminal to debug this (using printf), you can just export global variable and have live output of your work in "geometry spreadsheet" Shame on me I didn't see it .. Thank you for your help next time I'll pay more attention Quote Link to comment Share on other sites More sharing options...
fsimerey Posted March 13, 2019 Share Posted March 13, 2019 There is a VEX function to find the closest point > https://www.sidefx.com/docs/houdini/vex/functions/nearpoint.html And for a list of the all the closest points in a geometry https://www.sidefx.com/docs/houdini/vex/functions/nearpoints.html 1 Quote Link to comment Share on other sites More sharing options...
davidyannick Posted March 13, 2019 Author Share Posted March 13, 2019 1 hour ago, fsimerey said: There is a VEX function to find the closest point > https://www.sidefx.com/docs/houdini/vex/functions/nearpoint.html And for a list of the all the closest points in a geometry https://www.sidefx.com/docs/houdini/vex/functions/nearpoints.html Thanks 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.