I was playing with a tutorial “How to Stay Procedural in Houdini with VEX”.
https://www.sidefx.com/tutorials/how-to-stay-procedural-in-houdini-with-vex/ [www.sidefx.com]
I decided to try to extrude the polygons that share a center point on each side of the created object.
Essentially, I want to add each polygon that has a center point in common to a group, so I can extrude the group. I can create a group of points that are near a single point.
The key thing I need to figure out is how to use vex to select a polygon.
This is the code from the tutorial. I successfully created a point group, but I need create polygon groups to extrude. Note that I will only create one polygon group for each geometries sides.
float search_radius = ch(“sr”);
string groupname = “circlePoints”;
for(int i=0; i<npoints(1); i++)
{
vector pos = point(1,“P”,i);
int pts = nearpoints(0,pos,search_radius);
float avgDist=0, dist=0;
vector myPos, dir;
foreach(int pt;pts)
{
myPos = point(0,“P”,pt);
dist = distance(pos, myPos);
if(dist<search_radius/2) removevalue(pts, pt);
}
//printf(“%d\n”,len(pts));
foreach(int pt;pts)
{
myPos = point(0,“P”,pt);
dist = distance(pos,myPos);
avgDist += dist;
}
avgDist /= len(pts);
foreach(int pt;pts)
{
myPos = point(0,“P”,pt);
dir = normalize(myPos-pos);
myPos = pos;
myPos += dir*avgDist;
setpointattrib(0,“P”,pt,myPos,“set”);
setpointgroup(0,“circlePts”,pt,1);
}
}
Brad Carvey
Using Vex or Python to select polygons
1558 0 1- bradcarvey
- Member
- 52 posts
- Joined: July 2013
- Offline
-
- Quick Links