Union vertices from fixtures again into polygon

General discussion about the R.U.B.E editor
Post Reply
Pawel
Posts: 4
Joined: Mon Nov 18, 2013 10:25 am

Union vertices from fixtures again into polygon

Post 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
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Union vertices from fixtures again into polygon

Post 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
Pawel
Posts: 4
Joined: Mon Nov 18, 2013 10:25 am

Re: Union vertices from fixtures again into polygon

Post 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
rb.png (26.17 KiB) Viewed 7780 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 :)
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Union vertices from fixtures again into polygon

Post 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
Selection_121.png (22.77 KiB) Viewed 7774 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?
Post Reply