Package java.nio

Examples of java.nio.FloatBuffer


  }

  public static void drawClothAsPatchesBAK(DBody[][] bodymatrix) {
    GL11.glEnable(GL11.GL_LIGHTING);

    FloatBuffer fb1 = BufferUtils.createFloatBuffer(4);
    fb1.put(new float[] { .8f, .0f, 1.f, 1.f }).flip();
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, fb1);
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, fb1);

    FloatBuffer fb2 = BufferUtils.createFloatBuffer(4);
    fb2.put(new float[] { .8f, .8f, 0f, 1.f }).flip();
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_AMBIENT, fb2);
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_DIFFUSE, fb2);

    GL11.glLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE);
    GL11.glFrontFace(GL11.GL_CW);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_MAP2_VERTEX_3);
    GL11.glEnable(GL11.GL_AUTO_NORMAL);
    // GL11.glEnable(GL11.GL_MAP2_NORMAL);

    int size = bodymatrix.length;
    FloatBuffer pos = BufferUtils.createFloatBuffer(bodymatrix.length
        * bodymatrix.length * 3);

    for (int i = 0; i < bodymatrix.length; i++) {
      for (int j = 0; j < bodymatrix.length; j++) {
        DVector3C vec0 = bodymatrix[i][j].getPosition();
        float[] f0 = vec0.toFloatArray();
        pos.put(f0);
      }
    }
    pos.rewind();

    GL11.glMap2f(GL11.GL_MAP2_VERTEX_3, 0, 1, size * 3, size, 0, 1, 3,
        size, pos);
    GL11.glMapGrid2f(40, 0, 1, 40, 0, 1);
    GL11.glEvalMesh2(GL11.GL_FILL, 0, 40, 0, 40);
View Full Code Here


    GL11.glLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_TRUE);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    FloatBuffer color = BufferUtils.createFloatBuffer(4);
    color.put(new float[] { .8f, .0f, .8f, 1 }).flip();
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, color); // set material
    GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, color);

    FloatBuffer color2 = BufferUtils.createFloatBuffer(4);
    color2.put(new float[] { 1f, .8f, 0, 1 }).flip();
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_AMBIENT, color2);
    GL11.glMaterial(GL11.GL_BACK, GL11.GL_DIFFUSE, color2);

    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glBegin(GL11.GL_TRIANGLES);
View Full Code Here

  public int getId() {
    return id;
  }

  public void setColor(float[] ambient, float[] diffuse, float[] specular) {
    FloatBuffer lightColor = BufferUtils.createFloatBuffer(4);
    lightColor.put(ambient).flip();
    GL11.glLight(id, GL11.GL_AMBIENT, lightColor);

    lightColor.put(diffuse).flip();
    GL11.glLight(id, GL11.GL_DIFFUSE, lightColor);

    lightColor.put(specular).flip();
    GL11.glLight(id, GL11.GL_SPECULAR, lightColor);
  }
View Full Code Here

    lightingTextureFShader = ShaderManager.getInstance().getShader("lightingTexture.arbfp1");
    lightingTextureBumpVShader = ShaderManager.getInstance().getShader("lightingTextureBump.arbvp1");
    lightingTextureBumpFShader = ShaderManager.getInstance().getShader("lightingTextureBump.arbfp1");

    // set global light settings
    FloatBuffer ambient = BufferUtils.createFloatBuffer(4);
    ambient.put(new float[] { 0.0f, 0.0f, 0.0f, 1.0f }).flip();
    GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, ambient);

    lights = new LinkedList<Light>();
  }
View Full Code Here

   *
   * @return The background color of this graphics context
   */
  public Color getBackground() {
    predraw();
    FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
    GL.glGetFloat(SGL.GL_COLOR_CLEAR_VALUE, buffer);
    postdraw();

    return new Color(buffer);
  }
View Full Code Here

   * of the rendering loop.
   */
  public void pushTransform() {
    predraw();
   
    FloatBuffer buffer;
    if (stackIndex >= stack.size()) {
      buffer = BufferUtils.createFloatBuffer(18);
      stack.add(buffer);
    } else {
      buffer = (FloatBuffer) stack.get(stackIndex);
    }
   
    GL.glGetFloat(GL11.GL_MODELVIEW_MATRIX, buffer);
    buffer.put(16, sx);
    buffer.put(17, sy);
    stackIndex++;
   
    postdraw();
  }
View Full Code Here

    }
   
    predraw();
   
    stackIndex--;
    FloatBuffer oldBuffer = (FloatBuffer) stack.get(stackIndex);
    GL.glLoadMatrix(oldBuffer);
    sx = oldBuffer.get(16);
    sy = oldBuffer.get(17);
   
    postdraw();
  }
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
          FloatBuffer floatbuf = buf.asFloatBuffer();
          float[] floatArray = new float[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            floatArray[i - arrayStart] = Float.intBitsToFloat(this.getHeap().heap[i]);
          }
          floatbuf.put(floatArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_BOOLEAN_ARRAY)
            || type.getName().equals(CAS.TYPE_NAME_BYTE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here

    //setMode(Mode.Lines);
    updateGeometry();
  }
 
  protected void updateGeometry() {
    FloatBuffer positions = BufferUtils.createFloatBuffer(samples * 6);
    FloatBuffer normals = BufferUtils.createFloatBuffer(samples * 6);
    short[] indices = new short[samples * 4];
    float rate = FastMath.PI / ((float) (samples-1));
    float angle = 0;
    for (int i = 0; i < samples; i++) {
      float x = FastMath.cos(angle) + center.x;
      float z = FastMath.sin(angle) + center.z;
      positions.put(x * radius).put(center.y).put(z * radius);
      normals.put(new float[] { 0, 1, 0 });
      indices[i * 2] = (short) i;
      indices[i * 2 + 1] = (short) (i + 1);
      angle += rate;
    }
    angle = FastMath.PI;
   
    center.z = center.z - width;
    for (int i = samples; i < samples*2; i++) {
      float x = FastMath.cos(angle) + center.x;
      float z = FastMath.sin(angle) + center.z;
      positions.put(x * radius).put(center.y).put(z * radius);
      normals.put(new float[] { 0, 1, 0 });
      indices[i * 2] = (short) i;
      if (i < samples*2 - 1)
        indices[i * 2 + 1] = (short) (i + 1);
      else
        indices[i * 2 + 1] = 0;
View Full Code Here

    this.samples = samples;
    setMode(Mode.Lines);
    updateGeometry();
  }
  protected void updateGeometry() {
    FloatBuffer positions = BufferUtils.createFloatBuffer(samples * 3);
    FloatBuffer normals = BufferUtils.createFloatBuffer(samples * 3);
    short[] indices = new short[samples * 2];
    float rate = FastMath.TWO_PI / (float) samples;
    float angle = 0;
    for (int i = 0; i < samples; i++) {
      float x = FastMath.cos(angle) + center.x;
      float z = FastMath.sin(angle) + center.z;
      positions.put(x * radius).put(center.y).put(z * radius);
      normals.put(new float[] { 0, 1, 0 });
      indices[i * 2] = (short) i;
      if (i < samples - 1)
        indices[i * 2 + 1] = (short) (i + 1);
      else
        indices[i * 2 + 1] = 0;
View Full Code Here

TOP

Related Classes of java.nio.FloatBuffer

Copyright © 2018 www.massapicom. 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.