# VEX: add point to prim

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

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

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

Cheers,

• 2

##### Share on other sites

vertex point or ..I just having Fun and learning

POint.hiplc

Edited by Librarian

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

You're welcome

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

• 2

##### Share on other sites

You can add vertices to any edge by converting a polygon to a polyline and then sorting it using Intrinsic UV.

Edited by satoru
• 2

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

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

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

Edited by satoru
Fix hip file.
• 1

## Create an account

Register a new account