@Generates private FloatBuffer generateFloatBuffer() { return FloatBuffer.allocate(generateInt()); }
@Override public FloatBuffer getBuffer(float sx, float sy, float base, int size) { FloatBuffer retval = FloatBuffer.allocate(size * size); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { retval.put(this.modulate((sx + x) / size, (sy + y) / size, base)); } } return retval; }
public FloatBuffer clip(FloatBuffer buf, int origSize, int newSize, int offset) { FloatBuffer result = FloatBuffer.allocate(newSize * newSize); float[] orig = buf.array(); for (int i = offset; i < offset + newSize; i++) { result.put(orig, i * origSize + offset, newSize); } return result; } }
@Override public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam) { if( eyeLeftInfo == null ) return cam.getProjectionMatrix(); if( eyeMatrix[EYE_LEFT] == null ) { FloatBuffer tfb = FloatBuffer.allocate(16); com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_LEFT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); eyeMatrix[EYE_LEFT] = new Matrix4f(); eyeMatrix[EYE_LEFT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); } return eyeMatrix[EYE_LEFT]; }
@Override public Matrix4f getHMDMatrixProjectionRightEye(Camera cam) { if( eyeRightInfo == null ) return cam.getProjectionMatrix(); if( eyeMatrix[EYE_RIGHT] == null ) { FloatBuffer tfb = FloatBuffer.allocate(16); com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.osvrClientGetViewerEyeSurfaceProjectionMatrixf(displayConfig, 0, (byte)EYE_RIGHT, 0, cam.getFrustumNear(), cam.getFrustumFar(), (short)0, tfb); eyeMatrix[EYE_RIGHT] = new Matrix4f(); eyeMatrix[EYE_RIGHT].set(tfb.get(0), tfb.get(4), tfb.get(8), tfb.get(12), tfb.get(1), tfb.get(5), tfb.get(9), tfb.get(13), tfb.get(2), tfb.get(6), tfb.get(10), tfb.get(14), tfb.get(3), tfb.get(7), tfb.get(11), tfb.get(15)); } return eyeMatrix[EYE_RIGHT]; }
/** * Creates a new FloatBuffer with the same contents as the given * FloatBuffer. The new FloatBuffer is separate from the old one and changes * are not reflected across. If you want to reflect changes, consider using * Buffer.duplicate(). * * @param buf * the FloatBuffer to copy * @return the copy */ public static FloatBuffer clone(FloatBuffer buf) { if (buf == null) { return null; } buf.rewind(); FloatBuffer copy; if (isDirect(buf)) { copy = createFloatBuffer(buf.limit()); } else { copy = FloatBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
/** * Maps the (x,y) coordinates of <code>tileName</code> in <code>atlas</code> * to the TextureCoordinates of this BaseObject3D * * Saves a copy of the original TextureCoordinates in case of future mapping. * * @param tileName * @param atlas */ public void setAtlasTile(String tileName, TextureAtlas atlas) { Tile tile = atlas.getTileNamed(tileName); if(mOriginalTextureCoords == null) { mOriginalTextureCoords = this.getGeometry().getTextureCoords().duplicate(); } FloatBuffer fb = FloatBuffer.allocate(mOriginalTextureCoords.capacity()); for (int i = 0; i < fb.capacity(); i++) { double uvIn = mOriginalTextureCoords.get(i); double uvOut; if (i % 2 == 0) { uvOut = (uvIn * (tile.width / atlas.getWidth())) + tile.x / atlas.getWidth(); } else { uvOut = (uvIn * (tile.height / atlas.getHeight())) + tile.y / atlas.getHeight(); } fb.put(i, (float) uvOut); } mGeometry.changeBufferData(mGeometry.getTexCoordBufferInfo(), fb, 0); }
weightsFloatData = FloatBuffer.allocate(vertCount * 4); indicesData = ByteBuffer.allocate(vertCount * 4);
FloatBuffer weights = FloatBuffer.allocate( box.getVertexCount() * 4 ); VertexBuffer weightsBuf = new VertexBuffer(Type.BoneWeight); weightsBuf.setupData(Usage.CpuOnly, 4, Format.Float, weights);
if (!weights.getData().hasArray()) { FloatBuffer originalWeight = (FloatBuffer) weights.getData(); FloatBuffer arrayWeight = FloatBuffer.allocate(originalWeight.capacity()); originalWeight.clear(); arrayWeight.put(originalWeight);
@Override public void reallocate(int size) { FloatBuffer oldImpl = impl; impl = FloatBuffer.allocate(size); impl.put(oldImpl); }
protected static FloatBuffer allocateFloatBuffer(int size) { if (USE_DIRECT_BUFFERS) { return allocateDirectFloatBuffer(size); } else { return FloatBuffer.allocate(size); } }
protected static FloatBuffer allocateFloatBuffer(int size) { if (USE_DIRECT_BUFFERS) { return allocateDirectFloatBuffer(size); } else { return FloatBuffer.allocate(size); } }
public void samples(float[] samp) { if ( recording ) { left.put(samp); if ( !left.hasRemaining() ) { buffers.add(left); left = FloatBuffer.allocate(left.capacity()); } } }
@Override protected FloatBuffer deserialize(final ArrayNode input) throws JsonProcessingException { final FloatBuffer result = FloatBuffer.allocate(input.size()); for(final JsonNode node: input) result.put((float) node.asDouble()); return result; } }
protected float getDepthValue(int scrX, int scrY) { if (depthBuffer == null) { depthBuffer = FloatBuffer.allocate(1); } depthBuffer.rewind(); readPixels(scrX, graphics.height - scrY - 1, 1, 1, DEPTH_COMPONENT, FLOAT, depthBuffer); return depthBuffer.get(0); }
protected float getDepthValue(int scrX, int scrY) { if (depthBuffer == null) { depthBuffer = FloatBuffer.allocate(1); } depthBuffer.rewind(); readPixels(scrX, graphics.height - scrY - 1, 1, 1, DEPTH_COMPONENT, FLOAT, depthBuffer); return depthBuffer.get(0); }
FloatBuffer grabScreen(GL gl) { int w = SCREENWITDH; int h = SCREENHEIGHT; FloatBuffer bufor = FloatBuffer.allocate(w*h*4); // 4 = rgba gl.glReadBuffer(GL.GL_FRONT); gl.glReadPixels(0, 0, w, h, GL.GL_RGBA, GL.GL_FLOAT, bufor); //Copy the image to the array imageData return bufor; }
public FloatVBO(int verticeBufferSize, int indexBufferSize){ vertices = FloatBuffer.allocate(verticeBufferSize); indices = IntBuffer.allocate(indexBufferSize); bounds = new BoundingBox3d(); }
@Override public void allocate(int length) { // allocate buffer only at start and when length change if (impl == null || impl.capacity() < length) { impl = FloatBuffer.allocate(length); } else { impl.rewind(); } impl.limit(length); }