Jump to content
TomRaynor

Edge divide in vex?

Recommended Posts

i thought about this recently, as well. i am probably boring you, but basically cutting a polygon in two is nothing different than redrawing two polygons and deleting the old one.

 

in a four-sided polygon this would mean to create two new points inbetween existing points, and drawing vertices while creating prims. i don't know how to access specific point positions in vex, but at least some functions in my example might be useful.

// CALCULATE AVERAGE POSITIONS

vector avpos_0 = ((point_0 + point_1) /2);
vector avpos_1 = ((point_2 + point_3) /2);


// CREATE INBETWEEN POINTS

int pt_4 = addpoint(geoself(), set(avpos_0));
int pt_5 = addpoint(geoself(), set(avpos_1));

// CREATE FIRST PRIMITIVE

int prim1 = addprim(geoself(), "poly");

addvertex(geoself(), prim1, point_0);
addvertex(geoself(), prim1, pt_4);
addvertex(geoself(), prim1, pt_5);
addvertex(geoself(), prim1, point_3);


// CREATE SECOND PRIMITIVE

int prim2 = addprim(geoself(), "poly");

addvertex(geoself(), prim2, pt_4);
addvertex(geoself(), prim2, point_1);
addvertex(geoself(), prim2, point_2);
addvertex(geoself(), prim2, pt_5);



// DELETE ORIGINAL PRIM

removeprim(int geoself(), prim0, int andpoints); 

post-10570-0-88354200-1415659222_thumb.p

Edited by konstantin magnus

Share this post


Link to post
Share on other sites

Yes, it gets more complicated quickly. For example, splitting a polygon that has a shared edge with one (or more) other polygons. Then you also have to consider the case where you want attributes interpolated along the edges into the new points.

Share this post


Link to post
Share on other sites

Does this mean we won't see this feature in VEX? It does seem a lot of work to do it by hand each time. Houdini can already do this in the HDK, right?

Share this post


Link to post
Share on other sites

Yes, it can of course be done in the HDK but I don't think that was the original question.

  • Like 1

Share this post


Link to post
Share on other sites

Yes, it can of course be done in the HDK but I don't think that was the original question.

Thanks Edward. I mentioned that because if it's in the hdk, you guys can expose this function to VEX saving us the trouble of doing it manually.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×