@Override
    protected void controlRender(RenderManager rm, ViewPort vp) {
        BoundingVolume bv = spatial.getWorldBound();

        Camera cam = vp.getCamera();
        float atanNH = FastMath.atan(cam.getFrustumNear() * cam.getFrustumTop());
        float ratio = (FastMath.PI / (8f * atanNH));
        float newDistance = bv.distanceTo(vp.getCamera().getLocation()) / ratio;
        int level;

        if (Math.abs(newDistance - lastDistance) <= distTolerance) {
            level = lastLevel; // we haven't moved relative to the model, send the old measurement back.
        } else if (lastDistance > newDistance && lastLevel == 0) {
            level = lastLevel; // we're already at the lowest setting and we just got closer to the model, no need to keep trying.
        } else if (lastDistance < newDistance && lastLevel == numLevels - 1) {
            level = lastLevel; // we're already at the highest setting and we just got further from the model, no need to keep trying.
        } else {
            lastDistance = newDistance;

            // estimate area of polygon via bounding volume
            float area = AreaUtils.calcScreenArea(bv, lastDistance, cam.getWidth());
            float trisToDraw = area * trisPerPixel;
            level = numLevels - 1;
            for (int i = numLevels; --i >= 0;) {
                if (trisToDraw - numTris[i] < 0) {
                    break;
                }
                level = i;
            }
            lastLevel = level;
        }

        spatial.setLodLevel(level);
    }
Sets the triangles per pixel value. The
<code>LodControl</code> will use this value as an error metric to
determine which LOD level to use based on the geometry's area on the
screen.

@param trisPerPixel triangles per pixel
jme3-core/src/main/java/com/jme3/scene/control/LodControl.java