Jump to content

Edge divide in vex?


TomRaynor

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
Link to comment
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.

Link to comment
Share on other sites

  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...