# How to draw practically any poly from verts????

I split a mesh into 2, my object is all over the
place.

What i would like to do is draw a polygon with
all the vertices on the split(-its a flat plane-).
The problem is my vertices doesnt go from point1
to p2,p3 etc,. I have to sort them somehow so
my poly looks correct. I think the problem also
would be with concave polygons.

The way im doing it now:

center 2d vertices around 0,0
calculate arctan
sort by angle

but if its concave im stuffed.

could this be a matter of quad draws vs tri strip draws, as the draw orders differ

i think that gets complicated…

if you want to do a poly af abitrary points, it is the fact that only a convex polygon (“convex hull”) is uniquely defined (and maybe even ignores some interior points)
beside of this, there a many polygons using all of your verticies, and all are different

what you maybe wnat if i guess right is to draw a projection of your existing mesh on a cutting plane which intersects the object? this is hard too…
coukd be done by something called “silhouette extrusion”…

i just did something very similar…

you may have to trawl through a load of references to dog/pig/horse ears, but when you find the right pages it’ll all become very clear.

my bad its a mesh, so your problem is finding the order for the points in the cap for your slice, tricky, if i find a good solution Ill post it.

ok a thought just occurred to me, what if you create a new plane(yz) perpendicular to your slice(xy) plane and sweep it through 360 degrees (normal to the slice plane (z rotation)) measuring when points in your slice transverse from one side to the next, then use this order for drawing your poly.

since you cut through a mesh you just have exisiting data…
your verticies are intersections of the cutting plane with the mesh.
and, second, your EDGES are intersections of the meshes faces with your plane.
So when intersecing a face of your original mesh you not only get your new verticies, but also the information they both are connected. doing that for all your faces gives you many vericies, and of course the information how they are connected. you just need unify all multiple verticies (all equal) and then travel along the known edges from one to another
(eg. take point 0, search container edge, goto the other point of this edge …) after that you’ve iterated the whole conture of your intersection in right order.

any other method just based on the verticies would in fact spoil the original structure of your mash and can only work if the mesh is convex. otherwise there are intersections which are not, and those cannot be ordered by “best guess”, only by traversing the original mesh’s structure to the intersection.
so you CAN use a cheap ordering method as suggested if your mesh is fully convex, or is only cut in fashion that the cuts are convex. than this simple method preforms much faster & more reliably…

hi dronus, my original assumption of the problem from th0r1000 i tweezed out of his explanation, and with this was left thinking his problem lay in just the order of the cap he was trying to create.

to quote th0r1000

“What i would like to do is draw a polygon with all the vertices on the split (-its a flat plane-).
The problem is my vertices doesnt go from point1
to p2,p3 etc,. I have to sort them somehow so
my poly looks correct.”

and coupled with

“calculate arctan
sort by angle”

gave me this impression.

i agree however finding and fixing the breaks in the mesh caused by the cut plane would require iteration through the meshes edges, so i will take a closer look at your solution with interest, as i would like at some point to be able to achieve this myself.

regards