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.
Volume of btConvexHullShape
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Volume of btConvexHullShape
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?
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.
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?
I don't understand that... btConvexHullComputer should be enough.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.
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.
-
- Posts: 149
- Joined: Fri May 24, 2013 6:08 am
Re: Volume of btConvexHullShape
There's an example of doing exactly what Flix has suggested in VoronoiFractureDemo::voronoiBBShatter