當前位置: 首頁>>代碼示例>>Java>>正文


Java FloatBuffer.rewind方法代碼示例

本文整理匯總了Java中java.nio.FloatBuffer.rewind方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatBuffer.rewind方法的具體用法?Java FloatBuffer.rewind怎麽用?Java FloatBuffer.rewind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.FloatBuffer的用法示例。


在下文中一共展示了FloatBuffer.rewind方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Draws a unit sphere centered at the origin.
 */
public void draw() {
  if (_displayList==null) {
    FloatBuffer xyz = Direct.newFloatBuffer(3*_nv);
    xyz.put(_xyz); xyz.rewind();
    _displayList = new GlDisplayList();
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glNewList(_displayList.list(),GL_COMPILE);
    glVertexPointer(3,GL_FLOAT,0,xyz);
    glNormalPointer(GL_FLOAT,0,xyz);
    glDrawArrays(GL_TRIANGLES,0,_nv);
    glEndList();
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
  }
  glCallList(_displayList.list());
}
 
開發者ID:MinesJTK,項目名稱:jtk,代碼行數:21,代碼來源:EllipsoidGlyph.java

示例2: fillFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
     * <code>fillFloatBuffer</code> fills a FloatBuffer object with the matrix
     * data.
     * 
     * @param fb
     *            the buffer to fill, starting at current position. Must have
     *            room for 16 more floats.
     * @param columnMajor
     *            if true, this buffer should be filled with column major data,
     *            otherwise it will be filled row major.
     * @return matrix data as a FloatBuffer. (position is advanced by 16 and any
     *         limit set is not changed).
     */
    public FloatBuffer fillFloatBuffer(FloatBuffer fb, boolean columnMajor) {
//        if (columnMajor) {
//            fb.put(m00).put(m10).put(m20).put(m30);
//            fb.put(m01).put(m11).put(m21).put(m31);
//            fb.put(m02).put(m12).put(m22).put(m32);
//            fb.put(m03).put(m13).put(m23).put(m33);
//        } else {
//            fb.put(m00).put(m01).put(m02).put(m03);
//            fb.put(m10).put(m11).put(m12).put(m13);
//            fb.put(m20).put(m21).put(m22).put(m23);
//            fb.put(m30).put(m31).put(m32).put(m33);
//        }

        TempVars vars = TempVars.get();


        fillFloatArray(vars.matrixWrite, columnMajor);
        fb.put(vars.matrixWrite, 0, 16);

        vars.release();
        
        fb.rewind();

        return fb;
    }
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:39,代碼來源:Matrix4f.java

示例3: bindUniforms

