Saori Yoshimoto work notes since 2018

Monday, December 3, 2018

[VEX] pcopen vs pcfind function

pcopen
int  pcopen(string filename, string channel, int shaded, ...)
int  pcopen(string filename, string Pchannel, vector P, float radius, int maxpoints, ...)
int  pcopen(string filename, string Pchannel, vector P, string Nchannel, vector N, float radius, int maxpoints, ...)
int  pcopen(int opinput, string Pchannel, vector P, float radius, int maxpoints)

e.g.)
int handle = pcopen(0, 'P', @P, chf('radius'), chi('maxpoints'));
pcclose(handle);
------
pcfind


int [] pcfind(<geometry>geometry, string Pchannel, vector P, float radius, int maxpoints)
int [] pcfind(<geometry>geometry, string ptgroup, string Pchannel, vector P, float radius, int maxpoints)

<geometry>

Alternatively, the argument can be a string specifying a geometry file (for example, a .bgeo) to read from. When running inside Houdini, this can be an op:/path/to/sop reference.

The ptgroup is a point group that limits the points to search. This is a SOP-style group pattern, so can be something like 0-10 or @Cd.x>0.5. A blank string is treated as matching all points.


e.g. 1)

int[] closept = pcfind(filename, "P", P, maxdistance, maxpoints);
P = 0;
foreach (int ptnum; closept)
{
    vector closepos = point(filename, "P", ptnum);
    P += closepos;
}
P /= len(closept);


e.g. 2)

found_leader = pcfind(0, "@fishGP_ID==1", "P", @P, leader_search_radius, chi('max_point'));

if(len(found_leader) != 0 ){
        s@my_leaders_name = attrib(0, "point", "my_leaders_name", found_leader[0]);
        found_leader_P         = detail(0, s@my_leaders_name);
        vector dir                 = found_leader_P - @P;
        v@force                += dir * chf('follow_a_leader_strength');

}else{
        @Cd = {1,0,0};

};

e.g. 3)

int       point, points[];
vector  pos;

pos      = point(1,"P",0);
points  = pcfind(0, "P", pos, chf("distance"), 99999);
   
foreach (point; points){
    setattrib(0, "point", "Cd", point, 0, {1,0,0}, "set");
};