Package java.nio

Examples of java.nio.FloatBuffer.clear()


   * @param numFloats the number of floats to copy
   * @param offset the offset in src to start copying from */
  public static void copy (float[] src, Buffer dst, int numFloats, int offset) {
    FloatBuffer floatBuffer = asFloatBuffer(dst);

    floatBuffer.clear();
    dst.position(0);
    floatBuffer.put(src, offset, numFloats);
    dst.position(0);
    if (dst instanceof ByteBuffer)
      dst.limit(numFloats << 2);
View Full Code Here


        // Create a quad to use as geometry for the water.
        waterQuad = new Quad("waterQuad", 1, 1);
        // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as
        // we move this is more convenient than rotating the quad.
        final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer();
        normBuf.clear();
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        waterNode.attachChild(waterQuad);
View Full Code Here

     * @param z
     *            the z
     */
    private void setVertexCoords(final double x, final double y, final double z) {
        final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer();
        vertBuf.clear();

        vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane));
        vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane));
        vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane));
        vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane));
View Full Code Here

        x *= textureScale * 0.5f;
        y *= textureScale * 0.5f;
        textureScale = farPlane * textureScale;
        FloatBuffer texBuf;
        texBuf = waterQuad.getMeshData().getTextureBuffer(buffer);
        texBuf.clear();
        texBuf.put((float) x).put((float) (textureScale + y));
        texBuf.put((float) x).put((float) y);
        texBuf.put((float) (textureScale + x)).put((float) y);
        texBuf.put((float) (textureScale + x)).put((float) (textureScale + y));
    }
View Full Code Here

        // Create a quad to use as geometry for the water.
        waterQuad = new Quad("waterQuad", 1, 1);
        // Hack the quad normals to point up in the y-axis. Since we are manipulating the vertices as
        // we move this is more convenient than rotating the quad.
        final FloatBuffer normBuf = waterQuad.getMeshData().getNormalBuffer();
        normBuf.clear();
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        normBuf.put(0).put(1).put(0);
        waterNode.attachChild(waterQuad);
View Full Code Here

     * @param z
     *            the z
     */
    private void setVertexCoords(final double x, final double y, final double z) {
        final FloatBuffer vertBuf = waterQuad.getMeshData().getVertexBuffer();
        vertBuf.clear();

        vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z - farPlane));
        vertBuf.put((float) (x - farPlane)).put((float) y).put((float) (z + farPlane));
        vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z + farPlane));
        vertBuf.put((float) (x + farPlane)).put((float) y).put((float) (z - farPlane));
View Full Code Here

        x *= textureScale * 0.5f;
        y *= textureScale * 0.5f;
        textureScale = farPlane * textureScale;
        FloatBuffer texBuf;
        texBuf = waterQuad.getMeshData().getTextureBuffer(buffer);
        texBuf.clear();
        texBuf.put((float) x).put((float) (textureScale + y));
        texBuf.put((float) x).put((float) y);
        texBuf.put((float) (textureScale + x)).put((float) y);
        texBuf.put((float) (textureScale + x)).put((float) (textureScale + y));
    }
View Full Code Here

                caller.setTranslation(Math.sin(currentTime) * 10.0, t.getY(), t.getZ());
            }
        });

        final FloatBuffer color1 = torus.getMeshData().getColorBuffer();
        color1.clear();
        for (int i = 0, bLength = color1.capacity(); i < bLength; i += 4) {
            final ReadOnlyColorRGBA c = colorSpread[i % 3];
            color1.put(c.getRed()).put(c.getGreen()).put(c.getBlue()).put(c.getAlpha());
        }
        color1.flip();
View Full Code Here

            final ReadOnlyColorRGBA c = colorSpread[i % 3];
            color1.put(c.getRed()).put(c.getGreen()).put(c.getBlue()).put(c.getAlpha());
        }
        color1.flip();
        final FloatBuffer color2 = sphere.getMeshData().getColorBuffer();
        color2.clear();
        for (int i = 0, bLength = color2.capacity(); i < bLength; i += 4) {
            final ReadOnlyColorRGBA c = colorSpread[i % 3];
            color2.put(c.getRed()).put(c.getGreen()).put(c.getBlue()).put(c.getAlpha());
        }
        color2.flip();
View Full Code Here

      floatBuffer = (FloatBuffer)dst;
    } else {
      throw new GdxRuntimeException("dst must be a ByteBuffer or FloatBuffer");
    }

    floatBuffer.clear();
    dst.position(0);
    floatBuffer.put(src, offset, numFloats);
    dst.position(0);
    if (dst instanceof ByteBuffer)
      dst.limit(numFloats << 2);
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.