/** * Note: data is cast to floats. * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * @return matrix data as a FloatBuffer in row major order. The position is at the end of the inserted data. * @throws NullPointerException * if store is null. * @throws BufferOverflowException * if there is not enough room left in the buffer to write all 16 values. */ @Override public FloatBuffer toFloatBuffer(final FloatBuffer store) { return toFloatBuffer(store, true); }
/** * Note: data is cast to floats. * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * @return matrix data as a FloatBuffer in row major order. The position is at the end of the inserted data. * @throws NullPointerException * if store is null. * @throws BufferOverflowException * if there is not enough room left in the buffer to write all 16 values. */ @Override public FloatBuffer toFloatBuffer(final FloatBuffer store) { return toFloatBuffer(store, true); }
/** * Fill the buffer with the transforms and return it */ protected FloatBuffer fillTransformBuffer() { _primCount = Math.min(_visibleMeshes.size(), _maxBatchSize); final int nrOfFloats = _primCount * 16; /* 16 floats per matrix */ // re-init buffer when it is too small of more than twice the required size if (_transformBuffer == null || nrOfFloats > _transformBuffer.capacity()) { _transformBuffer = BufferUtils.createFloatBuffer(nrOfFloats); } _transformBuffer.rewind(); _transformBuffer.limit(nrOfFloats); final Matrix4 mat = Matrix4.fetchTempInstance(); for (int i = 0; i < _maxBatchSize && _meshesToDraw > 0; i++) { final Mesh mesh = _visibleMeshes.get(--_meshesToDraw); final Matrix4 transform = mesh.getWorldTransform().getHomogeneousMatrix(mat); transform.toFloatBuffer(_transformBuffer, false); } Matrix4.releaseTempInstance(mat); _transformBuffer.rewind(); return _transformBuffer; }
/** * Fill the buffer with the transforms and return it */ protected FloatBuffer fillTransformBuffer() { _primCount = Math.min(_visibleMeshes.size(), _maxBatchSize); final int nrOfFloats = _primCount * 16; /* 16 floats per matrix */ // re-init buffer when it is too small of more than twice the required size if (_transformBuffer == null || nrOfFloats > _transformBuffer.capacity()) { _transformBuffer = BufferUtils.createFloatBuffer(nrOfFloats); } _transformBuffer.rewind(); _transformBuffer.limit(nrOfFloats); final Matrix4 mat = Matrix4.fetchTempInstance(); for (int i = 0; i < _maxBatchSize && _meshesToDraw > 0; i++) { final Mesh mesh = _visibleMeshes.get(--_meshesToDraw); final Matrix4 transform = mesh.getWorldTransform().getHomogeneousMatrix(mat); transform.toFloatBuffer(_transformBuffer, false); } Matrix4.releaseTempInstance(mat); _transformBuffer.rewind(); return _transformBuffer; }
final Matrix4 mat = (Matrix4) value; final FloatBuffer buff = stack.mallocFloat(16); mat.toFloatBuffer(buff, false); return buff.flip(); final FloatBuffer buff = stack.mallocFloat(16 * mats.length); for (final Matrix4 mat : mats) { mat.toFloatBuffer(buff, false);
final FloatBuffer fb = mat4A.toFloatBuffer(FloatBuffer.allocate(16)); fb.flip(); for (int i = 0; i < 16; i++) { mat4A.toFloatBuffer(fb, false); fb.flip(); for (int i = 0; i < 16; i++) {