Page 1 of 1
Union vertices from fixtures again into polygon
Posted: Mon Dec 16, 2013 12:05 am
by Pawel
Is there a easy way of decompose exported vertices ( per fixture ) back again to orderer vertices of all the body ?
I need to extract body as ONE polygon ( assuming fixtures are connected with edges )
Thanks in advance
Re: Union vertices from fixtures again into polygon
Posted: Mon Dec 16, 2013 5:31 am
by iforce2d
You can set a fixture to be a loop type, which exports as a simple list of vertices with no polygon decomposition interfering with the ordering. To make a loop shape at the same place as an existing polygon you can duplicate the existing polygon and then change the shape type of the duplicate to loop. After loading and obtaining the vertex ordering, you can delete the loop shape if it messes up the behavior of your game.
That's the best option at the moment, and it keeps the ordering of vertices within each fixture. There is no way to make one polygon from all the fixtures on a body, and I'm not sure what you mean by 'fixtures are connected with edges'... it sounds like something that's not possible, but if you could show an example it might help.
If it helps, there is a script that can merge two polygons into one:
viewtopic.php?f=9&t=186
Re: Union vertices from fixtures again into polygon
Posted: Thu Jan 02, 2014 12:09 am
by Pawel
Thanks , i will try this way but it will be hard to polish final effect.
It seems that you have this item already implemented in rube, as outline of fixtures.

- rb.png (26.17 KiB) Viewed 13522 times
basically the main goal is to render shapes created in rube as polygons with not repeatable texture. I have already implemented generalized barycentric coordinates for proper rendering of polygons so this outlined vertices are the last piece

Re: Union vertices from fixtures again into polygon
Posted: Thu Jan 02, 2014 10:37 am
by iforce2d
The method used in RUBE is only a naive implementation, that does not handle all cases (see below), does not calculate any new fixtures, and relies in part on using the OpenGL depth buffer. Even so, it's already over 250 lines of code just for this.

- Selection_121.png (22.77 KiB) Viewed 13516 times
I'm not sure what you mean by "not repeatable texture" and I'm having a hard time visualizing what you're trying to render. Do you have some example to look at?