Package java.nio

Examples of java.nio.FloatBuffer.position()


   * @param strideInBytes The offset between the first and the second vector to transform
   * @param count The number of vectors to transform
   * @param matrix The matrix to multiply the vector with */
  public static void transform (Buffer data, int dimensions, int strideInBytes, int count, Matrix4 matrix) {
    FloatBuffer buffer = asFloatBuffer(data);
    final int pos = buffer.position();
    int idx = pos;
    float[] arr = asFloatArray(buffer);
    int stride = strideInBytes / 4;
    float[] m = matrix.val;
    for (int i = 0; i < count; i++) {
View Full Code Here


        if (dimensions >= 4)
          arr[idx+3] = x * m[ 3] + y * m[ 7] + z * m[11] + w * m[15];
      }
    }
    buffer.put(arr);
    buffer.position(pos);
  }
 
  /** Multiply float vector components within the buffer with the specified matrix. The {@link Buffer#position()} is used as
   * the offset.
   * @param data The buffer to transform.
View Full Code Here

   * @param count The number of vectors to transform
   * @param matrix The matrix to multiply the vector with */
  public static void transform (Buffer data, int dimensions, int strideInBytes, int count, Matrix3 matrix) {
    FloatBuffer buffer = asFloatBuffer(data);
    // FIXME untested code:
    final int pos = buffer.position();
    int idx = pos;
    float[] arr = asFloatArray(buffer);
    int stride = strideInBytes / 4;
    float[] m = matrix.val;
    for (int i = 0; i < count; i++) {
View Full Code Here

      arr[idx+1] = x * m[ 1] + y * m[ 4] + z * m[ 7];
      if (dimensions >= 3)
        arr[idx+2] = x * m[ 2] + y * m[ 5] + z * m[8];
    }
    buffer.put(arr);
    buffer.position(pos);
  }

  public static long findFloats(Buffer vertex, int strideInBytes, Buffer vertices, int numVertices) {
    return findFloats(asFloatArray(asFloatBuffer(vertex)), strideInBytes, asFloatArray(asFloatBuffer(vertices)), numVertices);
  }
View Full Code Here

      if (cache.counts.length < cache.textureCount) cache.counts = new int[cache.textureCount];
      for (int i = 0, n = cache.textureCount; i < n; i++)
        cache.counts[i] = counts.get(i);

      FloatBuffer vertices = mesh.getVerticesBuffer();
      vertices.position(0);
      Cache lastCache = caches.get(caches.size - 1);
      vertices.limit(lastCache.offset + lastCache.maxCount);
    }

    currentCache = null;
View Full Code Here

    if (dst instanceof ByteBuffer)
      buffer = ((ByteBuffer)dst).asFloatBuffer();
    else if (dst instanceof FloatBuffer) buffer = (FloatBuffer)dst;
    if (buffer == null) throw new GdxRuntimeException("dst must be a ByteBuffer or FloatBuffer");

    int oldPosition = buffer.position();
    buffer.put(src, srcOffset, numElements);
    buffer.position(oldPosition);
    buffer.limit(oldPosition + numElements);
  }
View Full Code Here

    else if (dst instanceof FloatBuffer) buffer = (FloatBuffer)dst;
    if (buffer == null) throw new GdxRuntimeException("dst must be a ByteBuffer or FloatBuffer");

    int oldPosition = buffer.position();
    buffer.put(src, srcOffset, numElements);
    buffer.position(oldPosition);
    buffer.limit(oldPosition + numElements);
  }

  /** Copies the contents of src to dst, starting from src[srcOffset], copying numElements elements. The {@link Buffer} instance's
   * {@link Buffer#position()} is used to define the offset into the Buffer itself. The position will stay the same, the limit
View Full Code Here

  private static FloatBuffer createFloatBuffer(float[] data)
  {
    FloatBuffer ambientDataBuffer = ByteBuffer
               .allocateDirect(data.length*4).order(ByteOrder.nativeOrder()).asFloatBuffer();
     ambientDataBuffer.put(data);
     ambientDataBuffer.position(0);
     return ambientDataBuffer;
  }
 
    public static void ResetMaterial()
    {
View Full Code Here

                final float col = index % side;
                // set texcoords
                final float sU = col / side, eU = (col + 1) / side;
                final float sV = row / side, eV = (row + 1) / side;
                final FloatBuffer texs = parent.getParticleGeometry().getMeshData().getTextureCoords(0).getBuffer();
                texs.position(startIndex * 2);
                texs.put(eU).put(sV);
                texs.put(eU).put(eV);
                texs.put(sU).put(eV);
                texs.put(sU).put(sV);
                texs.clear();
View Full Code Here

        for (int i = 0; i < 16; i++) {
            BufferUtils.setInBuffer(color, colors, i);
        }
        final float alpha = drawOriginConnector ? 0.4f : 0.0f;
        for (int i = 16; i < 24; i++) {
            colors.position(i * 4);
            colors.put(color.getRed());
            colors.put(color.getGreen());
            colors.put(color.getBlue());
            colors.put(alpha);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.