import java.nio.FloatBuffer; //導入方法依賴的package包/類
void bindUniforms(GL2 gl, Scene scene,Renderer renderer, Simulation s, MeshEntity me, 
        Matrix4f projectionViewModel, Matrix4f viewModel, Matrix4f model,
        FloatBuffer fb) {
    
    fb.rewind();
    gl.glUniformMatrix4fv(mvpMatrixHandle, 1, false, projectionViewModel.fillFloatBuffer(fb, true));
    gl.glUniformMatrix4fv(mvMatrixHandle, 1, false, viewModel.fillFloatBuffer(fb, true));
    gl.glUniformMatrix4fv(mMatrixHandle, 1, false, model.fillFloatBuffer(fb, true));
    
    Vector3f lightPos = scene.getLight().getTransform().getTranslation();
    Vector3f eyePos = scene.getCamera().getTransform().getTranslation();
    
    gl.glUniform4f(lightPosHandle, lightPos.x, lightPos.y, lightPos.z, 1);
    gl.glUniform4f(eyePosHandle, eyePos.x, eyePos.y, eyePos.z, 1);

    float r = Color.red(me.getColor()) / 255.0f;
    float g = Color.green(me.getColor()) / 255.0f;
    float b = Color.blue(me.getColor()) / 255.0f;
    float a = Color.alpha(me.getColor()) / 255.0f;
    gl.glUniform4f(colorHandle, r, g, b, a);

    gl.glUniform1f(ambient, me.getMaterial().getAmbient());
    gl.glUniform1f(diffuse, me.getMaterial().getDiffuse());
    gl.glUniform1f(specular, me.getMaterial().getSpecular());
    gl.glUniform1f(shininess, me.getMaterial().getShininess());
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:27,代碼來源:Shader.java

示例4: clone

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Creates a new FloatBuffer with the same contents as the given
 * FloatBuffer. The new FloatBuffer is seperate 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;
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:27,代碼來源:BufferUtils.java

示例5: toBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
    * Stores the specified 4x4 matrix into a float buffer
    * @param data The 4x4 matrix
    * @return The generated FloatBuffer
    */
   public static FloatBuffer toBuffer(Matrix4f data) {
// Create an empty FloatBuffer with the correct size (4x4)
FloatBuffer buffer = BufferUtils.createFloatBuffer(4 * 4);

// Store the matrix into the buffer
data.store(buffer);

// Prepare the buffer for get() operations
buffer.rewind();

return buffer;
   }
 
開發者ID:camilne,項目名稱:open-world,代碼行數:18,代碼來源:Util.java

示例6: lwjglBody

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void lwjglBody(int gl_format, Texture tx, Texel ir, int mipmap, int slice, Map<String,String> options, DDS_HEADER header, DDS_BODY body) throws Exception {

		IntBuffer intBuf1=BufferUtils.createIntBuffer(1);
		glGenTextures(intBuf1);
		int id=intBuf1.get(0);

		glBindTexture(GL_TEXTURE_2D,id);

		Vector4f pixels[][]=ir.getPixels(PixelFormat.FLOAT_NORMALIZED_RGBA);

		FloatBuffer bbf=BufferUtils.createFloatBuffer(pixels.length*pixels[0].length*4);
		for(int y=0;y<pixels[0].length;y++){
			for(int x=0;x<pixels.length;x++){
				bbf.put(pixels[x][y].x);
				bbf.put(pixels[x][y].y);
				bbf.put(pixels[x][y].z);
				bbf.put(pixels[x][y].w);
			}
		}
		bbf.rewind();
		glTexImage2D(GL_TEXTURE_2D,0,gl_format,pixels.length,pixels[0].length,0,GL_RGBA,GL_FLOAT,bbf);

		int out_size=glGetTexLevelParameteri(GL_TEXTURE_2D,0,GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB);
		ByteBuffer out=BufferUtils.createByteBuffer(out_size);
//		glGetCompressedTexImageARB(GL_TEXTURE_2D,0,out);
		glGetCompressedTexImage(GL_TEXTURE_2D,0,out);
		byte bytes[]=new byte[out_size];
		out.rewind();
		out.get(bytes);
		body.write(bytes);
		BufferUtils.destroyDirectBuffer(out);

		BufferUtils.destroyDirectBuffer(bbf);
		glBindTexture(GL_TEXTURE_2D,0);
		glDeleteTextures(id);
	}
 
開發者ID:riccardobl,項目名稱:DDSWriter,代碼行數:37,代碼來源:LWJGLBlockCompressionDelegate.java

示例7: toFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * <code>toFloatBuffer</code> returns a FloatBuffer object that contains
 * the matrix data.
 * 
 * @return matrix data as a FloatBuffer.
 */
public FloatBuffer toFloatBuffer() {
    FloatBuffer fb = BufferUtils.createFloatBuffer(9);

    fb.put(m00).put(m01).put(m02);
    fb.put(m10).put(m11).put(m12);
    fb.put(m20).put(m21).put(m22);
    fb.rewind();
    return fb;
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:16,代碼來源:Matrix3f.java

示例8: calcWelzl

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Calculates a minimum bounding sphere for the copyTo of points. The algorithm
 * was originally found in C++ at
 * <p><a href="http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1">
 * http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1</a><br><strong>broken link</strong></p>
 * <p>and translated to java by Cep21</p>
 *
 * @param points
 *            The points to calculate the minimum bounds from.
 */
public void calcWelzl(FloatBuffer points) {
    if (center == null) {
        center = new Vector3f();
    }
    FloatBuffer buf = BufferUtils.createFloatBuffer(points.limit());
    points.rewind();
    buf.put(points);
    buf.flip();
    recurseMini(buf, buf.limit() / 3, 0, 0);
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:21,代碼來源:BoundingSphere.java

示例9: quatToGlMatrix

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer quatToGlMatrix(FloatBuffer p_187418_0_, Quaternion p_187418_1_)
{
    p_187418_0_.clear();
    float f = p_187418_1_.x * p_187418_1_.x;
    float f1 = p_187418_1_.x * p_187418_1_.y;
    float f2 = p_187418_1_.x * p_187418_1_.z;
    float f3 = p_187418_1_.x * p_187418_1_.w;
    float f4 = p_187418_1_.y * p_187418_1_.y;
    float f5 = p_187418_1_.y * p_187418_1_.z;
    float f6 = p_187418_1_.y * p_187418_1_.w;
    float f7 = p_187418_1_.z * p_187418_1_.z;
    float f8 = p_187418_1_.z * p_187418_1_.w;
    p_187418_0_.put(1.0F - 2.0F * (f4 + f7));
    p_187418_0_.put(2.0F * (f1 + f8));
    p_187418_0_.put(2.0F * (f2 - f6));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(2.0F * (f1 - f8));
    p_187418_0_.put(1.0F - 2.0F * (f + f7));
    p_187418_0_.put(2.0F * (f5 + f3));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(2.0F * (f2 + f6));
    p_187418_0_.put(2.0F * (f5 - f3));
    p_187418_0_.put(1.0F - 2.0F * (f + f4));
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(0.0F);
    p_187418_0_.put(1.0F);
    p_187418_0_.rewind();
    return p_187418_0_;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:32,代碼來源:GlStateManager.java

示例10: processAPSFrame

import java.nio.FloatBuffer; //導入方法依賴的package包/類
@Override
    public float[] processAPSFrame(AEFrameChipRenderer frame) {
        final int numChannels = processor.isMakeRGBFrames() ? 3 : 1;
        float mean = processor.getImageMean(), scale = processor.getImageScale();
        int width = processor.getImageWidth(), height = processor.getImageHeight();
        if (inputNormalizationGraph == null) {
            Graph g = new Graph();
            GraphBuilder b = new GraphBuilder(g);
            // see https://github.com/tensorflow/tensorflow/issues/6781
            final Output<Float> imagePH = g.opBuilder("Placeholder", "input").setAttr("dtype", DataType.FLOAT).build().output(0);
            final Output<Float> meanPH = g.opBuilder("Placeholder", "mean").setAttr("dtype", DataType.FLOAT).build().output(0);
            final Output<Float> scalePH = g.opBuilder("Placeholder", "scale").setAttr("dtype", DataType.FLOAT).build().output(0);
//            final Output<Integer> widthPH = g.opBuilder("Placeholder", "width").setAttr("dtype", DataType.INT32).build().output(0);
//            final Output<Integer> heightPH = g.opBuilder("Placeholder", "height").setAttr("dtype", DataType.INT32).build().output(0);
            final Output<Integer> sizePH = g.opBuilder("Placeholder", "size").setAttr("dtype", DataType.INT32).build().output(0);
            normalizedImageOutput
                    = b.div(
                            b.sub(
                                    b.resizeBilinear(
                                            imagePH,
                                            sizePH),
                                    meanPH),
                            scalePH);
            inputNormalizationGraph = g;
        }
        final int sx = frame.getWidthInPixels(), sy = frame.getHeightInPixels();
        FloatBuffer fb = FloatBuffer.allocate(sx * sy * numChannels);
        float[] rgb = null;
        if (processor.isMakeRGBFrames()) {
            rgb = new float[]{1, 1, 1};
        } else {
            rgb = new float[]{1};
        }

        for (int y = 0; y < sy; y++) {
            for (int x = 0; x < sx; x++) {
                for (int c = 0; c < numChannels; c++) {
                    final int newIdx = c + numChannels * (x + (sx * (sy - y - 1)));
                    fb.put(newIdx, rgb[c] * frame.getApsGrayValueAtPixel(x, y));
                }
            }
        }
        fb.rewind();
        Tensor<Float> inputImageTensor = Tensor.create(new long[]{1, sy, sx, numChannels}, fb);
        Tensor meanT = Tensor.create(mean);
        Tensor scaleT = Tensor.create(scale);
        Tensor sizeT = Tensor.create(new int[]{height, width});
        Tensor<Float> normalizedImage = new Session(inputNormalizationGraph)
                .runner()
                .feed("input", inputImageTensor)
                .feed("mean", meanT)
                .feed("scale", scaleT)
                .feed("size", sizeT)
                .fetch(normalizedImageOutput.op().name())
                .run()
                .get(0).expect(Float.class);

        float[] results = TensorFlow.executeGraph(executionGraph, normalizedImage, processor.getInputLayerName(), processor.getOutputLayerName());
        outputLayer = new OutputLayer(results);
        getSupport().firePropertyChange(EVENT_MADE_DECISION, null, this);
        return results;
    }
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:63,代碼來源:DavisCNNTensorFlow.java

示例11: createFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer createFloatBuffer(float[] floats) {
  FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
  buffer.put(floats);
  buffer.rewind();
  return buffer;
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:7,代碼來源:Trism.java

示例12: containAABB

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * <code>containAABB</code> creates a minimum-volume axis-aligned bounding
 * box of the points, then selects the smallest enclosing sphere of the box
 * with the sphere centered at the boxes center.
 * 
 * @param points
 *            the list of points.
 */
public void containAABB(FloatBuffer points) {
    if (points == null) {
        return;
    }

    points.rewind();
    if (points.remaining() <= 2) // we need at least a 3 float vector
    {
        return;
    }

    TempVars vars = TempVars.get();
    
    float[] tmpArray = vars.skinPositions;

    float minX = Float.POSITIVE_INFINITY, minY = Float.POSITIVE_INFINITY, minZ = Float.POSITIVE_INFINITY;
    float maxX = Float.NEGATIVE_INFINITY, maxY = Float.NEGATIVE_INFINITY, maxZ = Float.NEGATIVE_INFINITY;
    
    int iterations = (int) M.ceil(points.limit() / ((float) tmpArray.length));
    for (int i = iterations - 1; i >= 0; i--) {
        int bufLength = Math.min(tmpArray.length, points.remaining());
        points.get(tmpArray, 0, bufLength);

        for (int j = 0; j < bufLength; j += 3) {
            vars.vect1.x = tmpArray[j];
            vars.vect1.y = tmpArray[j+1];
            vars.vect1.z = tmpArray[j+2];
            
            if (vars.vect1.x < minX) {
                minX = vars.vect1.x;
            }
            if (vars.vect1.x > maxX) {
                maxX = vars.vect1.x;
            }

            if (vars.vect1.y < minY) {
                minY = vars.vect1.y;
            }
            if (vars.vect1.y > maxY) {
                maxY = vars.vect1.y;
            }

            if (vars.vect1.z < minZ) {
                minZ = vars.vect1.z;
            }
            if (vars.vect1.z > maxZ) {
                maxZ = vars.vect1.z;
            }
        }
    }

    vars.release();

    center.set(minX + maxX, minY + maxY, minZ + maxZ);
    center.multLocal(0.5f);

    xExtent = maxX - center.x;
    yExtent = maxY - center.y;
    zExtent = maxZ - center.z;
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:69,代碼來源:BoundingBox.java

示例13: toFloatBuffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * <code>toFloatBuffer</code> returns a FloatBuffer object that contains the
 * matrix data.
 * 
 * @param columnMajor
 *            if true, this buffer should be filled with column major data,
 *            otherwise it will be filled row major.
 * @return matrix data as a FloatBuffer. The position is set to 0 for
 *         convenience.
 */
public FloatBuffer toFloatBuffer(boolean columnMajor) {
    FloatBuffer fb = BufferUtils.createFloatBuffer(16);
    fillFloatBuffer(fb, columnMajor);
    fb.rewind();
    return fb;
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:17,代碼來源:Matrix4f.java

示例14: createVector3Buffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Create a new FloatBuffer of an appropriate size to hold the specified
 * number of Vector3f object data only if the given buffer if not already
 * the right size.
 * 
 * @param buf
 *            the buffer to first check and rewind
 * @param vertices
 *            number of vertices that need to be held by the newly created
 *            buffer
 * @return the requested new FloatBuffer
 */
public static FloatBuffer createVector3Buffer(FloatBuffer buf, int vertices) {
    if (buf != null && buf.limit() == 3 * vertices) {
        buf.rewind();
        return buf;
    }

    return createFloatBuffer(3 * vertices);
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:21,代碼來源:BufferUtils.java

示例15: createVector2Buffer

import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
 * Create a new FloatBuffer of an appropriate size to hold the specified
 * number of Vector2f object data only if the given buffer if not already
 * the right size.
 * 
 * @param buf
 *            the buffer to first check and rewind
 * @param vertices
 *            number of vertices that need to be held by the newly created
 *            buffer
 * @return the requested new FloatBuffer
 */
public static FloatBuffer createVector2Buffer(FloatBuffer buf, int vertices) {
    if (buf != null && buf.limit() == 2 * vertices) {
        buf.rewind();
        return buf;
    }

    return createFloatBuffer(2 * vertices);
}
 
開發者ID:asiermarzo,項目名稱:Ultraino,代碼行數:21,代碼來源:BufferUtils.java


注:本文中的java.nio.FloatBuffer.rewind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。