public void extractVertexData(Mesh other) {
        // Determine the number of unique vertices need to
        // be created. Also determine the mappings
        // between old indices to new indices (since we avoid duplicating
        // vertices, this is a map and not an array).
        VertexBuffer oldIdxBuf = getBuffer(Type.Index);
        IndexBuffer indexBuf = getIndexBuffer();
        int numIndices = indexBuf.size();

        IntMap<Integer> oldIndicesToNewIndices = new IntMap<>(numIndices);
        ArrayList<Integer> newIndicesToOldIndices = new ArrayList<>();
        int newIndex = 0;

        for (int i = 0; i < numIndices; i++) {
            int oldIndex = indexBuf.get(i);

            if (!oldIndicesToNewIndices.containsKey(oldIndex)) {
                // this vertex has not been added, so allocate a
                // new index for it and add it to the map
                oldIndicesToNewIndices.put(oldIndex, newIndex);
                newIndicesToOldIndices.add(oldIndex);

                // increment to have the next index
                newIndex++;
            }
        }

        // Number of unique verts to be created now available
        int newNumVerts = newIndicesToOldIndices.size();

        if (newIndex != newNumVerts) {
            throw new AssertionError();
        }

        // Create the new index buffer.
        // Do not overwrite the old one because we might be able to
        // convert from int index buffer to short index buffer
        IndexBuffer newIndexBuf;
        if (newNumVerts >= 65536) {
            newIndexBuf = new IndexIntBuffer(BufferUtils.createIntBuffer(numIndices));
        } else {
            newIndexBuf = new IndexShortBuffer(BufferUtils.createShortBuffer(numIndices));
        }

        for (int i = 0; i < numIndices; i++) {
            // Map the old indices to the new indices
            int oldIndex = indexBuf.get(i);
            newIndex = oldIndicesToNewIndices.get(oldIndex);

            newIndexBuf.put(i, newIndex);
        }

        VertexBuffer newIdxBuf = new VertexBuffer(Type.Index);
        newIdxBuf.setupData(oldIdxBuf.getUsage(),
                oldIdxBuf.getNumComponents(),
                newIndexBuf instanceof IndexIntBuffer ? Format.UnsignedInt : Format.UnsignedShort,
                newIndexBuf.getBuffer());
        clearBuffer(Type.Index);
        setBuffer(newIdxBuf);

        // Now, create the vertex buffers
        SafeArrayList<VertexBuffer> oldVertexData = other.getBufferList();
        for (VertexBuffer oldVb : oldVertexData) {
            if (oldVb.getBufferType() == VertexBuffer.Type.Index) {
                // ignore the index buffer
                continue;
            }

            VertexBuffer newVb = new VertexBuffer(oldVb.getBufferType());
            newVb.setNormalized(oldVb.isNormalized());
            //check for data before copying, some buffers are just empty shells
            //for caching purpose (HW skinning buffers), and will be filled when
            //needed
            if (oldVb.getData() != null) {
                // Create a new vertex buffer with similar configuration, but
                // with the capacity of number of unique vertices
                Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(),
                        oldVb.getNumComponents(), newNumVerts);
                newVb.setupData(oldVb.getUsage(), oldVb.getNumComponents(),
                        oldVb.getFormat(), buffer);

                // Copy the vertex data from the old buffer into the new buffer
                for (int i = 0; i < newNumVerts; i++) {
                    int oldIndex = newIndicesToOldIndices.get(i);

                    // Copy the vertex attribute from the old index
                    // to the new index
                    oldVb.copyElement(oldIndex, newVb, i);
                }
            }

            // Set the buffer on the mesh
            clearBuffer(newVb.getBufferType());
            setBuffer(newVb);
        }

        // Copy max weights per vertex as well
        setMaxNumWeights(other.getMaxNumWeights());

        // The data has been copied over, update information
        updateCounts();
        updateBound();
    }
Extracts the vertex attributes from the given mesh into
this mesh, by using this mesh's {@link #getIndexBuffer() index buffer}
to index into the attributes of the other mesh.
Note that this will also change this mesh's index buffer so that
the references to the vertex data match the new indices.

@param other The mesh to extract the vertex data from
jme3-core/src/main/java/com/jme3/scene/Mesh.java