Page 1 of 1

Volume of btConvexHullShape

Posted: Wed Nov 19, 2014 8:37 am
by Geometrian
I need to calculate the volume of a "btConvexHullShape" (more accurately, I need to compute a mass, but I'll do this through a density).

Short of implementing my own convex hull algorithm, what should I do?

I considered making a temporary "btConvexTriangleMeshShape" and then using its "calculatePrincipalAxisTransform" method, but this seems semi-crufty. If there's no better option, I'll try it.

Re: Volume of btConvexHullShape

Posted: Wed Nov 19, 2014 9:42 am
by Flix
I'm probably not enough "geometry-expert" to answer this. Anyways:

What I'd do:
1) using btConvexHullComputer to compute vertices/triangle indices from the btConvexHullShape (*).
2) after that, you can use for example Stan Melax's code here http://www.melax.com/volint (I'm not sure, but I AFAIR it should work for every manifold mesh (convex or not)).

I don't know if there's a faster way of doing it, specialized for convex meshes (maybe operating on the convex plane equations directly). Are you doing it every frame?
Geometrian wrote:I considered making a temporary "btConvexTriangleMeshShape" and then using its "calculatePrincipalAxisTransform" method, but this seems semi-crufty. If there's no better option, I'll try it.
I don't understand that... btConvexHullComputer should be enough.

However, as I've aready told you, I'm not an expert of topology/geometry and maybe there's something I'm missing.

(*) You can probably use generatePolyhedralFeatures(), btConvexPolyhedron(), [or something like that] directly on your btConvexHullShape to get the convex faces.

Re: Volume of btConvexHullShape

Posted: Wed Nov 19, 2014 10:19 am
by c6burns
There's an example of doing exactly what Flix has suggested in VoronoiFractureDemo::voronoiBBShatter