Package java.nio

Examples of java.nio.FloatBuffer


  }

  /** Bulk output of a float array. */
  public void writeFloats (float[] object) throws KryoException {
    if (capacity - position >= object.length * 4 && isNativeOrder()) {
      FloatBuffer buf = niobuffer.asFloatBuffer();
      buf.put(object);
      position += object.length * 4;
    } else
      super.writeFloats(object);
  }
View Full Code Here


                         i < 512 ? 0 : MAGIC, array[i]);
        }
    }
    public void testWrappedFloatArrayArguent() {
        float[] array = new float[1024];
        FloatBuffer buf  = FloatBuffer.wrap(array, 512, 512);
        final float MAGIC = -118.625f;
        lib.fillFloatBuffer(buf, 512, MAGIC);
        for (int i=0;i < array.length;i++) {
            assertEquals("Bad value at index " + i,
                         i < 512 ? 0 : MAGIC, array[i]);
View Full Code Here

    }
    public void testFloatBufferPut() {
        final float MAGIC = 1234.5678f;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        FloatBuffer fb = buf.asFloatBuffer();
        fb.put(MAGIC).flip();
        assertEquals("Int not written to memory", MAGIC, m.getFloat(0), 0f);
    }
View Full Code Here

    }
    public void testFloatBufferGet() {
        final float MAGIC = 1234.5678f;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        FloatBuffer fb = buf.asFloatBuffer();
        m.setFloat(0, MAGIC);
        assertEquals("Float not read from memory", MAGIC, fb.get(0), 0f);
    }
View Full Code Here

        GL11.glLoadIdentity();

        if (renderSceneNumber == 0)
        {
            // Left eye
            FloatBuffer leftProj = eyeRenderParams.gl_getLeftProjectionMatrix();
            GL11.glLoadMatrix(leftProj);
            //mc.checkGLError("Set left projection");
        }
        else
        {
            // Right eye
            FloatBuffer rightProj = eyeRenderParams.gl_getRightProjectionMatrix();
            GL11.glLoadMatrix(rightProj);
            //mc.checkGLError("Set right projection");
        }
        float var5;

        if (this.mc.playerController != null && this.mc.playerController.enableEverythingIsScrewedUpMode())
        {
            var5 = 0.6666667F;
            GL11.glScalef(1.0F, var5, 1.0F);
        }

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();

        //First, IPD transformation
        if (renderSceneNumber == 0)
        {
            // Left eye
            FloatBuffer leftEyeTransform = eyeRenderParams.gl_getLeftViewportTransform();
            GL11.glMultMatrix(leftEyeTransform);
        }
        else
        {
            // Right eye
            FloatBuffer rightEyeTransform = eyeRenderParams.gl_getRightViewportTransform();
            GL11.glMultMatrix(rightEyeTransform);
        }

        // Camera height offset
        float cameraYOffset = 1.62f - (this.mc.vrSettings.getPlayerEyeHeight() - this.mc.vrSettings.neckBaseToEyeHeight);
View Full Code Here

            GL11.glLoadIdentity();

            if (renderSceneNumber == 0)
            {
                // Left eye
                FloatBuffer leftProj = eyeRenderParams.gl_getLeftProjectionMatrix();
                GL11.glLoadMatrix(leftProj);
                //mc.checkGLError("Set left projection");
            }
            else
            {
                // Right eye
                FloatBuffer rightProj = eyeRenderParams.gl_getRightProjectionMatrix();
                GL11.glLoadMatrix(rightProj);
                //mc.checkGLError("Set right projection");
            }
            float var3 = 0.07F;

            if (this.mc.gameSettings.anaglyph)
            {
                GL11.glTranslatef((float)(-(renderSceneNumber * 2 - 1)) * var3, 0.0F, 0.0F);
            }

            if (this.cameraZoom != 1.0D)
            {
                GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F);
                GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D);
            }

            if (this.mc.playerController.enableEverythingIsScrewedUpMode())
            {
                float var4 = 0.6666667F;
                GL11.glScalef(1.0F, var4, 1.0F);
            }

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glPushMatrix();
            GL11.glLoadIdentity();

            // IPD transformation
            if (renderSceneNumber == 0)
            {
                // Left eye
                FloatBuffer leftEyeTransform = eyeRenderParams.gl_getLeftViewportTransform();
                GL11.glMultMatrix(leftEyeTransform);
            }
            else
            {
                // Right eye
                FloatBuffer rightEyeTransform = eyeRenderParams.gl_getRightViewportTransform();
                GL11.glMultMatrix(rightEyeTransform);
            }

            if (this.mc.gameSettings.anaglyph)
            {
View Full Code Here

        return matrix;
    }

    public static FloatBuffer quatToMatrix4fFloatBuf(Quaternion q)
    {
        FloatBuffer fb = createFloatBuffer(4*4);
        Matrix4f mat4f = quatToMatrix4f(q);
        mat4f.store(fb);
        fb.flip();
        return fb;
    }
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

      if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) {
    if ((vertexFormat & GeometryArray.INTERLEAVED) == 0) {
        switch ((vertexType & GeometryArrayRetained.TEXCOORD_DEFINED)) {
        case TF:
      FloatBuffer texBuffer = (FloatBuffer)refTexCoordsBuffer[texCoordSet].getROBuffer();
      if(refTexCoords[texCoordSet] != null &&  multiplier * newMax >= texBuffer.limit()) {
          throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray25"));
      }
      break;
        }
    }
View Full Code Here

      cdirty = dirtyFlag;
        }

        Buffer vcoord = null;
        Buffer cdataBuffer = null;
        FloatBuffer normal = null;

        int vdefined = 0;
        if((vertexType & PF!= 0) {
      vdefined |= COORD_FLOAT;
      vcoord = floatBufferRefCoords;
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.