### PolyExtrude in VEX

773   8   2
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?

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
Member
519 posts
Joined: Feb. 2016
Offline

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

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.
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)

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'));

append(newPTS,newPt);

}

//inset prim

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

}

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

Ideally you also interpolate point and vertex attributes on the inset points.
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'));

append(newPTS,newPt);

}

//inset prim

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

}

//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.
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)

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;

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