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


Java GL10.GL_FLOAT属性代码示例

本文整理汇总了Java中javax.microedition.khronos.opengles.GL10.GL_FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java GL10.GL_FLOAT属性的具体用法?Java GL10.GL_FLOAT怎么用?Java GL10.GL_FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.microedition.khronos.opengles.GL10的用法示例。


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

示例1: getModelUVElements

private static float[] getModelUVElements(InputStream modelStream)
    throws IOException, UVTypeNotSupportedException {
  byte[] uvBufferSize32Bits = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numUVs32Bits = new byte[4];

  modelStream.read(uvBufferSize32Bits, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numUVs32Bits, 0, 4);

  int uvBufferSize = ByteBuffer.wrap(uvBufferSize32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numUVs = ByteBuffer.wrap(numUVs32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new UVTypeNotSupportedException("Only float UVs are supported");
  }

  // We have multiple elements per uv
  int numUVElements = numUVs * sizePerElement;
  int uvElementTypeSize = uvBufferSize / numUVElements;
  float[] uvElements = new float[numUVElements];
  byte[] currentUVElement32Bit = new byte[uvElementTypeSize];

  // Read the indices into a buffer
  for (int i = 0; i < numUVElements; i++) {
    modelStream.read(currentUVElement32Bit, 0, uvElementTypeSize);
    float currentUVElement = ByteBuffer.wrap(currentUVElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    uvElements[i] = currentUVElement;
  }

  return uvElements;
}
 
开发者ID:rastapasta,项目名称:react-native-gl-model-view,代码行数:38,代码来源:RNGLModelViewModelLoader.java

示例2: getModelNormalElements

private static float[] getModelNormalElements(InputStream modelStream)
    throws IOException, NormalTypeNotSupportedException {
  byte[] normalElementBufferSize32Bit = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numNormalElements32Bit = new byte[4];

  modelStream.read(normalElementBufferSize32Bit, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numNormalElements32Bit, 0, 4);

  int normalElementBufferSize = ByteBuffer.wrap(normalElementBufferSize32Bit).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numNormals = ByteBuffer.wrap(numNormalElements32Bit).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new NormalTypeNotSupportedException("Only float normals are supported");
  }

  // We have multiple elements per normal
  int numNormalElements = numNormals * sizePerElement;
  int normalElementSize = normalElementBufferSize / numNormalElements;
  float[] normalElements = new float[numNormalElements];
  byte[] currentNormalElement32Bit = new byte[normalElementSize];

  // Read the indices into a buffer
  for (int i = 0; i < numNormalElements; i++) {
    modelStream.read(currentNormalElement32Bit, 0, normalElementSize);
    float currentNormalElement = ByteBuffer.wrap(currentNormalElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    normalElements[i] = currentNormalElement;
  }

  return normalElements;
}
 
开发者ID:rastapasta,项目名称:react-native-gl-model-view,代码行数:38,代码来源:RNGLModelViewModelLoader.java

示例3: getModelVertexElements

private static float[] getModelVertexElements(InputStream modelStream)
    throws IOException, VertexTypeNotSupportedException {
  byte[] vertexELementBufferSize32Bits = new byte[4];
  byte[] dataTypeBytes = new byte[4];
  byte[] primTypeBytes = new byte[4];
  byte[] sizePerElementBytes = new byte[4];
  byte[] numVertexElements32Bits = new byte[4];

  modelStream.read(vertexELementBufferSize32Bits, 0, 4);
  modelStream.read(dataTypeBytes, 0, 4);
  modelStream.read(primTypeBytes, 0, 4);
  modelStream.read(sizePerElementBytes, 0, 4);
  modelStream.read(numVertexElements32Bits, 0, 4);

  int vertexElementBufferSize = ByteBuffer.wrap(vertexELementBufferSize32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int dataType = ByteBuffer.wrap(dataTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int sizePerElement = ByteBuffer.wrap(sizePerElementBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
  int numVertices = ByteBuffer.wrap(numVertexElements32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();

  if (dataType != GL10.GL_FLOAT) {
    throw new VertexTypeNotSupportedException("Only float vertices are supported");
  }

  // We have multiple elements per vertex and we will eventually throw away the fourth elements (w)
  int numVertexElements = numVertices * (sizePerElement == 4 ? 3 : sizePerElement);
  int vertexElementSize = vertexElementBufferSize / numVertices / sizePerElement;
  float[] vertexElements = new float[numVertexElements];
  byte[] currentVertexElement32Bit = new byte[vertexElementSize];

  // Read the indices into a buffer
  for (int i = 0; i < numVertexElements; i++) {
    modelStream.read(currentVertexElement32Bit, 0, vertexElementSize);
    float currentVertexElement = ByteBuffer.wrap(currentVertexElement32Bit).order(ByteOrder.LITTLE_ENDIAN).getFloat();
    vertexElements[i] = currentVertexElement;

    // If the model contains Vector4s, we need to throw away the fourth element (w) here
    if (sizePerElement == 4 && (i + 1) % 3 == 0) {
      modelStream.read(currentVertexElement32Bit, 0, vertexElementSize);
    }
  }

  return vertexElements;
}
 
开发者ID:rastapasta,项目名称:react-native-gl-model-view,代码行数:43,代码来源:RNGLModelViewModelLoader.java


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