private void gatherIndexData(Mesh mesh, List<Vertex> vertexLookup) {
        VertexBuffer indexBuffer = mesh.getBuffer(VertexBuffer.Type.Index);
        indexCount = indexBuffer.getNumElements() * 3;
        Buffer b = indexBuffer.getDataReadOnly();
        b.rewind();
        
        while (b.remaining() != 0) {
            Triangle tri = new Triangle();
            tri.isRemoved = false;
            triangleList.add(tri);            
            for (int i = 0; i < 3; i++) {
                if (b instanceof IntBuffer) {
                    tri.vertexId[i] = ((IntBuffer) b).get();
                } else {
                    //bit shift to avoid negative values due to conversion form short to int.
                    //we need an unsigned int here.
                    tri.vertexId[i] = ((ShortBuffer) b).get()& 0xffff;
                }
               // assert (tri.vertexId[i] < vertexLookup.size());
                tri.vertex[i] = vertexLookup.get(tri.vertexId[i]);
                //debug only;
                tri.vertex[i].index = tri.vertexId[i];
            }
            if (tri.isMalformed()) {
                if (!tri.isRemoved) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "malformed triangle found with ID:{0}\n{1} It will be excluded from LOD calculations.", new Object[]{triangleList.indexOf(tri), tri.toString()});
                    }
                    tri.isRemoved = true;
                    indexCount -= 3;
                }
                
            } else {
                tri.computeNormal();
                addTriangleToEdges(tri);
            }
        }
        b.rewind();
    }
Constructs an LodGenerator for the given Geometry.

@param geom the geometry for which to generate LODs.
jme3-core/src/tools/java/jme3tools/optimize/LodGenerator.java