Android FloatBuffer Copy copyInternalVector3(final FloatBuffer buf, final int fromPos, final int toPos)

Here you can find the source of copyInternalVector3(final FloatBuffer buf, final int fromPos, final int toPos)

Description

Copies a Vector3 from one position in the buffer to another.

Parameter

Parameter Description
buf the buffer to copy from/to
fromPos the index of the vector to copy
toPos the index to copy the vector to

Declaration

public static void copyInternalVector3(final FloatBuffer buf,
        final int fromPos, final int toPos) 

Method Source Code

//package com.java2s;

import java.nio.FloatBuffer;

public class Main {
    /**/*from   w ww.  j  a va  2 s  .c o m*/
     * Copies a Vector3 from one position in the buffer to another. The index values are in terms of vector number (eg,
     * vector number 0 is positions 0-2 in the FloatBuffer.)
     * 
     * @param buf
     *            the buffer to copy from/to
     * @param fromPos
     *            the index of the vector to copy
     * @param toPos
     *            the index to copy the vector to
     */
    public static void copyInternalVector3(final FloatBuffer buf,
            final int fromPos, final int toPos) {
        copyInternal(buf, fromPos * 3, toPos * 3, 3);
    }

    /**
     * Copies floats from one position in the buffer to another.
     * 
     * @param buf
     *            the buffer to copy from/to
     * @param fromPos
     *            the starting point to copy from
     * @param toPos
     *            the starting point to copy to
     * @param length
     *            the number of floats to copy
     */
    public static void copyInternal(final FloatBuffer buf,
            final int fromPos, final int toPos, final int length) {
        final float[] data = new float[length];
        buf.position(fromPos);
        buf.get(data);
        buf.position(toPos);
        buf.put(data);
    }
}

Related

  1. copyFloatBuffer(FloatBuffer paramFloatBuffer)
  2. copyInternal(final FloatBuffer buf, final int fromPos, final int toPos, final int length)