Godot 4.3
i am making a system that allows me to build a mesh out of cubes, and the next step requires me to be able to calculate the volume of a generated ConvexPolyghonShape3d.
i have figured out how to find the volume of an arraymesh, but Mesh.create_convex_shape returns a ConvexPolygonShape3d.
does anyone best know how to get the steps from create_convex_shape to actually calculating volume? is there a better way than what i found? please advise.
Shape3D has method get_debug_mesh() that returns an ArrayMesh and ConvexPolygonShape3D is a Shape3D.
However, you can access 3D points of the ConvexPolygonShape3D from the points-property and isn’t it possible to calculate the volume by using these points?
So perhaps there is no need to convert the convex polygon to ArrayMesh at all?
well, i tried using get_debug_mesh but that seems to lack the faces, which makes it impossible to tell which tris are connected into faces for calculation. i think the points property has the same problem, but i’m not certain. let me check.
after checking, it seems that ConvexPolygonShape3D.get_debug_mesh and ConvexPolyGonShape3d.points never return any faces, and SurfaceTool and MeshDataTool require faces to be pre-added. i dont have anything in the way of knowledge of how to generate faces from edges and vertices, so i’m a little lost.
I think ConcavePolygonShape3D has a method get_faces().
Other than that I ran out of ideas already. There of course is a way to calculate the volume if needed geometry data is available at the beginning but how much own code is needed and how much Godot’s API can help is a different story…