public float unitize()
    {
        assert (vertices != null);

        float maxx, minx, maxy, miny, maxz, minz;
        float cx, cy, cz, w, h, d;
        float scale;

        /*
         * get the max/mins
         */
        maxx = minx = vertices[3 + 0];
        maxy = miny = vertices[3 + 1];
        maxz = minz = vertices[3 + 2];

        for (int i = 1; i <= numvertices; i++)
        {
            if (maxx < vertices[3 * i + 0])
            {
                maxx = vertices[3 * i + 0];
            }
            if (minx > vertices[3 * i + 0])
            {
                minx = vertices[3 * i + 0];
            }

            if (maxy < vertices[3 * i + 1])
            {
                maxy = vertices[3 * i + 1];
            }
            if (miny > vertices[3 * i + 1])
            {
                miny = vertices[3 * i + 1];
            }

            if (maxz < vertices[3 * i + 2])
            {
                maxz = vertices[3 * i + 2];
            }
            if (minz > vertices[3 * i + 2])
            {
                minz = vertices[3 * i + 2];
            }
        }

        /*
         * calculate model width, height, and depth
         */
        w = Math.abs(maxx) + Math.abs(minx);
        h = Math.abs(maxy) + Math.abs(miny);
        d = Math.abs(maxz) + Math.abs(minz);

        /*
         * calculate center of the model
         */
        cx = (maxx + minx) / 2.0f;
        cy = (maxy + miny) / 2.0f;
        cz = (maxz + minz) / 2.0f;

        /*
         * calculate unitizing scale factor
         */
        scale = 2.0f / Math.max(Math.max(w, h), d);

        /*
         * translate around center then scale
         */
        for (int i = 1; i <= numvertices; i++)
        {
            vertices[3 * i + 0] -= cx;
            vertices[3 * i + 1] -= cy;
            vertices[3 * i + 2] -= cz;
            vertices[3 * i + 0] *= scale;
            vertices[3 * i + 1] *= scale;
            vertices[3 * i + 2] *= scale;
        }

        return scale;
    }