PolyExtrude in VEX

   776   8   2
User Avatar
Member
18 posts
Joined: Oct. 2010
Offline
Hi,


I've been wondering if anyone tried to recreate the polyextrude sop in vex? I'm particularly interested in the inset function of the sop, and how one would go about recreating this in vex.


Any ideas?


Thanks in advance.
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
you just need to add points in the direction of a surface's normal, connect the dots and make a surface out of it
User Avatar
Member
519 posts
Joined: Feb. 2016
Offline
following this thread.

I always wanted to try to build one in vex because the original one can't be compiled.
User Avatar
Member
18 posts
Joined: Oct. 2010
Offline
Andr
following this thread.

I always wanted to try to build one in vex because the original one can't be compiled.

That's exactly why I'm asking hehe.

ouroboros1221
you just need to add points in the direction of a surface's normal, connect the dots and make a surface out of it

Thanks for your answer.I guess I'm looking for a bit more specific information on how to do that. Sorry my question wasn't clear enough.
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
Here I made a simple example, it's up to you to figure out how to procedurally organize the points so you don't have to type them in.

Attachments:
vex_extrude_v01.hipnc (81.9 KB)

User Avatar
Member
31 posts
Joined: Aug. 2015
Offline
Simple VEX inset. Run over prims.

vector centerPoint = v@P ;

int pts[] = primpoints(0,@elemnum);
int newPTS[] = {};

//generate inset points
foreach( int pt ; pts )
{

    vector pos = point(0,'P',pt);
    vector insetPos = lerp(pos,centerPoint,ch('inset'));
    
    int newPt = addpoint(0,insetPos);
    append(newPTS,newPt);
    
}

//inset prim
int prCenter = addprim(0,'poly',newPTS);

//contour prims
for(int i=0; i<len(pts); i++)
{

    int pr = addprim(0,'poly');
    addvertex(0,pr,pts[i-1]);
    addvertex(0,pr,pts[i]);
    addvertex(0,pr,newPTS[i]);
    addvertex(0,pr,newPTS[i-1]);

}

//remove original prim
removeprim(0,@elemnum,0);

Ideally you also interpolate point and vertex attributes on the inset points.
User Avatar
Member
18 posts
Joined: Oct. 2010
Offline
ouroboros1221
Here I made a simple example, it's up to you to figure out how to procedurally organize the points so you don't have to type them in.

Thank you. Unfortunately, your file doesn't work properly, geometry is all messed up with open prims flying everywhere. But it's a starting point.

Nicolas Longchamps
Simple VEX inset. Run over prims.

vector centerPoint = v@P ;

int pts[] = primpoints(0,@elemnum);
int newPTS[] = {};

//generate inset points
foreach( int pt ; pts )
{

    vector pos = point(0,'P',pt);
    vector insetPos = lerp(pos,centerPoint,ch('inset'));
    
    int newPt = addpoint(0,insetPos);
    append(newPTS,newPt);
    
}

//inset prim
int prCenter = addprim(0,'poly',newPTS);

//contour prims
for(int i=0; i<len(pts); i++)
{

    int pr = addprim(0,'poly');
    addvertex(0,pr,pts[i-1]);
    addvertex(0,pr,pts[i]);
    addvertex(0,pr,newPTS[i]);
    addvertex(0,pr,newPTS[i-1]);

}

//remove original prim
removeprim(0,@elemnum,0);

Ideally you also interpolate point and vertex attributes on the inset points.

Thank you for your example. Simple indeed but very interesting.
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
Here I got it fixed. If anyone figured out how to procedurally connect those points, please let me know.

Attachments:
vex_extrude_v02.hipnc (91.0 KB)

User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
v@extrude_distance = @N * chf("distance");
int @pts[];
int @ptsOnPrim[];



    @ptsOnPrim = primpoints(0,chi("selection"));

    foreach(int pt; @ptsOnPrim)
    {
       
       
            vector pos = point(0,"P",pt);
            i@point = addpoint(0, pos + v@extrude_distance);
            append(@pts,@point);
            
             
            
            
        
       
   
      
       //setpointattrib(0,"pts",@primnum,@pts,"set");
    }


int i = 0; int j =0;
addprim(0,"poly",@pts[i+2],@pts[i+1],@pts[i],@pts[i+3]);
addprim(0,"poly",@ptsOnPrim[j+1],@ptsOnPrim[j],@pts[i],@pts[i+1]);    
addprim(0,"poly",@ptsOnPrim[j],@pts[i],@pts[i+3],@ptsOnPrim[j+3]);
addprim(0,"poly",@ptsOnPrim[j+1],@pts[i+1],@pts[i+2],@ptsOnPrim[j+2]);
addprim(0,"poly",@ptsOnPrim[j+2],@pts[i+2],@pts[i+3],@ptsOnPrim[j+3]);

if(@primnum==chi("selection"))
{
    removeprim(0,@primnum,1);
}
    
    
    

        

only works with a grid and it has duplicated primitives, waiting for some more advanced user to improve the code
  • Quick Links