Package java.nio

Examples of java.nio.DoubleBuffer


    glPopMatrix();
  }
 
  protected void applyCoordinatesSystem() {
    glTranslated(position.getX(), position.getY(), position.getZ());
    DoubleBuffer buf = BufferUtils.createDoubleBuffer(16).put(
        direction.convertToOpenGL());
    buf.flip();
    glMultMatrix(buf);
  }
View Full Code Here


          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

                oldPosition * Sizeof.cl_double);
            buffer.position(oldPosition);
        }
        else if (buffer.hasArray())
        {
            DoubleBuffer t = DoubleBuffer.wrap(buffer.array());
            int elementOffset = buffer.position() + buffer.arrayOffset();
            result = Pointer.to(t).withByteOffset(
                elementOffset * Sizeof.cl_double);
        }
        else
View Full Code Here

  }

  /** Bulk output of a double array. */
  public void writeDoubles (double[] object) throws KryoException {
    if (capacity - position >= object.length * 8 && isNativeOrder()) {
      DoubleBuffer buf = niobuffer.asDoubleBuffer();
      buf.put(object);
      position += object.length * 8;
    } else
      super.writeDoubles(object);
  }
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
          buf = ByteBuffer.allocate(arraySize * 8);
          DoubleBuffer doublebuf = buf.asDoubleBuffer();
          double[] doubleArray = new double[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            doubleArray[i - arrayStart] = Double.longBitsToDouble(this.getLongHeap().heap[i]);
          }
          doublebuf.put(doubleArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        }

      } else if (null != aSofa.getSofaURI()) {
View Full Code Here

     * left corner)
     * @param z the z-depth to render at
     */
    public static void _GLRenderAnimation(RenderingSceneGL gld, AnimationGLHandler anim, Rectangle bounds, double z) {
        int transform = 0;
        DoubleBuffer scale = null;
        DoubleBuffer translate = null;
        if (anim.isTransformEnabled()) {
            if (scale == null) {
                scale = BufferIO._wrapd(new double[]{1, 1});
            }
            if (translate == null) {
View Full Code Here

     * @param colorBlend float array with a 3- or 4-components (RGB(A)) color
     * for blending or null for none
     *
     */
    public static void _GLRenderAnimation(RenderingSceneGL gld, AnimationGLHandler anim, Rectangle bounds, double z, int transform, DoubleBuffer scaleArgs, DoubleBuffer rotateArgs, DoubleBuffer translateArgs, FloatBuffer colorBlend) {
        DoubleBuffer scale = scaleArgs;
        DoubleBuffer translate = translateArgs;
        if (anim.isTransformEnabled()) {
            if (scale == null) {
                scale = BufferIO._wrapd(new double[]{1, 1});
            }
            if (translate == null) {
View Full Code Here

                System.err.println("translate " + translate.get(0) + ", " + translate.get(1));
            }
        } else {
            translate = BufferIO._wrapd(new double[]{0, 0});
        }
        DoubleBuffer eqr = null, eqEye = null;
        DoubleBuffer rotationFX = null, rotationFX_mirror = null;
        if ((transform & GLHandler._GL_TRANSFORM_ROTATE_BIT) != 0 && rotate != null) {
            rotate = BufferIO._wrapd(new double[]{rotate.get(0), 0, 0});
            if (isDebugEnabled()) {
                System.err.println("rotate " + rotate.get(0));
            }
        } else {
            rotate = BufferIO._wrapd(new double[]{0, 0, 0});
        }
        rotationFX = rotationFX_mirror = rotate;
        FloatBuffer colorBlend = fx_color != null ? BufferIO._wrapf(fx_color.getRGBComponents(new float[4])) : null;
        FloatBuffer alphaBlend = BufferIO._wrapf(new float[]{1, 1, 1, 1});
        long now = System.currentTimeMillis();
        final Rectangle fxBounds = texBounds.getBounds();
        Rectangle backgroundClip = new Rectangle(Math.round((float) gld._GLZRatio(z) * gld.getWidth()), Math.round((float) gld._GLZRatio(z) * gld.getHeight()));
        backgroundClip.setLocation(-Math.round(.5f * (backgroundClip.width - gld.getWidth())), -Math.round(.5f * (backgroundClip.height - gld.getHeight())));
        /**
         * retrieve all fx enum fields
         */
        fx &= gfx._FX.bitRangeFields() | gfx._FX_EXT.bitRangeFields() | gfx._FX_ORIENT.bitRangeFields() | gfx._FX_PASS.bitRangeFields();
        /*
         *
         */
        if (fx != gfx.FX_NONE) {
            if (isDebugEnabled()) {
                System.err.print("GLFX ");
                for (gfx select : gfx.values()) {
                    if ((select.bit() & fx) != 0) {
                        System.err.print("fx " + select.toString());
                    }
                }
                System.err.println();
            }
        }
        /**
         * OVERALL FX SETTINGS SCROLLING
         */
        if ((fx & gfx.FX_SCROLLING.bit()) != 0) {
            if (!(FX_lastTransformScrolling.get(mySp.getUID()) instanceof AffineTransform)) {
                FX_lastTransformScrolling.put(mySp.getUID(), new AffineTransform());
            }
            if (!(FX_lastTransformTime.get(mySp.getUID()) instanceof Long)) {
                FX_lastTransformTime.put(mySp.getUID(), now);
            }
            double translateH, translateV;
            translateH = (fx & gfx.FX_HORIZONTAL.bit()) != 0 ? FX_overallSPEED * (now - FX_lastTransformTime.get(mySp.getUID())) : 0f;
            translateV = (fx & gfx.FX_VERTICAL.bit()) != 0 ? FX_overallSPEED * (now - FX_lastTransformTime.get(mySp.getUID())) : 0f;
            FX_lastTransformScrolling.get(mySp.getUID()).setToTranslation(-((Math.abs(FX_lastTransformScrolling.get(mySp.getUID()).getTranslateX()) + translateH) % -texBounds.width), -((Math.abs(FX_lastTransformScrolling.get(mySp.getUID()).getTranslateY()) + translateV) % texBounds.height));
            fx_tx.preConcatenate(FX_lastTransformScrolling.get(mySp.getUID()));
            fx_tx_mirror.preConcatenate(FX_lastTransformScrolling.get(mySp.getUID()));
            FX_lastTransformTime.put(mySp.getUID(), now);
        }
        /**
         * OVERALL FX SETTINGS ROTATION
         */
        if ((fx & gfx.FX_ROTATION.bit()) != 0) {
            if (!(FX_lastTransformTime.get(mySp.getUID()) instanceof Long)) {
                FX_lastTransformTime.put(mySp.getUID(), now);
            }
            float lastTransformTheta = FX_lastTransformTheta.containsKey(mySp.getUID()) ? FX_lastTransformTheta.get(mySp.getUID()) : (1f - 1f / 360f) * 360f;
            float rotationSpeed = FX_overallRADIALSPEED * 360f / (2f * (float) Math.PI);
            if ((fx - (fx & (bits._getAllBits() | bits._getAllBitRanges()))) != 0) {
                rotationSpeed = fx - (fx & (bits._getAllBits() | bits._getAllBitRanges()));
                rotationSpeed /= 1000f;
            }
            lastTransformTheta -= (float) (now - FX_lastTransformTime.get(mySp.getUID())) * rotationSpeed;
            lastTransformTheta = lastTransformTheta % 360f;
            FX_lastTransformTheta.put(mySp.getUID(), lastTransformTheta);
            FX_lastTransformTime.put(mySp.getUID(), now);
            rotationFX = BufferIO._wrapd(new double[]{lastTransformTheta, texBounds.getCenterX(), texBounds.getCenterY()});
            rotationFX_mirror = rotationFX;
        }

        /**
         * OVERALL FX SETTINGS REFLEXION
         */
        if ((fx & gfx.FX_REFLEXION.bit()) != 0) {
            assert (fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit() | gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0 : "no orientation defined FX_BOTTOM, TOP etc.";

            if ((fx & (gfx.FX_1ST_PASS.bit() | gfx.FX_2ND_PASS.bit())) != 0) {
                if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
                    fx_tx_mirror.scale(1., -1.);
                    /*
                     * Clip Plane Equations
                     */
                    if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
                        eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, -(fx_loc.y)});
                        eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{0, 1, 0}));
                    } else {
                        eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, -(fx_loc.y)});
                        eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{0, -1, 0}));
                    }
                    fx_tx_mirror.translate(0, -2. * eqr.get(3));
                }
                if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
                    fx_tx_mirror.scale(-1., 1.);
                    /*
                     * Clip Plane Equations
                     */
                    if ((fx & gfx.FX_RIGHT.bit()) != 0) {
                        eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, -(fx_loc.x)});
                        eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{1, 0, 0}));
                    } else {
                        eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, -(fx_loc.x)});
                        eqEye = RenderingSceneGL._GL_getLookAt_plane(gld.getSize(), gld.getZDepth(), BufferIO._wrapf(new float[]{-1, 0, 0}));
                    }
                    fx_tx_mirror.translate(-2. * eqr.get(3), 0);
                }
            } else {
                if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
                    /*
                     * Clip Plane Equations
                     */
                    if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
                        eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, (fx_loc.y)});
                    } else {
                        eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, (fx_loc.y)});
                    }
                }
                if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
                    /*
                     * Clip Plane Equations
                     */
                    if ((fx & gfx.FX_RIGHT.bit()) != 0) {
                        eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, (fx_loc.x)});
                    } else {
                        eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, (fx_loc.x)});
                    }
                }
            }
            /**
             * FX SETTINGS SHADOW
             */
        } else if ((fx & gfx.FX_SHADOW.bit()) != 0) {
            assert (fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit() | gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0 : "no orientation defined FX_BOTTOM, TOP etc.";
            if ((fx & (gfx.FX_TOP.bit() | gfx.FX_BOTTOM.bit())) != 0) {
                /*
                 * Clip Plane Equations
                 */
                if ((fx & gfx.FX_BOTTOM.bit()) != 0) {
                    eqr = BufferIO._wrapd(new double[]{0.0f, 1, 0.0f, -fx_loc.y});
                } else {
                    eqr = BufferIO._wrapd(new double[]{0.0f, -1, 0.0f, -fx_loc.y});
                }
            }
            if ((fx & (gfx.FX_LEFT.bit() | gfx.FX_RIGHT.bit())) != 0) {
                /*
                 * Clip Plane Equations
                 */
                if ((fx & gfx.FX_RIGHT.bit()) != 0) {
                    eqr = BufferIO._wrapd(new double[]{1, 0f, 0.0f, -fx_loc.x});
                } else {
                    eqr = BufferIO._wrapd(new double[]{-1, 0f, 0.0f, -fx_loc.x});
                }
            }
        }
        /**
         * FX GL BLOCK begin
         */
        boolean fxPushBlockInit = !_fxPushBlock.isOn();
        if (fxPushBlockInit) {
            _fxPushBlock.begin();
            GLHandler._GLpushAttrib(GL11.GL_ENABLE_BIT);
        }
        Util.checkGLError();
        /**
         * 1ST AND 2ND PASSES
         */
        if ((fx & (gfx.FX_1ST_PASS.bit() | gfx.FX_2ND_PASS.bit())) != 0) {
            if ((fx & gfx.FX_1ST_PASS.bit()) != 0) {
                if ((fx & gfx.FX_REFLEXION.bit()) != 0) {
                    GL11.glEnable(GL11.GL_CLIP_PLANE0);
                    GL11.glClipPlane(GL11.GL_CLIP_PLANE0, eqr);
                    GL11.glEnable(GL11.GL_CLIP_PLANE1);
                    GL11.glClipPlane(GL11.GL_CLIP_PLANE1, eqEye);
                    GL11.glDisable(GL11.GL_DEPTH_TEST);
                    Util.checkGLError();
                }
            }
            if ((fx & gfx.FX_2ND_PASS.bit()) != 0) {
                if ((fx & gfx.FX_SHADOW.bit()) != 0) {
                    GLHandler.stView.push();
                    /**
                     * column-major matrix to cast shadows onto the selected
                     * plane
                     */
                    DoubleBuffer shadowCasting = BufferIO._wrapd(new double[]{-eqr.get(3), 0, 0, eqr.get(0), 0, -eqr.get(3), 0, eqr.get(1), 0, 0, -eqr.get(3), eqr.get(2), 0, 0, 0, 0});
                    GL11.glMultMatrix(shadowCasting);
                    /**
                     * translate to make the light source 0,0,0,1
                     */
                    FloatBuffer lightPos = BufferIO._newf(4);
View Full Code Here

  }

  /** Bulk output of a double array. */
  public void writeDoubles (double[] object) throws KryoException {
    if (capacity - position >= object.length * 8 && isNativeOrder()) {
      DoubleBuffer buf = niobuffer.asDoubleBuffer();
      buf.put(object);
      position += object.length * 8;
    } else
      super.writeDoubles(object);
  }
View Full Code Here

TOP

Related Classes of java.nio.DoubleBuffer

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.