当前位置: 首页>>代码示例>>Java>>正文


Java FloatBuffer类代码示例

本文整理汇总了Java中java.nio.FloatBuffer的典型用法代码示例。如果您正苦于以下问题:Java FloatBuffer类的具体用法?Java FloatBuffer怎么用?Java FloatBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FloatBuffer类属于java.nio包,在下文中一共展示了FloatBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AudioEngine

import java.nio.FloatBuffer; //导入依赖的package包/类
/**
 * (Use this as the default!)
 * Create an AudioEngine with a static listener at the default location (0,0,0).
 */
private AudioEngine() {
    setDeviceAndContext();

    /**
     * Set default values for the listener:
     *     listenerPos : 0.0f, 0.0f, 0.0f
     *     listenerVel : 0.0f, 0.0f, 0.0f
     *     listenerOri : 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f
     */
    listenerPos = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
    listenerVel = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
    listenerOri =
            (FloatBuffer)BufferUtils.createFloatBuffer(6).put(new float[] {0.0f,0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).rewind();

    setListenerValues();
}
 
开发者ID:TauOmicronMu,项目名称:TeamProject,代码行数:21,代码来源:AudioEngine.java

示例2: getScissorRect

import java.nio.FloatBuffer; //导入依赖的package包/类
/**
 * Get the current scissor rectangle
 */
public Rect getScissorRect() {
	if(!Engine.instance().isGLThread()) {
		// 不能在非gl线程中访问
		CCLog.error(TAG, "GLThread error");
		return null;
	}
	FloatBuffer fb = BufferUtils.newFloatBuffer(16); //4 * 4
	Gdx.gl.glGetFloatv(GL20.GL_SCISSOR_BOX, fb);
	float[] params = new float[4];
	fb.get(params);
	
    float x = (params[0] - _viewPortRect.x) / _scaleX;
    float y = (params[1] - _viewPortRect.y) / _scaleY;
    float w = params[2] / _scaleX;
    float h = params[3] / _scaleY;
    return (Rect) poolRect.set(x, y, w, h);
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:21,代码来源:GLView.java

示例3: setCamera

import java.nio.FloatBuffer; //导入依赖的package包/类
public static void setCamera(float partialTicks)
{
    Entity entity = mc.getRenderViewEntity();
    double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
    double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
    double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
    cameraPositionX = d0;
    cameraPositionY = d1;
    cameraPositionZ = d2;
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, (FloatBuffer)projection.position(0));
    SMath.invertMat4FBFA((FloatBuffer)projectionInverse.position(0), (FloatBuffer)projection.position(0), faProjectionInverse, faProjection);
    projection.position(0);
    projectionInverse.position(0);
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, (FloatBuffer)modelView.position(0));
    SMath.invertMat4FBFA((FloatBuffer)modelViewInverse.position(0), (FloatBuffer)modelView.position(0), faModelViewInverse, faModelView);
    modelView.position(0);
    modelViewInverse.position(0);
    checkGLError("setCamera");
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:Shaders.java

示例4: createFloatBuffer

import java.nio.FloatBuffer; //导入依赖的package包/类
/**
 * Generate a new FloatBuffer using the given array of Vector2f objects.
 * The FloatBuffer will be 2 * data.length long and contain the vector data
 * as data[0].x, data[0].y, data[1].x... etc.
 * 
 * @param data array of Vector2f objects to place into a new FloatBuffer
 */
public static FloatBuffer createFloatBuffer(Vector2f... data) {
    if (data == null) {
        return null;
    }
    FloatBuffer buff = createFloatBuffer(2 * data.length);
    for (Vector2f element : data) {
        if (element != null) {
            buff.put(element.x).put(element.y);
        } else {
            buff.put(0).put(0);
        }
    }
    buff.flip();
    return buff;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:23,代码来源:BufferUtils.java

示例5: 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

示例6: testGetUvBuffer

import java.nio.FloatBuffer; //导入依赖的package包/类
@Test
public void testGetUvBuffer() throws Exception {
    Bitmap3DChar o = new Bitmap3DChar(string3D, chr, 3);

    FloatBuffer expected;

    float[] uvs = {
        o.getTopLeftU(), o.getTopLeftV(),
        o.getBottomLeftU(), o.getBottomLeftV(),
        o.getBottomRightU(), o.getBottomRightV(),
        o.getTopRightU(), o.getTopRightV()
    };
    ByteBuffer ulb = ByteBuffer.allocateDirect(uvs.length * 4);
    ulb.order(ByteOrder.nativeOrder());
    expected = ulb.asFloatBuffer();
    expected.put(uvs);
    expected.position(0);

    assertEquals(expected, o.getUvBuffer());
}
 
开发者ID:snada,项目名称:BitmapFontLoader,代码行数:21,代码来源:Bitmap3DCharTest.java

示例7: hmdMat4toMatrix4

import java.nio.FloatBuffer; //导入依赖的package包/类
static void hmdMat4toMatrix4(HmdMatrix44 hdm, Matrix4 mat) {
	float[] val = mat.val;
	FloatBuffer m = hdm.m();
	
	val[0] = m.get(0);
	val[1] = m.get(4);
	val[2] = m.get(8);
	val[3] = m.get(12);
	
	val[4] = m.get(1);
	val[5] = m.get(5);
	val[6] = m.get(9);
	val[7] = m.get(13);
	
	val[8] = m.get(2);
	val[9] = m.get(6);
	val[10] = m.get(10);
	val[11] = m.get(14);
	
	val[12] = m.get(3);
	val[13] = m.get(7);
	val[14] = m.get(11);
	val[15] = m.get(15);
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:25,代码来源:VRContext.java

示例8: testFloatGet

import java.nio.FloatBuffer; //导入依赖的package包/类
@Test(dataProvider = "floatViewProvider")
public void testFloatGet(String desc, IntFunction<ByteBuffer> fbb,
                         Function<ByteBuffer, FloatBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    FloatBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        float fromBytes = getFloatFromBytes(bb, o + i * 4);
        float fromMethodView = bb.getFloat(o + i * 4);
        assertValues(i, fromBytes, fromMethodView, bb);

        float fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        float v = getFloatFromBytes(bb, o + i * 4);
        float a = bb.getFloat();
        assertValues(i, v, a, bb);

        float b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例9: toBinary

import java.nio.FloatBuffer; //导入依赖的package包/类
@Override
public ColumnBinary toBinary(final ColumnBinaryMakerConfig commonConfig , final ColumnBinaryMakerCustomConfigNode currentConfigNode , final IColumn column ) throws IOException{
  ColumnBinaryMakerConfig currentConfig = commonConfig;
  if( currentConfigNode != null ){
    currentConfig = currentConfigNode.getCurrentConfig();
  }
  byte[] binaryRaw = new byte[ getBinaryLength( column.size() ) ];
  ByteBuffer lengthBuffer = ByteBuffer.wrap( binaryRaw );
  lengthBuffer.putInt( column.size() );
  lengthBuffer.putInt( column.size() * Float.BYTES );

  ByteBuffer nullFlagBuffer = ByteBuffer.wrap( binaryRaw , Integer.BYTES * 2 , column.size() );
  FloatBuffer floatBuffer = ByteBuffer.wrap( binaryRaw , ( Integer.BYTES * 2 + column.size() ) , ( column.size() * Float.BYTES ) ).asFloatBuffer();

  int rowCount = 0;
  for( int i = 0 ; i < column.size() ; i++ ){
    ICell cell = column.get(i);
    if( cell.getType() == ColumnType.NULL ){
      nullFlagBuffer.put( (byte)1 );
      floatBuffer.put( (float)0 );
    }
    else{
      rowCount++;
      PrimitiveCell byteCell = (PrimitiveCell) cell;
      nullFlagBuffer.put( (byte)0 );
      floatBuffer.put( byteCell.getRow().getFloat() );
    }
  }

  byte[] binary = currentConfig.compressorClass.compress( binaryRaw , 0 , binaryRaw.length );

  return new ColumnBinary( this.getClass().getName() , currentConfig.compressorClass.getClass().getName() , column.getColumnName() , ColumnType.FLOAT , rowCount , binaryRaw.length , rowCount * Float.BYTES , -1 , binary , 0 , binary.length , null );
}
 
开发者ID:yahoojapan,项目名称:multiple-dimension-spread,代码行数:34,代码来源:DumpFloatColumnBinaryMaker.java

示例10: glUniformMatrix3

import java.nio.FloatBuffer; //导入依赖的package包/类
public static void glUniformMatrix3(int location, boolean transpose, FloatBuffer matrices)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniformMatrix3ARB(location, transpose, matrices);
    }
    else
    {
        GL20.glUniformMatrix3(location, transpose, matrices);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:OpenGlHelper.java

示例11: glUniform4

import java.nio.FloatBuffer; //导入依赖的package包/类
public static void glUniform4(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform4ARB(location, values);
    }
    else
    {
        GL20.glUniform4(location, values);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:OpenGlHelper.java

示例12: getVector3Array

import java.nio.FloatBuffer; //导入依赖的package包/类
/**
 * Generates a Vector3f array from the given FloatBuffer.
 * 
 * @param buff
 *            the FloatBuffer to read from
 * @return a newly generated array of Vector3f objects
 */
public static Vector3f[] getVector3Array(FloatBuffer buff) {
    buff.clear();
    Vector3f[] verts = new Vector3f[buff.limit() / 3];
    for (int x = 0; x < verts.length; x++) {
        Vector3f v = new Vector3f(buff.get(), buff.get(), buff.get());
        verts[x] = v;
    }
    return verts;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:17,代码来源:BufferUtils.java

示例13: glUniform3

import java.nio.FloatBuffer; //导入依赖的package包/类
public static void glUniform3(int location, FloatBuffer values)
{
    if (arbShaders)
    {
        ARBShaderObjects.glUniform3ARB(location, values);
    }
    else
    {
        GL20.glUniform3(location, values);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:12,代码来源:OpenGlHelper.java

示例14: createFloatBuffer

import java.nio.FloatBuffer; //导入依赖的package包/类
public static FloatBuffer createFloatBuffer(float[] coords) {
  // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
  ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4);
  bb.order(ByteOrder.nativeOrder());
  FloatBuffer fb = bb.asFloatBuffer();
  fb.put(coords);
  fb.position(0);
  return fb;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:10,代码来源:GlUtil.java

示例15: initDataFeed

import java.nio.FloatBuffer; //导入依赖的package包/类
public Vbo initDataFeed(FloatBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit() * DataUtils.BYTES_IN_FLOAT);
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:11,代码来源:Vao.java


注:本文中的java.nio.FloatBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。