More draw functions for convex shapes (DEF-2067)

#1

Maybe a draw polygon, and then you specify the number of sides and the radius? Then you also specify to fill or only be outlines. This would help with testing and prototyping. It’s a feature which other engines have better support of, and porting projects to Defold would be helped by adding it.

msg.post("@render:", "draw_polygon", { position = vmath.vector3(200, 200, 0), sides = 3, radius = 42, style = 0, rotation = 0, scale = 1 } ) 
-- draw a triangle with , 0 for outline only no fill

msg.post("@render:", "draw_convex_shape", { position = vmath.vector3(200, 200, 0), points = { ... }, style = 0, rotation = 0, scale = 1 } ) 
-- draw a convex hull, position would be based on the center of mass
1 Like

#2

Hmm, I wonder what would be the best way of achieving something like this? I’m not sure that adding more functions to complement the draw_line and draw_text messages is a good way to go about it. @sven and @Ragnar_Svensson, is this something that has been discussed?

0 Likes

#3

How are the shapes drawn for 2d physics debug?

0 Likes

#4

Not sure. @sven?

0 Likes

#5

The physics debug graphics are drawn by c++ code, i.e. pretty much hardcoded. I think it would make sense to have something very simplistic supported by default (draw_box, draw_sphere) and then a future extension for more complex things like arbitrary polygons.

5 Likes

#6

Added an issue for this feature request; DEF-2067

2 Likes

#7

Hey! Any updates?

0 Likes

#8

I’m afraid not.
Note that these functions are really just for debug features too.
As we do more work on our 3D support though, we’ll need to add support for new vertex formats, and I think at that point we’ll be able to provide a better methods to achieve this.

2 Likes