private static FloatBuffer getVertices(ConvexShape convexShape) {
        // Check there is a hull shape to render
        if (convexShape.getUserPointer() == null) {
            // create a hull approximation
            ShapeHull hull = new ShapeHull(convexShape);
            float margin = convexShape.getMargin();
            hull.buildHull(margin);
            convexShape.setUserPointer(hull);
        }

        // Assert state - should have a pointer to a hull (shape) that'll be drawn
        assert convexShape.getUserPointer() != null : "Should have a shape for the userPointer, instead got null";
        ShapeHull hull = (ShapeHull) convexShape.getUserPointer();

        // Assert we actually have a shape to render
        assert hull.numTriangles() > 0 : "Expecting the Hull shape to have triangles";
        int numberOfTriangles = hull.numTriangles();

        // The number of bytes needed is: (floats in a vertex) * (vertices in a triangle) * (# of triangles) * (size of float in bytes)
        final int numberOfFloats = 3 * 3 * numberOfTriangles;
        FloatBuffer vertices = BufferUtils.createFloatBuffer(numberOfFloats); 

        // Force the limit, set the cap - the largest number of floats we will use the buffer for
        vertices.limit(numberOfFloats);

        // Loop variables
        final IntArrayList hullIndices = hull.getIndexPointer();
        final List<Vector3f> hullVertices = hull.getVertexPointer();
        Vector3f vertexA, vertexB, vertexC;
        int index = 0;

        for (int i = 0; i < numberOfTriangles; i++) {
            // Grab the data for this triangle from the hull
            vertexA = hullVertices.get(hullIndices.get(index++));
            vertexB = hullVertices.get(hullIndices.get(index++));
            vertexC = hullVertices.get(hullIndices.get(index++));

            // Put the vertices into the vertex buffer
            vertices.put(vertexA.x).put(vertexA.y).put(vertexA.z);
            vertices.put(vertexB.x).put(vertexB.y).put(vertexB.z);
            vertices.put(vertexC.x).put(vertexC.y).put(vertexC.z);
        }

        vertices.clear();
        return vertices;
    }
Processes the given convex shape to retrieve a correctly ordered FloatBuffer to
 construct the shape from with a TriMesh.

@param convexShape the shape to retrieve the vertices from.
@return the vertices as a FloatBuffer, ordered as Triangles.
jme3-jbullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java