VEX

Getting min&max vectors from bounds. #

float bd[]=primintrinsic(...,"bounds",...);
vector bbmin=set(bd[::2]);
vector bbmax=set(bd[1::2]);
v@scale=bbmax-bbmin;

In DOP network or a SOP solver we usually don’t have access to the history of the attributes. Here is how you can easily fix this inconvenience.

i[]@_dead_list;

append(@_dead_list, int(@_dead));
if (len(@_dead_list) > 10)
    removeindex(@_dead_list, 0);

Point Cloud #

// Average V
float radius = chf("search_radius");
int maxpts = chi("search_max_pts");

int handle = pcopen(@OpInput2, "P", v@P, radius, maxpts);

// avarage velocity within the radius
vector avg_V = pcfilter(handle, "vel");
v@force += avg_V;

VEX create polygons

// Create four points, each represented by a unique integer ID
int pt1 = addpoint(0, set(1,0,1)); // Top-right corner (x=1, y=0, z=1)
int pt2 = addpoint(0, set(0,0,1)); // Top-left corner  (x=0, y=0, z=1)
int pt3 = addpoint(0, set(0,0,0)); // Bottom-left corner (x=0, y=0, z=0)
int pt4 = addpoint(0, set(1,0,0)); // Bottom-right corner (x=1, y=0, z=0)

// Create an empty polygon primitive (also gets a unique ID)
int prim = addprim(0, "poly");

// Add each point as a vertex to the polygon (connecting them in order)
addvertex(0, prim, pt1); 
addvertex(0, prim, pt2);
addvertex(0, prim, pt3);
addvertex(0, prim, pt4);

even better version

// Define point coordinates in a more organized way
vector pts[] = {
    {1, 0, 1},  // Top-right
    {0, 0, 1},  // Top-left
    {0, 0, 0},  // Bottom-left
    {1, 0, 0}   // Bottom-right
};

// Create points and polygon in a single loop
int prim = addprim(0, "poly");  
for (int i = 0; i < len(pts); i++) {
    int pt = addpoint(0, pts[i]);
    addvertex(0, prim, pt);
}

Scale boxes and control the height using ramp