Jump to content

VEX: add point to prim


csp

Recommended Posts

Hello, 

lets say I have a prim with 3 points and I want to add an new point on that prim, by splitting one of the 3 edges. I assume that the prim will have to be deleted and drawn again but what I am wondering how to get the correct order with the new point so the prim will close properly. 

Link to comment
Share on other sites

I assume that a triangle has always the same order, so if you add a point between point 0 and 1, just offset the point number after point 1.

Let's say you have a triangle, this should work :

int pts  = primpoints(0, @primnum);
removeprim(0, @primnum, 0);

vector pos1 = point(0, "P", pts[0]);
vector pos2 = point(0, "P", pts[1]);
vector new_pos = avg(pos1, pos2);

int new_pt = addpoint(geoself(), new_pos);

addprim(geoself(), "poly", pts[0], new_pt, pts[1], pts[2]);

 

Cheers,

  • Thanks 2
Link to comment
Share on other sites

Hey Romain, I would not assume the point order is always the same, I need something more precrural.

I think makes sense to explain the bigger picture here. I have a model with some UVs and I want to remesh it for vellum but  the UVs will be destroyed on the seams if I will do it once for the entire geometry.

There are technics to improve a lot the UVs but the seams will never be perfect if I don't have the same edges on these areas.

So I thought to remesh per UV connectivity in a for loop and transfer there the UVs, which gives me perfect seams of course but I need to fuse all the pieces after the loop and I don't get the same resolution on the seams unfortunately. It is close enough but not exactly.  So I have some vex lines to detect if a point at the seams of a pieces does not have a point on the same location in the near by piece and add that point. This thread is regarding my next step to make this new point part of the target prim. 

Maybe is an overkill and maybe will not be enough but thanks for the hip Tesan. 

Link to comment
Share on other sites

Hi,

here is another version: With VEX you can insert your point into the point array of a primitive and rebuild the primitive with the new point.

  • choose a primitive, a point and an index
  • get the point array of the primitive and insert the new point to the position given by the index
  • rebuild the primitive with the new pointarray and remove the old primitive

 

insert_point.hipnc

  • Thanks 2
Link to comment
Share on other sites

@satoru your solution is very close the desired result but with more complicated geometry the sorting method based on u is not working unfortunately, you can see that in your example by increasing the count at the scatter.

Link to comment
Share on other sites

On 2020/10/8 at 8:22 PM, csp said:

@satoru your solution is very close the desired result but with more complicated geometry the sorting method based on u is not working unfortunately, you can see that in your example by increasing the count at the scatter.

@csp

Indeed.
I've made it even more robust. But this may not be perfect yet.

addvertex_v2.hiplc

Edited by satoru
Fix hip file.
  • Thanks 1
Link to comment
Share on other sites

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