public void copyElements(int inIndex, VertexBuffer outVb, int outIndex, int len) {
        if (outVb.format != format || outVb.components != components) {
            throw new IllegalArgumentException("Buffer format mismatch. Cannot copy");
        }

        int inPos = inIndex * components;
        int outPos = outIndex * components;
        int elementSz = components;
        if (format == Format.Half) {
            // because half is stored as ByteBuffer, but it's 2 bytes long
            inPos *= 2;
            outPos *= 2;
            elementSz *= 2;
        }

        // Make sure to grab a read-only copy in case some other
        // thread is also accessing the buffer and messing with its
        // position()
        Buffer srcData = getDataReadOnly();
        outVb.data.clear();

        switch (format) {
            case Byte:
            case UnsignedByte:
            case Half:
                ByteBuffer bin = (ByteBuffer) srcData;
                ByteBuffer bout = (ByteBuffer) outVb.data;
                bin.position(inPos).limit(inPos + elementSz * len);
                bout.position(outPos).limit(outPos + elementSz * len);
                bout.put(bin);
                break;
            case Short:
            case UnsignedShort:
                ShortBuffer sin = (ShortBuffer) srcData;
                ShortBuffer sout = (ShortBuffer) outVb.data;
                sin.position(inPos).limit(inPos + elementSz * len);
                sout.position(outPos).limit(outPos + elementSz * len);
                sout.put(sin);
                break;
            case Int:
            case UnsignedInt:
                IntBuffer iin = (IntBuffer) srcData;
                IntBuffer iout = (IntBuffer) outVb.data;
                iin.position(inPos).limit(inPos + elementSz * len);
                iout.position(outPos).limit(outPos + elementSz * len);
                iout.put(iin);
                break;
            case Float:
                FloatBuffer fin = (FloatBuffer) srcData;
                FloatBuffer fout = (FloatBuffer) outVb.data;
                fin.position(inPos).limit(inPos + elementSz * len);
                fout.position(outPos).limit(outPos + elementSz * len);
                fout.put(fin);
                break;
            default:
                throw new UnsupportedOperationException("Unrecognized buffer format: " + format);
        }

        // Clear the output buffer to rewind it and reset its
        // limit from where we shortened it above.
        outVb.data.clear();
    }
Copies a sequence of elements of data from this <code>VertexBuffer</code>
to the given output VertexBuffer.

@param inIndex The input element index
@param outVb The buffer to copy to
@param outIndex The output element index
@param len The number of elements to copy

@throws IllegalArgumentException If the formats of the buffers do not
match.
jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java