Hello,
When I have in the editor a polygon fixture and I export the scene to a JSON the polygon is mapped as many triangle Fixtures. Is there a way to prevent this behavior? I work with polygons better than with triangles in my code.
JSON Export polygonfixture to many triangular fixtures
Re: JSON Export polygonfixture to many triangular fixtures
Box2D can only handle polygons up to 8 sides. The exported JSON will automatically generate these, and you can see how the result will turn out in the player view.
Sometimes the polygon decomposition can have problems, if this happens you will see a warning in the message log panel. This can happen if vertices are colinear or extremely close together. You might also be able to avoid the issue by reversing the vertex winding (in the action menu select Fixture->Reverse vertex winding).
For static bodies, maybe you can use a loop type fixture instead of a polygon.
Sometimes the polygon decomposition can have problems, if this happens you will see a warning in the message log panel. This can happen if vertices are colinear or extremely close together. You might also be able to avoid the issue by reversing the vertex winding (in the action menu select Fixture->Reverse vertex winding).
For static bodies, maybe you can use a loop type fixture instead of a polygon.
Re: JSON Export polygonfixture to many triangular fixtures
Ahh didn't know that about Box2d. Then I will stick to triangles to get the stuff printed on the screen. Thanks for the help
Re: JSON Export polygonfixture to many triangular fixtures
I use a quad to triangle converter in collada exporter :
Here is my exporter : https://github.com/gillesboisson/rube-to-collada
Here is the earcut converter : https://github.com/mapbox/earcut
You can code a nodejs / gulp task that can convert it easily.
Here is my exporter : https://github.com/gillesboisson/rube-to-collada
Here is the earcut converter : https://github.com/mapbox/earcut
You can code a nodejs / gulp task that can convert it easily.