Main photo Nearestpoints function

Nearestpoints function

  • By Admin
  • 1769 views
int origin = chi("source");// set a slider to pick a point number called origin (set to 0 for sphere
vector pos = point(1,"P",origin); //second input 1 is the sphere 
//find the position of sphere plugged into 
//second socket (only one point on sphere prim so origin mkust be 0)

float distance = ch("Distance"); //create distance value box

int targets[] = nearpoints(0,pos,distance);// set up an array of nearest points to pos 

foreach(int pt; targets)
{
    setpointattrib(0,"Cd", pt,1,"set");
}    


Or use pcopen to open a point cloudoud

int origin = chi("source");  // slider for point origin (set to 0 when using sphere)

float distance = ch("dist"); //slider for float distance

int amount = chi ("amounts");// slider for amount

int target;

vector pos = point(1,"P",origin);// set origin to 0 and input to 1 for the sphere input again

int pcloud = pcopen(0, "P", pos, distance, amount);// open a point cloud 
// for input 0  and the position of "P" distance to search and the amount of points to capture

if (pcnumfound(pcloud)>0)// if any are found do this 
{
        while(pciterate(pcloud) ) //for each memeber of the point cloud
        {
                pcimport(pcloud, "point.number", target);// import the date from the pclound 
                //(note this is a string because it is a channel name) of the number of the point being process into target
                setpointattrib(0, "Cd", target, 1, "set");//make them red
        }
}
f@far = pcfarthest(pcloud);//creates a detail in spreadsheet for the farther point in point cloud. 

pc iterate and pcimport can only be used when pcopen has been initiated


Posted in Vex

Recommended publications