List of usage examples for java.nio ShortBuffer put
public ShortBuffer put(short[] src, int off, int len)
From source file:Main.java
public static void main(String[] args) { ShortBuffer bb = ShortBuffer.allocate(10); bb.put(new short[] { 100, 123, 123, 123, 1 }, 0, 1); System.out.println(bb.toString()); }
From source file:com.google.android.apps.body.LayersLoader.java
private static ShortBuffer decodeIndexBuffer(DrawGroup drawGroup, char[] data, int start, int length) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(length * 2); byteBuffer.order(ByteOrder.nativeOrder()); ShortBuffer indexData = byteBuffer.asShortBuffer(); int prev = 0; for (int i = 0; i < length;) { int limit = Math.min(length - i, BUFSIZE); int s = start + i; for (int j = 0; j < limit; ++j) { int word = data[s + j]; prev += (word >> 1) ^ (-(word & 1)); mBuffer[j] = (short) prev; }/*from w w w. ja v a2 s . co m*/ i += limit; indexData.put(mBuffer, 0, limit); } indexData.rewind(); return indexData; }
From source file:com.google.android.apps.body.LayersLoader.java
private static ShortBuffer decodeVertexBuffer(DrawGroup drawGroup, char[] data, int start, int length) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(length * 2); byteBuffer.order(ByteOrder.nativeOrder()); ShortBuffer vertexData = byteBuffer.asShortBuffer(); short prev0 = 0, prev1 = 0, prev2 = 0, prev3 = 0; short prev4 = 0, prev5 = 0, prev6 = 0, prev7 = 0; for (int i = 0; i < length;) { int limit = Math.min(length - i, BUFSIZE); int s = start + i; for (int j = 0; j < limit;) { short word = (short) data[s + j]; prev0 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) (prev0 - 8192); word = (short) data[s + j]; prev1 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) (prev1 - 4096); word = (short) data[s + j]; prev2 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) (prev2 - 8192); word = (short) data[s + j]; prev3 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) ((prev3 - 256) << 7); word = (short) data[s + j]; prev4 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) ((prev4 - 256) << 7); word = (short) data[s + j]; prev5 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) ((prev5 - 256) << 7); word = (short) data[s + j]; prev6 += (word >> 1) ^ (-(word & 1)); mBuffer[j++] = (short) prev6; word = (short) data[s + j]; prev7 += (word >> 1) ^ (-(word & 1)); // The web version flips the tex images instead. mBuffer[j++] = (short) (512 - prev7); }/*ww w.j ava2s . co m*/ i += limit; vertexData.put(mBuffer, 0, limit); } vertexData.rewind(); return vertexData; }