Drawing polygons on a table?

So i decided to start testing with physics and tables, and this is what i got so far:


Drawing circles was fine, but i have no idea how i would paint polygons?

Hello @MarcosCapistrano. Please can you edit your comment to start and end your code sample with ~~~ (tilde) ‘fences’ (see here for advice on formatting in the forums). It will make it easier for others to read.

On drawing filled polygons, perhaps this would work:

  1. Use built-in function triangulate(points) to decompose the polygon into triangles.

  2. Use built-in userdata mesh to render triangles.

On drawing the boundary of polygons, look at the example project ‘Physics Lab’ (under PhysicsDebugDraw:draw() and if body.shapeType == POLYGON) for an example algorithm.


(formatting done)