Can someone explain how convexhull works in 3D space. So let’s say I have a 4 sided die and an 8 sided die. How can I create a convexhull to be that shape?
I need a collsionobject to match my die, and I can’t find an easy to understand explanation of how this will work in 3D. I understand the 2D version, but I can’t wrap my head around how to do it in 3D space.
It’s very simple. It is a set of vertices in space that create a convex shape. Literally. There are no triangles or lines here. The order is not important. Duplicates or randomly internal vertices do not affect anything, except for the extra volume of data.
To get a cube it is enough to have a set of XYZ vertices in any order:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
To build 4-sided dice (pyramid?) or 8-sided dice, you should, for example, find a 3D model in OBJ and look at the coordinates of the vertices, because I can’t imagine in my head what coordinates are there.
this.
The physics engine will build the planes itself and check for intersection with other entities. But this has a side effect: convexhull shape is not visible in the editor and debug drawing in runtime does not work correctly.
Absolutely right. Yes, the debug rendering of Defold draws 3D physics it’s like a set of lines in order, probably since that’s how the debug rendering of 2D physics works.
Well I’m stuck. I can’t see any debug lines at all. ANd clearly these dice aren’t working correctly. Where as my 6 sided dice are perfect. But I used a box collsionobject so it was easier. Can anyone give me a clue?
Thank for helping but this didn’t change much (see video). Also I’m not sure how would a box shape work for a tetrahedron when I need the dice to be able to lay flat on one of the sides. That is an honest question…I really don’t undestand these convexhulls in 3D especially when I can’t even see the outline of it in defold.
It would probably make sense to include a set of convex hulls in builtins, for instance a tetrahedron, cone and so on. And the collada files should have gltf counterparts as well. Anyone wanna make a contribution?
@britzl I fixed it! I can’t believe what the issue is. It was my gravity scale. Very odd that it behaves fine with the builtin collisionshapes but the convexhull would make it go wild. Anyway, resetting this value to the default appears to have fixed the issue.
Having said that it would be very nice to get more debug info out of convexhull shapes, so we can see what is going on.