# Polygon box2d and convex shapes

Hi, i was trying to create some convex shapes mainly from typospread to use with box2d, i’m having a lot of difficulties to make it work and in particular i don’t understand if the created shapes can be convex and what does it mean that the “polygon must be counter clockwise ordered”.
I have attached the sample patch i am using for my initial tests, i am creating a working convex shape and a shape from the typospread that instead does not work.
What is the best approach for this situation? What am i missing?
Thanks

PS
Test done using 45b29

polygon box2d.v4p (32.2 kB)

box2d can handle convex shapes only.
nevertheless you can “glue” together multiple
convex shapes to make a concave one.
you would call it a compound shape in box2d terms.

since most letters are concave or have even holes in them
you will not be able to create them as one polygon shape,
so raw typospread is not a good shape provider for box2d.

to achieve letters you must find a way to
divide them first into convex counterclockwise polygons.

please see attached patch for more visual explain
(also on ccw order).

polygon box2d-0.v4p (81.5 kB)

Thank you so much for your explanation, now it is very clear. I didn’t know about the meaning (and existence) of the CreateShape (Box2d) node, so thanks for sharing and for creating that sample patch.

Do you have some tips about what could be the next steps towards an automatic segmentation and ordering of casual shapes in more simple convex shapes?

glad it helped. but i have no tips on segmentation.
just for inspiration: http://www.cs.cmu.edu/~quake/triangle.delaunay.html

ok tgd thanks for your reference, i will look into that!

you know delaunay-(2d) ?

but the delaunay will triangulate all points it finds, regardless the shape. how can i tell it to give me just the indices for the letter shape and forget the room between? or how to filter out not wanted indices sets?

delaunay-letter.v4p (7.6 kB)