As Bullet need quite long to create HullCollisionShapes out of normal rendering models, I searched for ways to do the complex part of the calculation before it runs.

So I searchd for implemented algorithms in java tha optimize a pointcloud to a efficient hull and found this one here:

http://www.cs.ubc.ca/~lloyd/java/quickhull3d.html

I wrote a small wrapper for this to use in conjunction with a HullCollisionShape, and it is quite fast, in fact it is way faster than the bullet internal optimisation.

I used it in my testcase for a car chassis

(http://www.dexsoft-games.com/models/viper.html)

prior needed 5 seconds to generate the hullshape,

now its less than 100ms, for no toher ingame difference this is a great result. And I thought others might want to know about this.

If there is any interest/chance that this could get into the contributions/physicutils I would clean it up (add missing methods, docu, port to float for performance as jme only uses float anyway ect) and integrate it a bit more. The license of the used library should be compatible with jme. (see below)

Basically the jar just needs to be put into the buildpath, and then this small snippet:

[java]

/**

*

* @param mesh

* The to calculate the Optimized Shape for

* @param precision

* Sets an explicit distance tolerance for convexity tests. If AUTOMATIC_TOLERANCE (-1) is specified , then the tolerance will be computed automatically from the point data.

*

* @see #getDistanceTolerance

*

* @return

*/

private float[] getOptimizeHullPoints(final Mesh mesh, final float precision) {

final FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);

vertices.rewind();

final int components = mesh.getVertexCount() * 3;

final double[] pointsArray = new double[components];

for (int i = 0; i < components; i += 3) {

pointsArray[i] = vertices.get();

pointsArray[i + 1] = vertices.get();

pointsArray[i + 2] = vertices.get();

}

final QuickHull3D quickHull = new QuickHull3D();

quickHull.setExplicitDistanceTolerance(precision);

quickHull.build(pointsArray);

final double[] output = new double[quickHull.getNumVertices() * 3];

quickHull.getVertices(output);

final float[] floatOutput = new float[output.length];

for (int i = 0; i < floatOutput.length; i++) {

floatOutput[i] = (float) output[i];

}

System.out.println("Reduced from " + mesh.getVertexCount() + " to " + quickHull.getNumVertices());

return floatOutput;

}

[/java]

```
/**
* Copyright John E. Lloyd, 2004. All rights reserved. Permission to use,
* copy, modify and redistribute is granted, provided that this copyright
* notice is retained and the author is given credit whenever appropriate.
*
* This software is distributed "as is", without any warranty, including
* any implied warranty of merchantability or fitness for a particular
* use. The author assumes no responsibility for, and shall not be liable
* for, any special, indirect, or consequential damages, or any damages
* whatsoever, arising out of or in connection with the use of this
* software.
*/
```